Giant Bug: Cannot run java with a virtual mem limit (ulimit -v)

Bug #1241926 reported by Moritz
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
openjdk-7 (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

$ java
Usage: java [-options] class [args...]
           (to execute a class)
   or java [-options] -jar jarfile [args...]
           (to execute a jar file)
[...]
$ ulimit -v 2097152
$ java
#
# There is insufficient memory for the Java Runtime Environment to continue.
# pthread_getattr_np
# An error report file with more information is saved as:
# /home/moritz/hs_err_pid16051.log

This is no reason why java should try to allocate more than 2 GB of RAM for diplaying a simple help message. If it does need much memory, it should inspect existng limits to make sure it doesn't try to allocate more than the resource limit.

It's very inconvenient not to be able to run java just because of (very generous) per user ulimits.

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: openjdk-7-jre-headless 7u25-2.3.10-1ubuntu0.12.04.2
ProcVersionSignature: Ubuntu 3.8.0-31.46~precise1-generic 3.8.13.8
Uname: Linux 3.8.0-31-generic x86_64
ApportVersion: 2.0.1-0ubuntu17.5
Architecture: amd64
Date: Sat Oct 19 07:08:18 2013
EcryptfsInUse: Yes
InstallationMedia: Ubuntu 12.04.3 LTS "Precise Pangolin" - Release amd64 (20130820.1)
MarkForUpload: True
SourcePackage: openjdk-7
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Moritz (moritz-faui2k3) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in openjdk-7 (Ubuntu):
status: New → Confirmed
summary: - Cannot run java with a uliimt of 2GB virtual memory
+ Giant Bug: Cannot run java with a virtual mem limit (ulimit -v)
Revision history for this message
Martin Babutzka (martin-babutzka) wrote :

Please take this bug serious and report it upstream because whatever is the technical reason for this Java VM behaviour - it needs to be fixed.

Running a usual remote multi-user x86-64 Linux machine I can confirm this GIANT bug and provide additional information:

- This bug applies to all Java versions I tested so far (OpenJDK 6-8, Oracle Java 6-8). The consequences of the bug are excessive and posted several times on the web without a reasonable reaction (e.g. https://bugzilla.redhat.com/show_bug.cgi?id=510344) - except telling the people to provide an artificial memory limit to java directly via -Xmx.

- The bug occurs when the virtual memory limit (ulimit -v) is set below 30% of the total memory available on the system. On large servers the required minimum memory limit becomes huge(!)

- This bug happens with even the simplest java programs among them are the execution of "java -version" or the Hello World example from https://en.wikipedia.org/wiki/Java_%28programming_language%29 .

Example (Server has 48 GB memory):
> ulimit -v 16777216
> java -version
OpenJDK Runtime Environment (IcedTea 2.5.3) (7u71-2.5.3-0ubuntu0.14.04.1)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)

> ulimit -v 12000000
> java -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

> java -Xmx2m -version
java version "1.7.0_65"
OpenJDK Runtime Environment (IcedTea 2.5.3) (7u71-2.5.3-0ubuntu0.14.04.1)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)
--> java -version should run with 2 MB of virtual memory.

Its amazing! Java can't even allocate 12 GB of RAM in the time it needs to put out the out of memory error. I am really curious how it finds the limit so fast to crash. Java can therefore be not executed normally (without -Xmx) on any machine with a reasonable memory limit for users! This behaviour leads to many subsequent bugs in java-software (e.g. eclipse) that I found on the web.

Everyone knows that java is kind of a slow and crappy language but thats not an argument to allow the Java VM to crash if the Helloworld example can not reserve 15 GB of memory on a larger server(!) I have no idea how this bug could survive for that long.

Revision history for this message
Martin Babutzka (martin-babutzka) wrote :

* I wanted to add that I dont want to ultimatively blame Java for this. There is aweseome software out there written in Java. But this VM behavior really did cost me a lot of time and nerves.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.