Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8071445

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

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 7u75
    • Fix Version/s: 9
    • Component/s: hotspot
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      linux_ubuntu

      Description

      FULL PRODUCT VERSION :
      Applies as far as tested to ALL java versions (OpenJDK 6-8 and Oracle Java 6-8)

      FULL OS VERSION :
      Linux 3.13.0-37-generic #64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      Please take this bug seriously - its actually a huge one and might not be disregarded. I think it is also responsible for a lot of subsequent bugs in different kinds of java software but its not always easy to track this down.

      - This bug applies to all Java versions I tested so far (OpenJDK 6-8, Oracle Java 6-8).

      - 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)
      > java HelloWorld
      Hello, World!

      > 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 HelloWorld
      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.

      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 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.

      There are many disregarded replicates of this bug like JDK-8008792 or JDK-8006761.

      THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Yes

      THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes

      REGRESSION. Last worked in version 7u72

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      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.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Java VM crashes in even simplest java programs if a virtual memory limit is active.

      Expectation: Crash only if the VM memory usage actually EXCEEDS the ulimit.
      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      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.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      None required. Works with any Java binary.

      E.g. with the wikipedia HelloWorld example:
      public class HelloWorld {
          public static void main(String[] args) {
              System.out.println("Hello, World!");
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Artificially limiting the java memory usage is a workaround (-Xmx). Yet this should not be necessary for simple programs like HelloWorld or java -version.

      Furthermore, not all published Java software allows an easy setting of the Xmx parameter. There must be a better solution than this workaround.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: