From 4023b172e9daa24d37ceb4b2da3b2e9caec7bae1 Mon Sep 17 00:00:00 2001 From: coleenp Date: Sat, 15 Feb 2014 13:03:38 -0500 Subject: [PATCH] 8027146: Class loading verification failure if GC occurs in Universe::flush_dependents_on Summary: Remove search in system dictionary and hacks, replace with verifying in CLD::_klasses list. Reviewed-by: dcubed, acorn --- src/share/vm/classfile/classLoaderData.cpp | 9 ++++++++- src/share/vm/classfile/classLoaderData.hpp | 3 ++- src/share/vm/classfile/dictionary.cpp | 4 ++-- src/share/vm/classfile/systemDictionary.cpp | 19 +------------------ src/share/vm/classfile/systemDictionary.hpp | 6 +----- src/share/vm/oops/arrayKlass.cpp | 6 +++--- src/share/vm/oops/arrayKlass.hpp | 4 ++-- src/share/vm/oops/instanceKlass.cpp | 15 ++++++--------- src/share/vm/oops/instanceKlass.hpp | 2 +- src/share/vm/oops/klass.cpp | 4 ++-- src/share/vm/oops/klass.hpp | 6 +++--- src/share/vm/oops/objArrayKlass.cpp | 6 +++--- src/share/vm/oops/objArrayKlass.hpp | 4 ++-- 13 files changed, 36 insertions(+), 52 deletions(-) diff --git a/src/share/vm/classfile/classLoaderData.cpp b/src/share/vm/classfile/classLoaderData.cpp index 892ea92fb..6b34e0150 100644 --- a/src/share/vm/classfile/classLoaderData.cpp +++ b/src/share/vm/classfile/classLoaderData.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -520,6 +520,13 @@ void ClassLoaderData::verify() { } } +bool ClassLoaderData::contains_klass(Klass* klass) { + for (Klass* k = _klasses; k != NULL; k = k->next_link()) { + if (k == klass) return true; + } + return false; +} + // GC root of class loader data created. ClassLoaderData* ClassLoaderDataGraph::_head = NULL; diff --git a/src/share/vm/classfile/classLoaderData.hpp b/src/share/vm/classfile/classLoaderData.hpp index 9e76b5044..3fcbb6b7d 100644 --- a/src/share/vm/classfile/classLoaderData.hpp +++ b/src/share/vm/classfile/classLoaderData.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -260,6 +260,7 @@ class ClassLoaderData : public CHeapObj { jobject add_handle(Handle h); void add_class(Klass* k); void remove_class(Klass* k); + bool contains_klass(Klass* k); void record_dependency(Klass* to, TRAPS); void init_dependencies(TRAPS); diff --git a/src/share/vm/classfile/dictionary.cpp b/src/share/vm/classfile/dictionary.cpp index e308791ca..9a2bb74f8 100644 --- a/src/share/vm/classfile/dictionary.cpp +++ b/src/share/vm/classfile/dictionary.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -707,7 +707,7 @@ void Dictionary::verify() { loader_data->class_loader() == NULL || loader_data->class_loader()->is_instance(), "checking type of class_loader"); - e->verify(/*check_dictionary*/false); + e->verify(); probe->verify_protection_domain_set(); element_count++; } diff --git a/src/share/vm/classfile/systemDictionary.cpp b/src/share/vm/classfile/systemDictionary.cpp index f5c5c017d..703443517 100644 --- a/src/share/vm/classfile/systemDictionary.cpp +++ b/src/share/vm/classfile/systemDictionary.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -2650,23 +2650,6 @@ void SystemDictionary::verify() { constraints()->verify(dictionary(), placeholders()); } - -void SystemDictionary::verify_obj_klass_present(Symbol* class_name, - ClassLoaderData* loader_data) { - GCMutexLocker mu(SystemDictionary_lock); - Symbol* name; - - Klass* probe = find_class(class_name, loader_data); - if (probe == NULL) { - probe = SystemDictionary::find_shared_class(class_name); - if (probe == NULL) { - name = find_placeholder(class_name, loader_data); - } - } - guarantee(probe != NULL || name != NULL, - "Loaded klasses should be in SystemDictionary"); -} - // utility function for class load event void SystemDictionary::post_class_load_event(const Ticks& start_time, instanceKlassHandle k, diff --git a/src/share/vm/classfile/systemDictionary.hpp b/src/share/vm/classfile/systemDictionary.hpp index b0e914ff9..88132f520 100644 --- a/src/share/vm/classfile/systemDictionary.hpp +++ b/src/share/vm/classfile/systemDictionary.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -375,10 +375,6 @@ public: static bool is_internal_format(Symbol* class_name); #endif - // Verify class is in dictionary - static void verify_obj_klass_present(Symbol* class_name, - ClassLoaderData* loader_data); - // Initialization static void initialize(TRAPS); diff --git a/src/share/vm/oops/arrayKlass.cpp b/src/share/vm/oops/arrayKlass.cpp index 9e40206c2..fcb46b11f 100644 --- a/src/share/vm/oops/arrayKlass.cpp +++ b/src/share/vm/oops/arrayKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -214,8 +214,8 @@ void ArrayKlass::oop_print_on(oop obj, outputStream* st) { // Verification -void ArrayKlass::verify_on(outputStream* st, bool check_dictionary) { - Klass::verify_on(st, check_dictionary); +void ArrayKlass::verify_on(outputStream* st) { + Klass::verify_on(st); if (component_mirror() != NULL) { guarantee(component_mirror()->klass() != NULL, "should have a class"); diff --git a/src/share/vm/oops/arrayKlass.hpp b/src/share/vm/oops/arrayKlass.hpp index 4b06f1c0e..7b4ad2e9a 100644 --- a/src/share/vm/oops/arrayKlass.hpp +++ b/src/share/vm/oops/arrayKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -146,7 +146,7 @@ class ArrayKlass: public Klass { void oop_print_on(oop obj, outputStream* st); // Verification - void verify_on(outputStream* st, bool check_dictionary); + void verify_on(outputStream* st); void oop_verify_on(oop obj, outputStream* st); }; diff --git a/src/share/vm/oops/instanceKlass.cpp b/src/share/vm/oops/instanceKlass.cpp index a6ca58c42..ac9340a87 100644 --- a/src/share/vm/oops/instanceKlass.cpp +++ b/src/share/vm/oops/instanceKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -3180,7 +3180,7 @@ class VerifyFieldClosure: public OopClosure { virtual void do_oop(narrowOop* p) { VerifyFieldClosure::do_oop_work(p); } }; -void InstanceKlass::verify_on(outputStream* st, bool check_dictionary) { +void InstanceKlass::verify_on(outputStream* st) { #ifndef PRODUCT // Avoid redundant verifies, this really should be in product. if (_verify_count == Universe::verify_count()) return; @@ -3188,14 +3188,11 @@ void InstanceKlass::verify_on(outputStream* st, bool check_dictionary) { #endif // Verify Klass - Klass::verify_on(st, check_dictionary); + Klass::verify_on(st); - // Verify that klass is present in SystemDictionary if not already - // verifying the SystemDictionary. - if (is_loaded() && !is_anonymous() && check_dictionary) { - Symbol* h_name = name(); - SystemDictionary::verify_obj_klass_present(h_name, class_loader_data()); - } + // Verify that klass is present in ClassLoaderData + guarantee(class_loader_data()->contains_klass(this), + "this class isn't found in class loader data"); // Verify vtables if (is_linked()) { diff --git a/src/share/vm/oops/instanceKlass.hpp b/src/share/vm/oops/instanceKlass.hpp index 2b7a73a31..ba2bce874 100644 --- a/src/share/vm/oops/instanceKlass.hpp +++ b/src/share/vm/oops/instanceKlass.hpp @@ -1086,7 +1086,7 @@ public: const char* internal_name() const; // Verification - void verify_on(outputStream* st, bool check_dictionary); + void verify_on(outputStream* st); void oop_verify_on(oop obj, outputStream* st); }; diff --git a/src/share/vm/oops/klass.cpp b/src/share/vm/oops/klass.cpp index bf5dae060..adca246aa 100644 --- a/src/share/vm/oops/klass.cpp +++ b/src/share/vm/oops/klass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -638,7 +638,7 @@ void Klass::collect_statistics(KlassSizeStats *sz) const { // Verification -void Klass::verify_on(outputStream* st, bool check_dictionary) { +void Klass::verify_on(outputStream* st) { // This can be expensive, but it is worth checking that this klass is actually // in the CLD graph but not in production. diff --git a/src/share/vm/oops/klass.hpp b/src/share/vm/oops/klass.hpp index 9855fdd32..a31a23573 100644 --- a/src/share/vm/oops/klass.hpp +++ b/src/share/vm/oops/klass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -695,8 +695,8 @@ class Klass : public Metadata { virtual const char* internal_name() const = 0; // Verification - virtual void verify_on(outputStream* st, bool check_dictionary); - void verify(bool check_dictionary = true) { verify_on(tty, check_dictionary); } + virtual void verify_on(outputStream* st); + void verify() { verify_on(tty); } #ifndef PRODUCT bool verify_vtable_index(int index); diff --git a/src/share/vm/oops/objArrayKlass.cpp b/src/share/vm/oops/objArrayKlass.cpp index 7294ebe9a..3316a8b27 100644 --- a/src/share/vm/oops/objArrayKlass.cpp +++ b/src/share/vm/oops/objArrayKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -674,8 +674,8 @@ const char* ObjArrayKlass::internal_name() const { // Verification -void ObjArrayKlass::verify_on(outputStream* st, bool check_dictionary) { - ArrayKlass::verify_on(st, check_dictionary); +void ObjArrayKlass::verify_on(outputStream* st) { + ArrayKlass::verify_on(st); guarantee(element_klass()->is_klass(), "should be klass"); guarantee(bottom_klass()->is_klass(), "should be klass"); Klass* bk = bottom_klass(); diff --git a/src/share/vm/oops/objArrayKlass.hpp b/src/share/vm/oops/objArrayKlass.hpp index af06fd420..cfe31e86e 100644 --- a/src/share/vm/oops/objArrayKlass.hpp +++ b/src/share/vm/oops/objArrayKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -151,7 +151,7 @@ class ObjArrayKlass : public ArrayKlass { const char* internal_name() const; // Verification - void verify_on(outputStream* st, bool check_dictionary); + void verify_on(outputStream* st); void oop_verify_on(oop obj, outputStream* st); }; -- GitLab