United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7123170 JCK vm/jvmti/ResourceExhausted/resexh001/resexh00101/ tests fails since 7u4 b02
JDK-7123170 : JCK vm/jvmti/ResourceExhausted/resexh001/resexh00101/ tests fails since 7u4 b02

Details
Type:
Bug
Submit Date:
2011-12-20
Status:
Closed
Updated Date:
2013-07-18
Project Name:
JDK
Resolved Date:
2012-03-21
Component:
hotspot
OS:
generic
Sub-Component:
jvmti
CPU:
generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
hs23,7u4
Fixed Versions:
hs24 (b04)

Related Reports
Backport:
Backport:
Backport:
Backport:
Backport:

Sub Tasks

Description
JCK vm/jvmti/ResourceExhausted/resexh001/resexh00101/resexh00101.html test fails since 7u4 b02.

The otput:
java version "1.7.0_04-ea"
Java(TM) SE Runtime Environment (build 1.7.0_04-ea-b02)
Java HotSpot(TM) Server VM (build 23.0-b06, mixed mode)

[check] Unexpected count: 0

Live phase test version:
Successfully attached to JVM with id: 24120
Native agent successfully loaded:  name=jckjvmti  opts=resexh00101
[check] Unexpected count: 0

Test passed on jdk7u4 b01, on jdk7 fcs.
The output of passed tests:
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b148)
Java HotSpot(TM) Client VM (build 21.0-b18, mixed mode)

ResourceExhausted event initiated:
        description: Java heap space
        flags: 0003
Live phase:
Successfully attached to JVM with id: 23566
Native agent successfully loaded:  name=jckjvmti  opts=resexh00101
ResourceExhausted event initiated:
        description: Java heap space
        flags: 0003

Please see more in comments.

                                    

Comments
EVALUATION

% setenv JCK "/net/hsdev-13/export/ss45998/JCK-runtime-7"

The JCK resexh00101 test sources are located here:
  $JCK/tests/vm/jvmti/ResourceExhausted/resexh001/resexh00101

I've modified the test as follows:

*** resexh00101.java.orig       Tue Mar 13 01:17:04 2012
--- resexh00101.java    Tue Mar 13 01:41:13 2012
***************
*** 76,83 ****
                              new HashMap(Integer.MAX_VALUE));
                  }
              }
!         } catch (OutOfMemoryError ok) {
              map = null;
              return check();
          }
 
--- 76,84 ----
                              new HashMap(Integer.MAX_VALUE));
                  }
              }
!         } catch (OutOfMemoryError er) {
              map = null;
+             System.err.println("Serg: OOM: " + er.getMessage());
              return check();
          }

With this test update the output is:

java version "1.7.0_04-ea"
Java(TM) SE Runtime Environment (build 1.7.0_04-ea-b02)
Java HotSpot(TM) Server VM (build 23.0-b06, mixed mode)

Serg: OOM: Requested array size exceeds VM limit
[check] Unexpected count: 0


Checking the Hotspot sources
----------------------------

% cd /net/hsdev-13/export/ss45998/jfr_jdk/hotspot/src/share/vm

% grep report_java_out_of_memory */* | grep -v utilities
gc_interface/collectedHeap.inline.hpp:    report_java_out_of_memory("Java heap space");
gc_interface/collectedHeap.inline.hpp:    report_java_out_of_memory("GC overhead limit exceeded");
gc_interface/collectedHeap.inline.hpp:  report_java_out_of_memory("PermGen space");
oops/arrayKlass.cpp:    report_java_out_of_memory("Requested array size exceeds VM limit");
oops/instanceKlass.cpp:    report_java_out_of_memory("Requested array size exceeds VM limit");
oops/objArrayKlass.cpp:      report_java_out_of_memory("Requested array size exceeds VM limit");
oops/typeArrayKlass.cpp:      report_java_out_of_memory("Requested array size exceeds VM limit");


The ResourceExhausted event is posted in the gc_interface/collectedHeap.inline.hpp:

  if (!gc_overhead_limit_was_exceeded) {
    // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support
    report_java_out_of_memory("Java heap space");

    if (JvmtiExport::should_post_resource_exhausted()) {
      JvmtiExport::post_resource_exhausted(
        JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR | JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP,
        "Java heap space");
    }

    THROW_OOP_0(Universe::out_of_memory_error_java_heap());
  } else {
    // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support
    report_java_out_of_memory("GC overhead limit exceeded");

    if (JvmtiExport::should_post_resource_exhausted()) {
      JvmtiExport::post_resource_exhausted(
        JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR | JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP,
        "GC overhead limit exceeded");
    }

    THROW_OOP_0(Universe::out_of_memory_error_gc_overhead_limit());
  }
 . . .
  // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support
  report_java_out_of_memory("PermGen space");

  if (JvmtiExport::should_post_resource_exhausted()) {
    JvmtiExport::post_resource_exhausted(
        JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR,
        "PermGen space");
  }

  THROW_OOP_0(Universe::out_of_memory_error_perm_gen());

But the event is not posted in the oops/*arrayKlass.cpp when the OOM message
"Requested array size exceeds VM limit" is returned.

oops/arrayKlass.cpp:
    report_java_out_of_memory("Requested array size exceeds VM limit");
    THROW_OOP_0(Universe::out_of_memory_error_array_size());

oops/instanceKlass.cpp:
    report_java_out_of_memory("Requested array size exceeds VM limit");
    THROW_OOP_0(Universe::out_of_memory_error_array_size());

oops/objArrayKlass.cpp:
      report_java_out_of_memory("Requested array size exceeds VM limit");
      THROW_OOP_0(Universe::out_of_memory_error_array_size());

oops/typeArrayKlass.cp:
      report_java_out_of_memory("Requested array size exceeds VM limit");
      THROW_OOP_0(Universe::out_of_memory_error_array_size());


Summary:

The changesets from Tony's integration have no updates of the files above.
So, this fix has just triggered a different code path for this JCK test.
Most likely, the bug existed in the sources for some time (maybe always).

We need to check if there is a reason why the ResourceExhausted JVMTI event is not posted for these 4 cases?
Perhaps, we need to check if there are other places where the OOM is reported.
                                     
2012-03-13
SUGGESTED FIX

Suggested fix:

--- old/src/share/vm/oops/arrayKlass.cpp	Tue Mar 13 15:19:17 2012
+++ new/src/share/vm/oops/arrayKlass.cpp	Tue Mar 13 15:19:16 2012
@@ -153,6 +153,12 @@
   }
   if (length > arrayOopDesc::max_array_length(T_ARRAY)) {
     report_java_out_of_memory("Requested array size exceeds VM limit");
+
+    if (JvmtiExport::should_post_resource_exhausted()) {
+      JvmtiExport::post_resource_exhausted(
+        JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR,
+        "Requested array size exceeds VM limit");
+    }
     THROW_OOP_0(Universe::out_of_memory_error_array_size());
   }
   int size = objArrayOopDesc::object_size(length);
--- old/src/share/vm/oops/instanceKlass.cpp	Tue Mar 13 15:19:20 2012
+++ new/src/share/vm/oops/instanceKlass.cpp	Tue Mar 13 15:19:19 2012
@@ -669,6 +669,11 @@
   if (length < 0) THROW_0(vmSymbols::java_lang_NegativeArraySizeException());
   if (length > arrayOopDesc::max_array_length(T_OBJECT)) {
     report_java_out_of_memory("Requested array size exceeds VM limit");
+    if (JvmtiExport::should_post_resource_exhausted()) {
+      JvmtiExport::post_resource_exhausted(
+        JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR,
+        "Requested array size exceeds VM limit");
+    }
     THROW_OOP_0(Universe::out_of_memory_error_array_size());
   }
   int size = objArrayOopDesc::object_size(length);
--- old/src/share/vm/oops/objArrayKlass.cpp	Tue Mar 13 15:19:22 2012
+++ new/src/share/vm/oops/objArrayKlass.cpp	Tue Mar 13 15:19:22 2012
@@ -68,6 +68,11 @@
       return a;
     } else {
       report_java_out_of_memory("Requested array size exceeds VM limit");
+      if (JvmtiExport::should_post_resource_exhausted()) {
+        JvmtiExport::post_resource_exhausted(
+          JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR,
+          "Requested array size exceeds VM limit");
+      }
       THROW_OOP_0(Universe::out_of_memory_error_array_size());
     }
   } else {
--- old/src/share/vm/oops/typeArrayKlass.cpp	Tue Mar 13 15:19:25 2012
+++ new/src/share/vm/oops/typeArrayKlass.cpp	Tue Mar 13 15:19:24 2012
@@ -93,6 +93,11 @@
       return t;
     } else {
       report_java_out_of_memory("Requested array size exceeds VM limit");
+      if (JvmtiExport::should_post_resource_exhausted()) {
+        JvmtiExport::post_resource_exhausted(
+          JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR,
+          "Requested array size exceeds VM limit");
+      }
       THROW_OOP_0(Universe::out_of_memory_error_array_size());
     }
   } else {
                                     
2012-03-14
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-rt/hotspot/rev/a735aec54ea4
                                     
2012-03-15
SUGGESTED FIX

Integrated into hs24/b04 changset:
 http://hg.openjdk.java.net/hsx/hotspot-rt/hotspot/rev/a735aec54ea4
                                     
2012-03-15
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-main/hotspot/rev/a735aec54ea4
                                     
2012-03-16
EVALUATION

http://hg.openjdk.java.net/hsx/hsx23/hotspot/rev/a5f2ffa62a17
                                     
2012-03-21



Hardware and Software, Engineered to Work Together