diff --git a/src/hotspot/cpu/aarch64/frame_aarch64.cpp b/src/hotspot/cpu/aarch64/frame_aarch64.cpp index 361b913fd2e..6db7b563063 100644 --- a/src/hotspot/cpu/aarch64/frame_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/frame_aarch64.cpp @@ -163,6 +163,11 @@ bool frame::safe_for_sender(JavaThread *thread) { } if (Continuation::is_return_barrier_entry(sender_pc)) { + // sender_pc might be invalid so check that the frame + // actually belongs to a Continuation. + if (!Continuation::is_frame_in_continuation(thread, *this)) { + return false; + } // If our sender_pc is the return barrier, then our "real" sender is the continuation entry frame s = Continuation::continuation_bottom_sender(thread, *this, sender_sp); sender_sp = s.sp(); diff --git a/src/hotspot/cpu/ppc/frame_ppc.cpp b/src/hotspot/cpu/ppc/frame_ppc.cpp index f698b14d312..d258e4d2b42 100644 --- a/src/hotspot/cpu/ppc/frame_ppc.cpp +++ b/src/hotspot/cpu/ppc/frame_ppc.cpp @@ -122,6 +122,11 @@ bool frame::safe_for_sender(JavaThread *thread) { address sender_pc = (address) sender_abi->lr; if (Continuation::is_return_barrier_entry(sender_pc)) { + // sender_pc might be invalid so check that the frame + // actually belongs to a Continuation. + if (!Continuation::is_frame_in_continuation(thread, *this)) { + return false; + } // If our sender_pc is the return barrier, then our "real" sender is the continuation entry frame s = Continuation::continuation_bottom_sender(thread, *this, sender_sp); sender_sp = s.sp(); diff --git a/src/hotspot/cpu/riscv/frame_riscv.cpp b/src/hotspot/cpu/riscv/frame_riscv.cpp index ecc450bd6b2..aaed28f295e 100644 --- a/src/hotspot/cpu/riscv/frame_riscv.cpp +++ b/src/hotspot/cpu/riscv/frame_riscv.cpp @@ -158,6 +158,11 @@ bool frame::safe_for_sender(JavaThread *thread) { } if (Continuation::is_return_barrier_entry(sender_pc)) { + // sender_pc might be invalid so check that the frame + // actually belongs to a Continuation. + if (!Continuation::is_frame_in_continuation(thread, *this)) { + return false; + } // If our sender_pc is the return barrier, then our "real" sender is the continuation entry frame s = Continuation::continuation_bottom_sender(thread, *this, sender_sp); sender_sp = s.sp(); diff --git a/src/hotspot/cpu/x86/frame_x86.cpp b/src/hotspot/cpu/x86/frame_x86.cpp index 4e28dc12534..cb22ec4502d 100644 --- a/src/hotspot/cpu/x86/frame_x86.cpp +++ b/src/hotspot/cpu/x86/frame_x86.cpp @@ -154,6 +154,11 @@ bool frame::safe_for_sender(JavaThread *thread) { } if (Continuation::is_return_barrier_entry(sender_pc)) { + // sender_pc might be invalid so check that the frame + // actually belongs to a Continuation. + if (!Continuation::is_frame_in_continuation(thread, *this)) { + return false; + } // If our sender_pc is the return barrier, then our "real" sender is the continuation entry frame s = Continuation::continuation_bottom_sender(thread, *this, sender_sp); sender_sp = s.sp();