src/hotspot/share/classfile/classFileParser.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File
*** old/src/hotspot/share/classfile/classFileParser.cpp	Thu Apr 26 17:30:35 2018
--- new/src/hotspot/share/classfile/classFileParser.cpp	Thu Apr 26 17:30:34 2018

*** 3590,3601 **** --- 3590,3606 ---- this_klass->set_constants(_cp); this_klass->set_fields(_fields, java_fields_count); this_klass->set_methods(_methods); this_klass->set_inner_classes(_inner_classes); this_klass->set_local_interfaces(_local_interfaces); this_klass->set_transitive_interfaces(_transitive_interfaces); this_klass->set_annotations(_combined_annotations); + // Delay the setting of _transitive_interfaces until after initialize_supers() in + // fill_instance_klass(). It is because the _transitive_interfaces may be shared with + // its _super. If an OOM occurs while loading the current klass, its _super field + // may not have been set. When GC tries to free the klass, the _transitive_interfaces + // may be deallocated mistakenly in InstanceKlass::deallocate_interfaces(). Subsequent + // dereferences to the deallocated _transitive_interfaces will result in a crash. // Clear out these fields so they don't get deallocated by the destructor clear_class_metadata(); }
*** 5460,5470 **** --- 5465,5474 ---- assert(NULL == _cp, "invariant"); assert(NULL == _fields, "invariant"); assert(NULL == _methods, "invariant"); assert(NULL == _inner_classes, "invariant"); assert(NULL == _local_interfaces, "invariant"); assert(NULL == _transitive_interfaces, "invariant"); assert(NULL == _combined_annotations, "invariant"); if (_has_final_method) { ik->set_has_final_method(); }
*** 5527,5537 **** --- 5531,5543 ---- ) { ik->set_has_miranda_methods(); // then set a flag } // Fill in information needed to compute superclasses. ! ik->initialize_supers(const_cast<InstanceKlass*>(_super_klass), _transitive_interfaces, CHECK); + ik->set_transitive_interfaces(_transitive_interfaces); + _transitive_interfaces = NULL; // Initialize itable offset tables klassItable::setup_itable_offset_table(ik); // Compute transitive closure of interfaces this class implements
*** 5832,5842 **** --- 5838,5847 ---- _cp = NULL; _fields = NULL; _methods = NULL; _inner_classes = NULL; _local_interfaces = NULL; _transitive_interfaces = NULL; _combined_annotations = NULL; _annotations = _type_annotations = NULL; _fields_annotations = _fields_type_annotations = NULL; }
*** 5884,5893 **** --- 5889,5899 ---- Annotations::free_contents(_loader_data, _fields_annotations); Annotations::free_contents(_loader_data, _fields_type_annotations); } clear_class_metadata(); + _transitive_interfaces = NULL; // deallocate the klass if already created. Don't directly deallocate, but add // to the deallocate list so that the klass is removed from the CLD::_klasses list // at a safepoint. if (_klass_to_deallocate != NULL) {

src/hotspot/share/classfile/classFileParser.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File