Skip to content

Commit

Permalink
8295872: [PPC64] JfrGetCallTrace: Need pc == nullptr check before fra…
Browse files Browse the repository at this point in the history
…me constructor

Backport-of: 59a13b1856cb1cf86385874b1152531016d41c22
  • Loading branch information
TheRealMDoerr committed Nov 11, 2022
1 parent 7d17479 commit 3486bb2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
13 changes: 9 additions & 4 deletions src/hotspot/os_cpu/aix_ppc/thread_aix_ppc.cpp
Expand Up @@ -32,7 +32,9 @@
frame JavaThread::pd_last_frame() {
assert(has_last_Java_frame(), "must have last_Java_sp() when suspended");

intptr_t* sp = Atomic::load_acquire(&_anchor._last_Java_sp);
// Only called by current thread or when the thread is suspended.
// No memory barrier needed, here. Only writer must write sp last (for use by profiler).
intptr_t* sp = last_Java_sp();
address pc = _anchor.last_Java_pc();

// Last_Java_pc ist not set, if we come here from compiled code.
Expand All @@ -50,9 +52,12 @@ bool JavaThread::pd_get_top_frame_for_profiling(frame* fr_addr, void* ucontext,
// If we have a last_Java_frame, then we should use it even if
// isInJava == true. It should be more reliable than ucontext info.
if (has_last_Java_frame() && frame_anchor()->walkable()) {
frame last_frame = pd_last_frame();
if (last_frame.pc() == nullptr) return false;
*fr_addr = last_frame;
intptr_t* sp = last_Java_sp();
address pc = _anchor.last_Java_pc();
// pc can be seen as null because not all writers use store pc + release store sp.
// Simply discard the sample in this very rare case.
if (pc == nullptr) return false;
*fr_addr = frame(sp, pc);
return true;
}

Expand Down
13 changes: 9 additions & 4 deletions src/hotspot/os_cpu/linux_ppc/thread_linux_ppc.cpp
Expand Up @@ -31,7 +31,9 @@
frame JavaThread::pd_last_frame() {
assert(has_last_Java_frame(), "must have last_Java_sp() when suspended");

intptr_t* sp = Atomic::load_acquire(&_anchor._last_Java_sp);
// Only called by current thread or when the thread is suspended.
// No memory barrier needed, here. Only writer must write sp last (for use by profiler).
intptr_t* sp = last_Java_sp();
address pc = _anchor.last_Java_pc();

// Last_Java_pc ist not set, if we come here from compiled code.
Expand All @@ -49,9 +51,12 @@ bool JavaThread::pd_get_top_frame_for_profiling(frame* fr_addr, void* ucontext,
// If we have a last_Java_frame, then we should use it even if
// isInJava == true. It should be more reliable than ucontext info.
if (has_last_Java_frame() && frame_anchor()->walkable()) {
frame last_frame = pd_last_frame();
if (last_frame.pc() == nullptr) return false;
*fr_addr = last_frame;
intptr_t* sp = last_Java_sp();
address pc = _anchor.last_Java_pc();
// pc can be seen as null because not all writers use store pc + release store sp.
// Simply discard the sample in this very rare case.
if (pc == nullptr) return false;
*fr_addr = frame(sp, pc);
return true;
}

Expand Down

1 comment on commit 3486bb2

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.