changeset 59858:05558bb80462

8247736: Shenandoah: assert(_nm->is_alive()) failed: only alive nmethods here Reviewed-by: rkennke, shade
author zgu
date Mon, 22 Jun 2020 11:40:06 -0400
parents 8d722fb14093
children ce082993c9d2
files src/hotspot/share/gc/shenandoah/shenandoahNMethod.cpp src/hotspot/share/gc/shenandoah/shenandoahNMethod.hpp
diffstat 2 files changed, 10 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/gc/shenandoah/shenandoahNMethod.cpp	Wed May 20 21:12:20 2020 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahNMethod.cpp	Mon Jun 22 11:40:06 2020 -0400
@@ -207,8 +207,7 @@
 }
 
 #ifdef ASSERT
-void ShenandoahNMethod::assert_alive_and_correct() {
-  assert(_nm->is_alive(), "only alive nmethods here");
+void ShenandoahNMethod::assert_correct() {
   ShenandoahHeap* heap = ShenandoahHeap::heap();
   for (int c = 0; c < _oops_count; c++) {
     oop *loc = _oops[c];
@@ -490,14 +489,14 @@
 }
 
 #ifdef ASSERT
-void ShenandoahNMethodTable::assert_nmethods_alive_and_correct() {
+void ShenandoahNMethodTable::assert_nmethods_correct() {
   assert_locked_or_safepoint(CodeCache_lock);
 
   for (int index = 0; index < length(); index ++) {
     ShenandoahNMethod* m = _list->at(index);
     // Concurrent unloading may have dead nmethods to be cleaned by sweeper
     if (m->is_unregistered()) continue;
-    m->assert_alive_and_correct();
+    m->assert_correct();
   }
 }
 #endif
@@ -563,8 +562,11 @@
         continue;
       }
 
-      nmr->assert_alive_and_correct();
-      f->do_code_blob(nmr->nm());
+      // A nmethod can become a zombie before it is unregistered.
+      if (nmr->nm()->is_alive()) {
+        nmr->assert_correct();
+        f->do_code_blob(nmr->nm());
+      }
     }
   }
 }
--- a/src/hotspot/share/gc/shenandoah/shenandoahNMethod.hpp	Wed May 20 21:12:20 2020 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahNMethod.hpp	Mon Jun 22 11:40:06 2020 -0400
@@ -73,7 +73,7 @@
   static inline ShenandoahNMethod* gc_data(nmethod* nm);
   static inline void attach_gc_data(nmethod* nm, ShenandoahNMethod* gc_data);
 
-  void assert_alive_and_correct() NOT_DEBUG_RETURN;
+  void assert_correct() NOT_DEBUG_RETURN;
   void assert_same_oops(bool allow_dead = false) NOT_DEBUG_RETURN;
   static void assert_no_oops(nmethod* nm, bool allow_dea = false) NOT_DEBUG_RETURN;
 
@@ -160,7 +160,7 @@
   ShenandoahNMethodTableSnapshot* snapshot_for_iteration();
   void finish_iteration(ShenandoahNMethodTableSnapshot* snapshot);
 
-  void assert_nmethods_alive_and_correct() NOT_DEBUG_RETURN;
+  void assert_nmethods_correct() NOT_DEBUG_RETURN;
 private:
   // Rebuild table and replace current one
   void rebuild(int size);