Skip to content

Commit

Permalink
8313796: AsyncGetCallTrace crash on unreadable interpreter method poi…
Browse files Browse the repository at this point in the history
…nter

Reviewed-by: phh
Backport-of: 0e2c72d7a5206b7173af5bf69e21d21ea276bd94
  • Loading branch information
Ben Taylor authored and Paul Hohensee committed Aug 18, 2023
1 parent ee128b2 commit 3c9dc44
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/cpu/aarch64/frame_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ bool frame::is_interpreted_frame_valid(JavaThread* thread) const {

// first the method

Method* m = *interpreter_frame_method_addr();
Method* m = safe_interpreter_frame_method();

// validate the method we'd find in this potential sender
if (!Method::is_valid_method(m)) return false;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/arm/frame_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ bool frame::is_interpreted_frame_valid(JavaThread* thread) const {

// first the method

Method* m = *interpreter_frame_method_addr();
Method* m = safe_interpreter_frame_method();

// validate the method we'd find in this potential sender
if (!Method::is_valid_method(m)) return false;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/ppc/frame_ppc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ bool frame::is_interpreted_frame_valid(JavaThread* thread) const {

// first the method

Method* m = *interpreter_frame_method_addr();
Method* m = safe_interpreter_frame_method();

// validate the method we'd find in this potential sender
if (!Method::is_valid_method(m)) return false;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/x86/frame_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ bool frame::is_interpreted_frame_valid(JavaThread* thread) const {
// do some validation of frame elements
// first the method

Method* m = *interpreter_frame_method_addr();
Method* m = safe_interpreter_frame_method();

// validate the method we'd find in this potential sender
if (!Method::is_valid_method(m)) return false;
Expand Down
9 changes: 9 additions & 0 deletions src/hotspot/share/runtime/frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "runtime/monitorChunk.hpp"
#include "runtime/os.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/safefetch.inline.hpp"
#include "runtime/signature.hpp"
#include "runtime/stubCodeGenerator.hpp"
#include "runtime/stubRoutines.hpp"
Expand Down Expand Up @@ -240,6 +241,14 @@ bool frame::is_entry_frame_valid(JavaThread* thread) const {
return (jfa->last_Java_sp() > sp());
}

Method* frame::safe_interpreter_frame_method() const {
Method** m_addr = interpreter_frame_method_addr();
if (m_addr == NULL) {
return NULL;
}
return (Method*) SafeFetchN((intptr_t*) m_addr, 0);
}

bool frame::should_be_deoptimized() const {
if (_deopt_state == is_deoptimized ||
!is_compiled_frame() ) return false;
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/runtime/frame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ class frame {

bool is_entry_frame_valid(JavaThread* thread) const;

Method* safe_interpreter_frame_method() const;

// All frames:

// A low-level interface for vframes:
Expand Down

1 comment on commit 3c9dc44

@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.