JDK-8057570 : RedefineClasses() tests fail assert(((Metadata*)obj)->is_valid()) failed: obj is valid
  • Type: Bug
  • Component: hotspot
  • Sub-Component: jvmti
  • Affected Version: 9
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: x86_64
  • Submitted: 2014-09-04
  • Updated: 2019-01-14
  • Resolved: 2014-09-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9 Other
8u162Fixed 9 b32Fixed emb-8u181Fixed
Description
These test failures were spotted in the 2014-09-03 RT_Baseline nightly.

nsk/jvmti/scenarios/hotswap/HS102/hs102t001
nsk/jvmti/scenarios/hotswap/HS102/hs102t002
    These tests failed the following assertion:

    #  Internal Error (src/share/vm/runtime/handles.inline.hpp:115), pid=28652, tid=140575061673728
    #  assert(((Metadata*)obj)->is_valid()) failed: obj is valid

    Here is the crashing stack trace:

---------------  T H R E A D  ---------------

Current thread (0x00007fda9c166800):  VMThread [stack: 0x00007fda2e8d8000,0x00007fda2e9d9000] [id=28667]

Stack: [0x00007fda2e8d8000,0x00007fda2e9d9000],  sp=0x00007fda2e9d73c0,  free space=1020k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x10717d1]  VMError::report_and_die()+0x151;;  VMError::report_and_die()+0x151
V  [libjvm.so+0x7316cb]  report_vm_error(char const*, int, char const*, char const*)+0x7b;;  report_vm_error(char const*, int, char const*, char const*)+0x7b
V  [libjvm.so+0x3d8e9f]  methodHandle::methodHandle(Method*)+0xbf;;  methodHandle::methodHandle(Method*)+0xbf
V  [libjvm.so+0xd6cb11]  nmethod::make_not_entrant_or_zombie(unsigned int)+0xb1;;  nmethod::make_not_entrant_or_zombie(unsigned int)+0xb1
V  [libjvm.so+0x66d654]  CodeCache::make_marked_nmethods_zombies()+0xd4;;  CodeCache::make_marked_nmethods_zombies()+0xd4
V  [libjvm.so+0x101652d]  Universe::flush_evol_dependents_on(instanceKlassHandle)+0xdd;;  Universe::flush_evol_dependents_on(instanceKlassHandle)+0xdd
V  [libjvm.so+0xbba535]  VM_RedefineClasses::redefine_single_class(_jclass*, Klass*, Thread*)+0x7d5;;  VM_RedefineClasses::redefine_single_class(_jclass*, Klass*, Thread*)+0x7d5
V  [libjvm.so+0xbba9ec]  VM_RedefineClasses::doit()+0xac;;  VM_RedefineClasses::doit()+0xac
V  [libjvm.so+0x109b533]  VM_Operation::evaluate()+0xa3;;  VM_Operation::evaluate()+0xa3
V  [libjvm.so+0x1098e1e]  VMThread::evaluate_operation(VM_Operation*)+0x14e;;  VMThread::evaluate_operation(VM_Operation*)+0x14e
V  [libjvm.so+0x1099753]  VMThread::loop()+0x4b3;;  VMThread::loop()+0x4b3
V  [libjvm.so+0x1099981]  VMThread::run()+0xb1;;  VMThread::run()+0xb1
V  [libjvm.so+0xdc3ab2]  java_start(Thread*)+0xf2;;  java_start(Thread*)+0xf2

VM_Operation (0x00007fda2cc87b70): RedefineClasses, mode: safepoint, requested by thread 0x00007fda9c4c8800
Comments
URL: http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/479ed4234a9d User: lana Date: 2014-09-24 20:47:23 +0000
24-09-2014

URL: http://hg.openjdk.java.net/jdk9/hs-rt/hotspot/rev/479ed4234a9d User: coleenp Date: 2014-09-05 13:38:21 +0000
05-09-2014

I had changed the code in nmethod::metadata_do() so that the _method field isn't walked because I erroneously thought that we always added the Method* to the metadata section above // Visit the metadata section for (Metadata** p = metadata_begin(); p < metadata_end(); p++) { if (*p == Universe::non_oop_word() || *p == NULL) continue; // skip non-oops Metadata* md = *p; f(md); } // Call function Method*, not embedded in these other places. if (_method != NULL) f(_method); I misremembered what CodeBuffer::finalize_oop_references does here. This only keeps Method* from being unloaded if the nmethod is still alive, not adds the Method to the metadata section. // Add the class loader of Method* for the nmethod itself append_oop_references(&oops, mh->method_holder()); The nmethod that failed with a garbage method wasn't marked during MetadataOnStackMark, which calls nmethod::metadata_do. What was odd about this nmethod is that the oop and metadata sections were all empty, which I didn't understand and know if this was caused by making the nmethod already non-entrant or deoptimized? Or if it was some deviant nmethod. Reverting this change fixes the regression.
05-09-2014

They don't fail on my linux x64 system either with the same options.
04-09-2014