Bug 134093 - Java Application crashes when run from cron
Java Application crashes when run from cron
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: IBMJava2-JRE (Show other bugs)
x86_64 Linux
medium Severity medium
: ---
: ---
Assigned To: Thomas Fitzsimmons
Depends On:
  Show dependency treegraph
Reported: 2004-09-29 12:21 EDT by Dirk Gfroerer
Modified: 2007-11-30 17:07 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-12-22 12:24:47 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Source file with sample program (107 bytes, text/plain)
2004-09-29 12:22 EDT, Dirk Gfroerer
no flags Details
env from command line (1.20 KB, text/plain)
2004-10-14 05:21 EDT, Dirk Gfroerer
no flags Details
env from cron (96 bytes, text/plain)
2004-10-14 05:21 EDT, Dirk Gfroerer
no flags Details
ulimit from command line (457 bytes, text/plain)
2004-10-14 05:22 EDT, Dirk Gfroerer
no flags Details
ulimit from cron (458 bytes, text/plain)
2004-10-14 05:22 EDT, Dirk Gfroerer
no flags Details

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

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):

How reproducible:

Steps to Reproduce:
1. Add attached java program via
x y * * * /etc/alternatives/jre_ibm/bin/java TestMe >/home/digf/x.out
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 12:22:07 EDT
Created attachment 104516 [details]
Source file with sample program
Comment 2 Thomas Fitzsimmons 2004-10-12 13:21:46 EDT
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 03:04:57 EDT
I've tried calling
* /usr/lib/jvm/java-1.4.2-ibm-ibm- 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 10:44:18 EDT
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 05:21:17 EDT
Created attachment 105190 [details]
env from command line
Comment 6 Dirk Gfroerer 2004-10-14 05:21:40 EDT
Created attachment 105191 [details]
env from cron
Comment 7 Dirk Gfroerer 2004-10-14 05:22:03 EDT
Created attachment 105192 [details]
ulimit from command line
Comment 8 Dirk Gfroerer 2004-10-14 05:22:19 EDT
Created attachment 105193 [details]
ulimit from cron
Comment 9 Dirk Gfroerer 2004-10-14 05:23:55 EDT
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 14:07:21 EDT
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 16:04:21 EST
IBM has released a native x86-64 JVM that will ship with RHEL3-U4 as
version java-1.4.2-ibm-
Comment 12 Dirk Gfroerer 2004-12-22 04:27:53 EST
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!

Note You need to log in before you can comment on or make changes to this bug.