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() {
void Isolate::PushStackTraceAndDie(void* ptr1, void* ptr2, void* ptr3,
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();
base::OS::Abort();
}
......@@ -617,14 +627,14 @@ void StackTraceFailureMessage::Print() volatile {
// Print the details of this failure message object, including its own address
// to force stack allocation.
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",
ptr1_, ptr2_, ptr3_, ptr4_, this, &js_stack_trace_[0]);
}
StackTraceFailureMessage::StackTraceFailureMessage(Isolate* isolate, void* ptr1,
void* ptr2, void* ptr3,
void* ptr4) {
StackTraceFailureMessage::StackTraceFailureMessage(
Isolate* isolate, StackTraceFailureMessage::StackTraceMode mode, void* ptr1,
void* ptr2, void* ptr3, void* ptr4) {
isolate_ = isolate;
ptr1_ = ptr1;
ptr2_ = ptr2;
......@@ -633,17 +643,20 @@ StackTraceFailureMessage::StackTraceFailureMessage(Isolate* isolate, void* ptr1,
// Write a stracktrace into the {js_stack_trace_} buffer.
const size_t buffer_length = arraysize(js_stack_trace_);
memset(&js_stack_trace_, 0, buffer_length);
FixedStringAllocator fixed(&js_stack_trace_[0], buffer_length - 1);
StringStream accumulator(&fixed, StringStream::kPrintObjectConcise);
isolate->PrintStack(&accumulator, Isolate::kPrintStackVerbose);
// Keeping a reference to the last code objects to increase likelyhood that
// they get included in the minidump.
const size_t code_objects_length = arraysize(code_objects_);
size_t i = 0;
StackFrameIterator it(isolate);
for (; !it.done() && i < code_objects_length; it.Advance()) {
code_objects_[i++] =
reinterpret_cast<void*>(it.frame()->unchecked_code().ptr());
memset(&code_objects_, 0, sizeof(code_objects_));
if (mode == kIncludeStackTrace) {
FixedStringAllocator fixed(&js_stack_trace_[0], buffer_length - 1);
StringStream accumulator(&fixed, StringStream::kPrintObjectConcise);
isolate->PrintStack(&accumulator, Isolate::kPrintStackVerbose);
// Keeping a reference to the last code objects to increase likelyhood that
// they get included in the minidump.
const size_t code_objects_length = arraysize(code_objects_);
size_t i = 0;
StackFrameIterator it(isolate);
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 {
void* ptr2 = nullptr,
void* ptr3 = 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(
int frame_limit, StackTrace::StackTraceOptions options);
Handle<Object> CaptureSimpleStackTrace(Handle<JSReceiver> error_object,
......@@ -2455,9 +2458,11 @@ class StackLimitCheck {
class StackTraceFailureMessage {
public:
explicit StackTraceFailureMessage(Isolate* isolate, void* ptr1 = nullptr,
void* ptr2 = nullptr, void* ptr3 = nullptr,
void* ptr4 = nullptr);
enum StackTraceMode { kIncludeStackTrace, kDontIncludeStackTrace };
explicit StackTraceFailureMessage(Isolate* isolate, StackTraceMode mode,
void* ptr1 = nullptr, void* ptr2 = nullptr,
void* ptr3 = nullptr, void* ptr4 = nullptr);
V8_NOINLINE void Print() volatile;
......
......@@ -7091,6 +7091,13 @@ Code Heap::GcSafeFindCodeForInnerPointer(Address inner_pointer) {
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();
}
......
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