Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8143571

[JVMCI] Double unregistering of nmethod during unloading

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 9
    • hotspot
    • b103

      {code:method.cpp}
      1320 void nmethod::make_unloaded(BoolObjectClosure* is_alive, oop cause) {
      ...
      1367 // Unregister must be done before the state change
      1368 Universe::heap()->unregister_nmethod(this);
      1369
      1370 _state = unloaded;
      1371
      1372 #if INCLUDE_JVMCI
      1373 // The method can only be unloaded after the pointer to the installed code
      1374 // Java wrapper is no longer alive. Here we need to clear out this weak
      1375 // reference to the dead object. Nulling out the reference has to happen
      1376 // after the method is unregistered since the original value may be still
      1377 // tracked by the rset.
      1378 maybe_invalidate_installed_code();
      1379 #endif
      {/code}

      We don't actually need to call barriers in maybe_invalidate_installed_code() for the unloaded cases because we've already removed the nmethod from G1's Rsets with Universe::heap()->unregister_nmethod(this). Moreover, nmethod::oops_do() expects the nmethod to be alive:

      # Internal Error (/Users/iggy/work/aot-clean/hotspot/src/share/vm/code/nmethod.cpp:2200), pid=77715, tid=20483
      # assert(!is_unloaded()) failed: should not call follow on unloaded nmethod
          frame #4: 0x0000000103dec0d6 libjvm.dylib`VMError::report_and_die(id=-536870912, message="assert(!is_unloaded()) failed", detail_fmt="should not call follow on unloaded nmethod", detail_args=0x0000700001757d60, thread=0x000000010100e000, pc=0x0000000000000000, siginfo=0x0000000000000000, context=0x0000000000000000, filename="/Users/iggy/work/aot-clean/hotspot/src/share/vm/code/nmethod.cpp", lineno=2200, size=0) + 2582 at vmError.cpp:1153
          frame #5: 0x0000000103dec3f8 libjvm.dylib`VMError::report_and_die(thread=0x000000010100e000, filename="/Users/iggy/work/aot-clean/hotspot/src/share/vm/code/nmethod.cpp", lineno=2200, message="assert(!is_unloaded()) failed", detail_fmt="should not call follow on unloaded nmethod", detail_args=0x0000700001757d60) + 120 at vmError.cpp:932
          frame #6: 0x00000001035aad2f libjvm.dylib`report_vm_error(file="/Users/iggy/work/aot-clean/hotspot/src/share/vm/code/nmethod.cpp", line=2200, error_msg="assert(!is_unloaded()) failed", detail_fmt="should not call follow on unloaded nmethod") + 415 at debug.cpp:218
          frame #7: 0x0000000103b819dd libjvm.dylib`nmethod::oops_do(this=0x000000010d335a90, f=0x0000700001757f78, allow_zombie=false) + 189 at nmethod.cpp:2200
          frame #8: 0x00000001034efc7f libjvm.dylib`nmethod::oops_do(this=0x000000010d335a90, f=0x0000700001757f78) + 31 at nmethod.hpp:793
          frame #9: 0x0000000103734148 libjvm.dylib`G1SATBCardTableModRefBS::write_ref_nmethod_pre(this=0x0000000100504d30, dst=0x000000010d335b00, nm=0x000000010d335a90) + 520 at g1SATBCardTableModRefBS.cpp:285
          frame #10: 0x0000000103b808e2 libjvm.dylib`nmethod::clear_jvmci_installed_code(this=0x000000010d335a90) + 82 at nmethod.cpp:3459
          frame #11: 0x0000000103b7f415 libjvm.dylib`nmethod::maybe_invalidate_installed_code(this=0x000000010d335a90) + 101 at nmethod.cpp:3473
          frame #12: 0x0000000103b7ee9c libjvm.dylib`nmethod::make_unloaded(this=0x000000010d335a90, is_alive=0x0000000104181070, cause=0x00000006c0113db0) + 588 at nmethod.cpp:1378
          frame #13: 0x0000000103b7ff5e libjvm.dylib`nmethod::can_unload(this=0x000000010d335a90, is_alive=0x0000000104181070, root=0x000000010d335b00, unloading_occurred=true) + 254 at nmethod.cpp:1652
          frame #14: 0x0000000103b80622 libjvm.dylib`nmethod::do_unloading(this=0x000000010d335a90, is_alive=0x0000000104181070, unloading_occurred=true) + 1234 at nmethod.cpp:1850

            never Tom Rodriguez
            iveresov Igor Veresov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: