From 1340e14e8912e9745ca9616fa264aef0398636fb Mon Sep 17 00:00:00 2001 From: ysr Date: Thu, 10 Feb 2011 14:48:07 -0800 Subject: [PATCH] 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 | 37 +++++++++++++------------ 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/share/vm/oops/constantPoolKlass.cpp b/src/share/vm/oops/constantPoolKlass.cpp index 3b097d963..ad1d73295 100644 --- a/src/share/vm/oops/constantPoolKlass.cpp +++ b/src/share/vm/oops/constantPoolKlass.cpp @@ -55,32 +55,35 @@ constantPoolOop constantPoolKlass::allocate(int length, bool is_conc_safe, TRAPS) { int size = constantPoolOopDesc::object_size(length); KlassHandle klass (THREAD, as_klassOop()); - constantPoolOop c = - (constantPoolOop)CollectedHeap::permanent_obj_allocate(klass, size, CHECK_NULL); - - c->set_length(length); - c->set_tags(NULL); - c->set_cache(NULL); - c->set_operands(NULL); - c->set_pool_holder(NULL); - c->set_flags(0); + assert(klass()->is_oop(), "Can't be null, else handlizing of c below won't work"); + constantPoolHandle pool; + { + constantPoolOop c = + (constantPoolOop)CollectedHeap::permanent_obj_allocate(klass, size, CHECK_NULL); + assert(c->klass_or_null() != NULL, "Handlizing below won't work"); + pool = constantPoolHandle(THREAD, c); + } + + pool->set_length(length); + pool->set_tags(NULL); + pool->set_cache(NULL); + pool->set_operands(NULL); + pool->set_pool_holder(NULL); + pool->set_flags(0); // only set to non-zero if constant pool is merged by RedefineClasses - c->set_orig_length(0); + pool->set_orig_length(0); // if constant pool may change during RedefineClasses, it is created // unsafe for GC concurrent processing. - c->set_is_conc_safe(is_conc_safe); + pool->set_is_conc_safe(is_conc_safe); // all fields are initialized; needed for GC // Note: because we may be in this "conc_unsafe" state when allocating // t_oop below, which may in turn cause a GC, it is imperative that our // size be correct, consistent and henceforth stable, at this stage. - assert(c->is_parsable(), "Else size() below is unreliable"); - DEBUG_ONLY(int sz = c->size();) + assert(pool->is_oop() && pool->is_parsable(), "Else size() below is unreliable"); + assert(size == pool->size(), "size() is wrong"); // initialize tag array - // Note: cannot introduce constant pool handle before since it is not - // completely initialized (no class) -> would cause assertion failure - constantPoolHandle pool (THREAD, c); typeArrayOop t_oop = oopFactory::new_permanent_byteArray(length, CHECK_NULL); typeArrayHandle tags (THREAD, t_oop); for (int index = 0; index < length; index++) { @@ -89,7 +92,7 @@ constantPoolOop constantPoolKlass::allocate(int length, bool is_conc_safe, TRAPS pool->set_tags(tags()); // Check that our size was stable at its old value. - assert(sz == c->size(), "size() changed"); + assert(size == pool->size(), "size() changed"); return pool(); } -- GitLab