changeset 57502:fd1fe6f7daab

8235669: G1: Stack walking API can expose AS_NO_KEEPALIVE oops Reviewed-by: kbarrett, tschatzl
author eosterlund
date Fri, 10 Jan 2020 16:20:31 +0000
parents 087ad80a9489
children f7ab94fadd5a
files src/hotspot/share/code/debugInfo.cpp
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/code/debugInfo.cpp	Fri Jan 10 16:30:02 2020 +0100
+++ b/src/hotspot/share/code/debugInfo.cpp	Fri Jan 10 16:20:31 2020 +0000
@@ -51,7 +51,15 @@
 }
 
 oop DebugInfoReadStream::read_oop() {
-  oop o = code()->oop_at(read_int());
+  nmethod* nm = const_cast<CompiledMethod*>(code())->as_nmethod_or_null();
+  oop o;
+  if (nm != NULL) {
+    // Despite these oops being found inside nmethods that are on-stack,
+    // they are not kept alive by all GCs (e.g. G1 and Shenandoah).
+    o = nm->oop_at_phantom(read_int());
+  } else {
+    o = code()->oop_at(read_int());
+  }
   assert(oopDesc::is_oop_or_null(o), "oop only");
   return o;
 }