7074579: G1: JVM crash with JDK7 running ATG CRMDemo Fusion App
Summary: Handlize MemoryUsage klass oop in createGCInfo routine
Reviewed-by: tonyp, fparain, ysr, jcoomes
--- a/hotspot/src/share/vm/services/gcNotifier.cpp Thu Aug 11 14:58:29 2011 +0100
+++ b/hotspot/src/share/vm/services/gcNotifier.cpp Thu Aug 11 11:36:29 2011 -0700
@@ -92,7 +92,6 @@
&args,
CHECK_NH);
return Handle(THREAD,(oop)result.get_jobject());
-
}
static Handle createGcInfo(GCMemoryManager *gcManager, GCStatInfo *gcStatInfo,TRAPS) {
@@ -100,9 +99,16 @@
// Fill the arrays of MemoryUsage objects with before and after GC
// per pool memory usage
- klassOop muKlass = Management::java_lang_management_MemoryUsage_klass(CHECK_NH); objArrayOop bu = oopFactory::new_objArray( muKlass,MemoryService::num_memory_pools(), CHECK_NH);
+ klassOop mu_klass = Management::java_lang_management_MemoryUsage_klass(CHECK_NH);
+ instanceKlassHandle mu_kh(THREAD, mu_klass);
+
+ // The array allocations below should use a handle containing mu_klass
+ // as the first allocation could trigger a GC, causing the actual
+ // klass oop to move, and leaving mu_klass pointing to the old
+ // location.
+ objArrayOop bu = oopFactory::new_objArray(mu_kh(), MemoryService::num_memory_pools(), CHECK_NH);
objArrayHandle usage_before_gc_ah(THREAD, bu);
- objArrayOop au = oopFactory::new_objArray(muKlass,MemoryService::num_memory_pools(), CHECK_NH);
+ objArrayOop au = oopFactory::new_objArray(mu_kh(), MemoryService::num_memory_pools(), CHECK_NH);
objArrayHandle usage_after_gc_ah(THREAD, au);
for (int i = 0; i < MemoryService::num_memory_pools(); i++) {
@@ -126,7 +132,7 @@
// The type is 'I'
objArrayOop extra_args_array = oopFactory::new_objArray(SystemDictionary::Integer_klass(), 1, CHECK_NH);
objArrayHandle extra_array (THREAD, extra_args_array);
- klassOop itKlass= SystemDictionary::Integer_klass();
+ klassOop itKlass = SystemDictionary::Integer_klass();
instanceKlassHandle intK(THREAD, itKlass);
instanceHandle extra_arg_val = intK->allocate_instance_handle(CHECK_NH);
@@ -147,7 +153,7 @@
extra_array->obj_at_put(0,extra_arg_val());
klassOop gcInfoklass = Management::com_sun_management_GcInfo_klass(CHECK_NH);
- instanceKlassHandle ik (THREAD,gcInfoklass);
+ instanceKlassHandle ik(THREAD, gcInfoklass);
Handle gcInfo_instance = ik->allocate_instance_handle(CHECK_NH);