Thu, 10 Feb 2011 14:48:07 -0800
7018302: newly added assert related to size of constantPoolOop causes secondary assertions or crashes
Summary: 6912621 used a raw oop in the newly added assert following an allocation attempt that could result in a GC.
Reviewed-by: jmasa
src/share/vm/oops/constantPoolKlass.cpp | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/vm/oops/constantPoolKlass.cpp Wed Feb 09 09:43:02 2011 -0800 1.2 +++ b/src/share/vm/oops/constantPoolKlass.cpp Thu Feb 10 14:48:07 2011 -0800 1.3 @@ -55,32 +55,35 @@ 1.4 constantPoolOop constantPoolKlass::allocate(int length, bool is_conc_safe, TRAPS) { 1.5 int size = constantPoolOopDesc::object_size(length); 1.6 KlassHandle klass (THREAD, as_klassOop()); 1.7 - constantPoolOop c = 1.8 - (constantPoolOop)CollectedHeap::permanent_obj_allocate(klass, size, CHECK_NULL); 1.9 + assert(klass()->is_oop(), "Can't be null, else handlizing of c below won't work"); 1.10 + constantPoolHandle pool; 1.11 + { 1.12 + constantPoolOop c = 1.13 + (constantPoolOop)CollectedHeap::permanent_obj_allocate(klass, size, CHECK_NULL); 1.14 + assert(c->klass_or_null() != NULL, "Handlizing below won't work"); 1.15 + pool = constantPoolHandle(THREAD, c); 1.16 + } 1.17 1.18 - c->set_length(length); 1.19 - c->set_tags(NULL); 1.20 - c->set_cache(NULL); 1.21 - c->set_operands(NULL); 1.22 - c->set_pool_holder(NULL); 1.23 - c->set_flags(0); 1.24 + pool->set_length(length); 1.25 + pool->set_tags(NULL); 1.26 + pool->set_cache(NULL); 1.27 + pool->set_operands(NULL); 1.28 + pool->set_pool_holder(NULL); 1.29 + pool->set_flags(0); 1.30 // only set to non-zero if constant pool is merged by RedefineClasses 1.31 - c->set_orig_length(0); 1.32 + pool->set_orig_length(0); 1.33 // if constant pool may change during RedefineClasses, it is created 1.34 // unsafe for GC concurrent processing. 1.35 - c->set_is_conc_safe(is_conc_safe); 1.36 + pool->set_is_conc_safe(is_conc_safe); 1.37 // all fields are initialized; needed for GC 1.38 1.39 // Note: because we may be in this "conc_unsafe" state when allocating 1.40 // t_oop below, which may in turn cause a GC, it is imperative that our 1.41 // size be correct, consistent and henceforth stable, at this stage. 1.42 - assert(c->is_parsable(), "Else size() below is unreliable"); 1.43 - DEBUG_ONLY(int sz = c->size();) 1.44 + assert(pool->is_oop() && pool->is_parsable(), "Else size() below is unreliable"); 1.45 + assert(size == pool->size(), "size() is wrong"); 1.46 1.47 // initialize tag array 1.48 - // Note: cannot introduce constant pool handle before since it is not 1.49 - // completely initialized (no class) -> would cause assertion failure 1.50 - constantPoolHandle pool (THREAD, c); 1.51 typeArrayOop t_oop = oopFactory::new_permanent_byteArray(length, CHECK_NULL); 1.52 typeArrayHandle tags (THREAD, t_oop); 1.53 for (int index = 0; index < length; index++) { 1.54 @@ -89,7 +92,7 @@ 1.55 pool->set_tags(tags()); 1.56 1.57 // Check that our size was stable at its old value. 1.58 - assert(sz == c->size(), "size() changed"); 1.59 + assert(size == pool->size(), "size() changed"); 1.60 return pool(); 1.61 } 1.62