Commit 4dab3a31 authored by Igor Sheludko's avatar Igor Sheludko Committed by V8 LUCI CQ

[heap] Add instrumentation to GcSafeFindCodeForInnerPointer

... in order to ease issues debugging.

Bug: chromium:1241665
Change-Id: I3b51d3eaaa9c03cfadbdadc4e91dee35617f4b33
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3293090
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarOmer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77999}
parent c201bb09
...@@ -608,7 +608,17 @@ Handle<String> Isolate::StackTraceString() { ...@@ -608,7 +608,17 @@ Handle<String> Isolate::StackTraceString() {
void Isolate::PushStackTraceAndDie(void* ptr1, void* ptr2, void* ptr3, void Isolate::PushStackTraceAndDie(void* ptr1, void* ptr2, void* ptr3,
void* ptr4) { void* ptr4) {
StackTraceFailureMessage message(this, ptr1, ptr2, ptr3, ptr4); StackTraceFailureMessage message(this,
StackTraceFailureMessage::kIncludeStackTrace,
ptr1, ptr2, ptr3, ptr4);
message.Print();
base::OS::Abort();
}
void Isolate::PushParamsAndDie(void* ptr1, void* ptr2, void* ptr3, void* ptr4) {
StackTraceFailureMessage message(
this, StackTraceFailureMessage::kDontIncludeStackTrace, ptr1, ptr2, ptr3,
ptr4);
message.Print(); message.Print();
base::OS::Abort(); base::OS::Abort();
} }
...@@ -617,14 +627,14 @@ void StackTraceFailureMessage::Print() volatile { ...@@ -617,14 +627,14 @@ void StackTraceFailureMessage::Print() volatile {
// Print the details of this failure message object, including its own address // Print the details of this failure message object, including its own address
// to force stack allocation. // to force stack allocation.
base::OS::PrintError( base::OS::PrintError(
"Stacktrace:\n ptr1=%p\n ptr2=%p\n ptr3=%p\n ptr4=%p\n " "Stacktrace:\n ptr1=%p\n ptr2=%p\n ptr3=%p\n ptr4=%p\n "
"failure_message_object=%p\n%s", "failure_message_object=%p\n%s",
ptr1_, ptr2_, ptr3_, ptr4_, this, &js_stack_trace_[0]); ptr1_, ptr2_, ptr3_, ptr4_, this, &js_stack_trace_[0]);
} }
StackTraceFailureMessage::StackTraceFailureMessage(Isolate* isolate, void* ptr1, StackTraceFailureMessage::StackTraceFailureMessage(
void* ptr2, void* ptr3, Isolate* isolate, StackTraceFailureMessage::StackTraceMode mode, void* ptr1,
void* ptr4) { void* ptr2, void* ptr3, void* ptr4) {
isolate_ = isolate; isolate_ = isolate;
ptr1_ = ptr1; ptr1_ = ptr1;
ptr2_ = ptr2; ptr2_ = ptr2;
...@@ -633,17 +643,20 @@ StackTraceFailureMessage::StackTraceFailureMessage(Isolate* isolate, void* ptr1, ...@@ -633,17 +643,20 @@ StackTraceFailureMessage::StackTraceFailureMessage(Isolate* isolate, void* ptr1,
// Write a stracktrace into the {js_stack_trace_} buffer. // Write a stracktrace into the {js_stack_trace_} buffer.
const size_t buffer_length = arraysize(js_stack_trace_); const size_t buffer_length = arraysize(js_stack_trace_);
memset(&js_stack_trace_, 0, buffer_length); memset(&js_stack_trace_, 0, buffer_length);
FixedStringAllocator fixed(&js_stack_trace_[0], buffer_length - 1); memset(&code_objects_, 0, sizeof(code_objects_));
StringStream accumulator(&fixed, StringStream::kPrintObjectConcise); if (mode == kIncludeStackTrace) {
isolate->PrintStack(&accumulator, Isolate::kPrintStackVerbose); FixedStringAllocator fixed(&js_stack_trace_[0], buffer_length - 1);
// Keeping a reference to the last code objects to increase likelyhood that StringStream accumulator(&fixed, StringStream::kPrintObjectConcise);
// they get included in the minidump. isolate->PrintStack(&accumulator, Isolate::kPrintStackVerbose);
const size_t code_objects_length = arraysize(code_objects_); // Keeping a reference to the last code objects to increase likelyhood that
size_t i = 0; // they get included in the minidump.
StackFrameIterator it(isolate); const size_t code_objects_length = arraysize(code_objects_);
for (; !it.done() && i < code_objects_length; it.Advance()) { size_t i = 0;
code_objects_[i++] = StackFrameIterator it(isolate);
reinterpret_cast<void*>(it.frame()->unchecked_code().ptr()); for (; !it.done() && i < code_objects_length; it.Advance()) {
code_objects_[i++] =
reinterpret_cast<void*>(it.frame()->unchecked_code().ptr());
}
} }
} }
......
...@@ -872,6 +872,9 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory { ...@@ -872,6 +872,9 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
void* ptr2 = nullptr, void* ptr2 = nullptr,
void* ptr3 = nullptr, void* ptr3 = nullptr,
void* ptr4 = nullptr); void* ptr4 = nullptr);
// Similar to the above but without collecting the stack trace.
V8_NOINLINE void PushParamsAndDie(void* ptr1 = nullptr, void* ptr2 = nullptr,
void* ptr3 = nullptr, void* ptr4 = nullptr);
Handle<FixedArray> CaptureCurrentStackTrace( Handle<FixedArray> CaptureCurrentStackTrace(
int frame_limit, StackTrace::StackTraceOptions options); int frame_limit, StackTrace::StackTraceOptions options);
Handle<Object> CaptureSimpleStackTrace(Handle<JSReceiver> error_object, Handle<Object> CaptureSimpleStackTrace(Handle<JSReceiver> error_object,
...@@ -2455,9 +2458,11 @@ class StackLimitCheck { ...@@ -2455,9 +2458,11 @@ class StackLimitCheck {
class StackTraceFailureMessage { class StackTraceFailureMessage {
public: public:
explicit StackTraceFailureMessage(Isolate* isolate, void* ptr1 = nullptr, enum StackTraceMode { kIncludeStackTrace, kDontIncludeStackTrace };
void* ptr2 = nullptr, void* ptr3 = nullptr,
void* ptr4 = nullptr); explicit StackTraceFailureMessage(Isolate* isolate, StackTraceMode mode,
void* ptr1 = nullptr, void* ptr2 = nullptr,
void* ptr3 = nullptr, void* ptr4 = nullptr);
V8_NOINLINE void Print() volatile; V8_NOINLINE void Print() volatile;
......
...@@ -7091,6 +7091,13 @@ Code Heap::GcSafeFindCodeForInnerPointer(Address inner_pointer) { ...@@ -7091,6 +7091,13 @@ Code Heap::GcSafeFindCodeForInnerPointer(Address inner_pointer) {
return code; return code;
} }
} }
// TODO(1241665): Remove once the issue is solved.
isolate()->PushParamsAndDie(
reinterpret_cast<void*>(inner_pointer),
const_cast<uint8_t*>(isolate()->embedded_blob_code()),
const_cast<uint8_t*>(Isolate::CurrentEmbeddedBlobCode()),
reinterpret_cast<void*>(Isolate::CurrentEmbeddedBlobCodeSize()));
UNREACHABLE(); UNREACHABLE();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment