Bug 134093

Summary: Java Application crashes when run from cron
Product: Red Hat Enterprise Linux 3 Reporter: Dirk Gfroerer <dirk.gfroerer>
Component: IBMJava2-JREAssignee: Thomas Fitzsimmons <fitzsim>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 3.0   
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-12-22 17:24:47 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Source file with sample program
none
env from command line
none
env from cron
none
ulimit from command line
none
ulimit from cron none

Description Dirk Gfroerer 2004-09-29 16:21:16 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.3)
Gecko/20040803

Description of problem:
I've coded a small hello world application which runs fine at the
command line but crashes immediately when being run by cron.

Version-Release number of selected component (if applicable):
java-1.4.2-ibm-1.4.2.0-1jpp_8rh.i386.rpm

How reproducible:
Always

Steps to Reproduce:
1. Add attached java program via
x y * * * /etc/alternatives/jre_ibm/bin/java TestMe >/home/digf/x.out
2>x.err
to the crontab of a normal user (set x and y as needed)
2. Wait for the cron job to be executed


Actual Results:  Job gets started but hangs. No output is generated.



Expected Results:  Job executes and output is created

Additional info:

digf     17946 17945  0 18:09 ?        00:00:00 /bin/sh -c
/etc/alternatives/jre_ibm/bin/java TestMe >/home/digf/x.out 2>x.err
digf     17949 17946  0 18:09 ?        00:00:00 [java.bin <defunct>]

When prepending LD_ASSUME_KERNEL=2.4.1 before the command, everything
works as expected; as it does when called directly from the command
line; LD_ASSUME_KERNEL is NOT being set at the command line or
environement. It also works from cron on i686 machines but not on a
x86_64 machine.

Comment 1 Dirk Gfroerer 2004-09-29 16:22:07 UTC
Created attachment 104516 [details]
Source file with sample program

Comment 2 Thomas Fitzsimmons 2004-10-12 17:21:46 UTC
This may be caused by the stack limit workaround in the java wrapper
script.  Open /etc/alternatives/jre_ibm/bin/java with a text editor
and try commenting out the if clause.


Comment 3 Dirk Gfroerer 2004-10-13 07:04:57 UTC
I've tried calling
* /usr/lib/jvm/java-1.4.2-ibm-ibm-1.4.2.0/jre/bin/java.bin directly
from cron
* commented everything but the ulimit -s 10240 and called the shell
script again.

Again nothing happend (and I've got a defunct process).

Comment 4 Thomas Fitzsimmons 2004-10-13 14:44:18 UTC
Can you run "env" on the command line and as a cron job and post the
results?  Likewise for "ulimit -a"?

There may be relevant environment variables that are set on the
command line but not by cron.  Likewise, resource settings may differ
in each case.

Another (less likely) possibility is that this is a permission
problem; does the cron job work when run from the root account?


Comment 5 Dirk Gfroerer 2004-10-14 09:21:17 UTC
Created attachment 105190 [details]
env from command line

Comment 6 Dirk Gfroerer 2004-10-14 09:21:40 UTC
Created attachment 105191 [details]
env from cron

Comment 7 Dirk Gfroerer 2004-10-14 09:22:03 UTC
Created attachment 105192 [details]
ulimit from command line

Comment 8 Dirk Gfroerer 2004-10-14 09:22:19 UTC
Created attachment 105193 [details]
ulimit from cron

Comment 9 Dirk Gfroerer 2004-10-14 09:23:55 UTC
I've created the requested outputs and added them via attachements to
the bug. Running the program from cron as root didn't work, too.
What still confuses me, is, why prepending LD_ASSUME_KERNEL=2.4.1 helps?

Comment 10 Thomas Fitzsimmons 2004-10-14 18:07:21 UTC
LD_ASSUME_KERNEL=2.4.1 causes the dynamic linker to load the
LinuxThreads thread library instead of the default, NPTL.  It appears
that the JVM happens to work with LinuxThreads but not with NPTL.

The only difference in the ulimits is the max user processes value. 
You may want to try setting that limit in the cron job to the command
line value.

From the environment variables in the output you've posted, I would
guess that only NLS_LANG, USER, MAIL, LANG and DISPLAY may be
relevant.  Try setting them for the cron run.

Hopefully IBM will release a native x86-64 JVM soon, which will likely
solve this problem without requiring any of these workarounds.


Comment 11 Thomas Fitzsimmons 2004-12-14 21:04:21 UTC
IBM has released a native x86-64 JVM that will ship with RHEL3-U4 as
version java-1.4.2-ibm-1.4.2.0-1jpp_13rh.

Comment 12 Dirk Gfroerer 2004-12-22 09:27:53 UTC
Just brought the machine to U4 and installed the new java rpms.
Everything is now working as expected. So this bug can be closed from
my point of view. Thanks!