8235669: G1: Stack walking API can expose AS_NO_KEEPALIVE oops

Reviewed-by: kbarrett, tschatzl
This commit is contained in:
Erik Österlund 2020-01-10 16:20:31 +00:00
parent 89f7e1925e
commit feccf3cdb6

View File

@ -51,7 +51,15 @@ void DebugInfoWriteStream::write_metadata(Metadata* h) {
}
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;
}