Mercurial > hg > truffle
comparison src/share/vm/classfile/systemDictionary.cpp @ 17883:9428a0b94204
8028497: SIGSEGV at ClassLoaderData::oops_do(OopClosure*, KlassClosure*, bool)
Summary: Keep class in CLD::_klasses list and mirror created for CDS classes if OOM during restore_shareable_info(). This keeps pointers consistent for CMS.
Reviewed-by: ehelin, stefank, jmasa, iklam
author | coleenp |
---|---|
date | Tue, 15 Apr 2014 17:02:20 -0400 |
parents | 85318d1fe8fe |
children | 78bbf4d43a14 |
comparison
equal
deleted
inserted
replaced
17876:9c3dc501b5eb | 17883:9428a0b94204 |
---|---|
824 } | 824 } |
825 } | 825 } |
826 } | 826 } |
827 } // load_instance_class loop | 827 } // load_instance_class loop |
828 | 828 |
829 if (HAS_PENDING_EXCEPTION) { | |
830 // An exception, such as OOM could have happened at various places inside | |
831 // load_instance_class. We might have partially initialized a shared class | |
832 // and need to clean it up. | |
833 if (class_loader.is_null()) { | |
834 // In some cases k may be null. Let's find the shared class again. | |
835 instanceKlassHandle ik(THREAD, find_shared_class(name)); | |
836 if (ik.not_null()) { | |
837 if (ik->class_loader_data() == NULL) { | |
838 // We didn't go as far as Klass::restore_unshareable_info(), | |
839 // so nothing to clean up. | |
840 } else { | |
841 Klass *kk; | |
842 { | |
843 MutexLocker mu(SystemDictionary_lock, THREAD); | |
844 kk = find_class(d_index, d_hash, name, ik->class_loader_data()); | |
845 } | |
846 if (kk != NULL) { | |
847 // No clean up is needed if the shared class has been entered | |
848 // into system dictionary, as load_shared_class() won't be called | |
849 // again. | |
850 } else { | |
851 // This must be done outside of the SystemDictionary_lock to | |
852 // avoid deadlock. | |
853 // | |
854 // Note that Klass::restore_unshareable_info (called via | |
855 // load_instance_class above) is also called outside | |
856 // of SystemDictionary_lock. Other threads are blocked from | |
857 // loading this class because they are waiting on the | |
858 // SystemDictionary_lock until this thread removes | |
859 // the placeholder below. | |
860 // | |
861 // This need to be re-thought when parallel-capable non-boot | |
862 // classloaders are supported by CDS (today they're not). | |
863 clean_up_shared_class(ik, class_loader, THREAD); | |
864 } | |
865 } | |
866 } | |
867 } | |
868 } | |
869 | |
870 if (load_instance_added == true) { | 829 if (load_instance_added == true) { |
871 // clean up placeholder entries for LOAD_INSTANCE success or error | 830 // clean up placeholder entries for LOAD_INSTANCE success or error |
872 // This brackets the SystemDictionary updates for both defining | 831 // This brackets the SystemDictionary updates for both defining |
873 // and initiating loaders | 832 // and initiating loaders |
874 MutexLocker mu(SystemDictionary_lock, THREAD); | 833 MutexLocker mu(SystemDictionary_lock, THREAD); |
1270 true /* shared class */); | 1229 true /* shared class */); |
1271 } | 1230 } |
1272 return ik; | 1231 return ik; |
1273 } | 1232 } |
1274 | 1233 |
1275 void SystemDictionary::clean_up_shared_class(instanceKlassHandle ik, Handle class_loader, TRAPS) { | |
1276 // Updating methods must be done under a lock so multiple | |
1277 // threads don't update these in parallel | |
1278 // Shared classes are all currently loaded by the bootstrap | |
1279 // classloader, so this will never cause a deadlock on | |
1280 // a custom class loader lock. | |
1281 { | |
1282 Handle lockObject = compute_loader_lock_object(class_loader, THREAD); | |
1283 check_loader_lock_contention(lockObject, THREAD); | |
1284 ObjectLocker ol(lockObject, THREAD, true); | |
1285 ik->remove_unshareable_info(); | |
1286 } | |
1287 } | |
1288 | 1234 |
1289 instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Handle class_loader, TRAPS) { | 1235 instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Handle class_loader, TRAPS) { |
1290 instanceKlassHandle nh = instanceKlassHandle(); // null Handle | 1236 instanceKlassHandle nh = instanceKlassHandle(); // null Handle |
1291 if (class_loader.is_null()) { | 1237 if (class_loader.is_null()) { |
1292 | 1238 |