[heap] Add instrumentation to GcSafeFindCodeForInnerPointer, pt.2

... in order to ease issues debugging.

Bug: chromium:1241665
Change-Id: I7731a37e642acd0aef02570fb70faf0bc65495ff
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3353367
Reviewed-by: Hannes Payer <hpayer@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78430}
This commit is contained in:
Igor Sheludko 2021-12-22 11:38:29 +01:00 committed by V8 LUCI CQ
parent 6072179d98
commit 6c30d63ab9
3 changed files with 24 additions and 8 deletions

View File

@ -642,10 +642,11 @@ void Isolate::PushStackTraceAndDie(void* ptr1, void* ptr2, void* ptr3,
base::OS::Abort();
}
void Isolate::PushParamsAndDie(void* ptr1, void* ptr2, void* ptr3, void* ptr4) {
void Isolate::PushParamsAndDie(void* ptr1, void* ptr2, void* ptr3, void* ptr4,
void* ptr5, void* ptr6) {
StackTraceFailureMessage message(
this, StackTraceFailureMessage::kDontIncludeStackTrace, ptr1, ptr2, ptr3,
ptr4);
ptr4, ptr5, ptr6);
message.Print();
base::OS::Abort();
}
@ -655,18 +656,20 @@ void StackTraceFailureMessage::Print() volatile {
// to force stack allocation.
base::OS::PrintError(
"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]);
"ptr5=%p\n ptr6=%p\n failure_message_object=%p\n%s",
ptr1_, ptr2_, ptr3_, ptr4_, ptr5_, ptr6_, this, &js_stack_trace_[0]);
}
StackTraceFailureMessage::StackTraceFailureMessage(
Isolate* isolate, StackTraceFailureMessage::StackTraceMode mode, void* ptr1,
void* ptr2, void* ptr3, void* ptr4) {
void* ptr2, void* ptr3, void* ptr4, void* ptr5, void* ptr6) {
isolate_ = isolate;
ptr1_ = ptr1;
ptr2_ = ptr2;
ptr3_ = ptr3;
ptr4_ = ptr4;
ptr5_ = ptr5;
ptr6_ = ptr6;
// 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);

View File

@ -895,7 +895,8 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
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);
void* ptr3 = nullptr, void* ptr4 = nullptr,
void* ptr5 = nullptr, void* ptr6 = nullptr);
Handle<FixedArray> CaptureDetailedStackTrace(
int limit, StackTrace::StackTraceOptions options);
Handle<FixedArray> CaptureSimpleStackTrace(int limit, FrameSkipMode mode,
@ -2503,7 +2504,8 @@ class StackTraceFailureMessage {
explicit StackTraceFailureMessage(Isolate* isolate, StackTraceMode mode,
void* ptr1 = nullptr, void* ptr2 = nullptr,
void* ptr3 = nullptr, void* ptr4 = nullptr);
void* ptr3 = nullptr, void* ptr4 = nullptr,
void* ptr5 = nullptr, void* ptr6 = nullptr);
V8_NOINLINE void Print() volatile;
@ -2517,6 +2519,8 @@ class StackTraceFailureMessage {
void* ptr2_;
void* ptr3_;
void* ptr4_;
void* ptr5_;
void* ptr6_;
void* code_objects_[4];
char js_stack_trace_[kStacktraceBufferSize];
uintptr_t end_marker_ = kEndMarker;

View File

@ -7178,11 +7178,20 @@ Code Heap::GcSafeFindCodeForInnerPointer(Address inner_pointer) {
}
}
// TODO(1241665): Remove once the issue is solved.
std::shared_ptr<CodeRange> code_range = CodeRange::GetProcessWideCodeRange();
void* code_range_embedded_blob_code_copy =
code_range ? code_range->embedded_blob_code_copy() : nullptr;
Address flags = (isolate()->is_short_builtin_calls_enabled() ? 1 : 0) |
(code_range ? 2 : 0) |
static_cast<Address>(max_old_generation_size());
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()));
code_range_embedded_blob_code_copy,
reinterpret_cast<void*>(Isolate::CurrentEmbeddedBlobCodeSize()),
reinterpret_cast<void*>(flags));
UNREACHABLE();
}