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

Backport-of: 0e2c72d7a5206b7173af5bf69e21d21ea276bd94
  • Loading branch information
Ben Taylor authored and Paul Hohensee committed Aug 25, 2023
1 parent b96aa3c commit 46ce555
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 5 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 @@ -508,7 +508,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 @@ -421,7 +421,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 @@ -324,7 +324,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/riscv/frame_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,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
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 @@ -496,7 +496,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 @@ -52,6 +52,7 @@
#include "runtime/monitorChunk.hpp"
#include "runtime/os.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/safefetch.hpp"
#include "runtime/signature.hpp"
#include "runtime/stackValue.hpp"
#include "runtime/stubCodeGenerator.hpp"
Expand Down Expand Up @@ -301,6 +302,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 == nullptr) {
return nullptr;
}
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 @@ -236,6 +236,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 46ce555

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