Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.35',
'v8_embedder_string': '-node.36',

##### V8 defaults for Node.js #####

Expand Down
1 change: 1 addition & 0 deletions deps/v8/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ Douglas Crosher <dtc-v8@scieneer.com>
Dusan Milosavljevic <dusan.m.milosavljevic@gmail.com>
Eden Wang <nedenwang@tencent.com>
Edoardo Marangoni <edoardo@wasmer.io>
Eliau Elkouby <eliau.elkouby@gmail.com>
Elisha Hollander <just4now666666@gmail.com>
Eric Rannaud <eric.rannaud@gmail.com>
Erich Ocean <erich.ocean@me.com>
Expand Down
11 changes: 7 additions & 4 deletions deps/v8/src/execution/isolate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1645,12 +1645,15 @@ MaybeDirectHandle<JSObject> Isolate::CaptureAndSetErrorStack(
static_cast<uint32_t>(
stack_trace_for_uncaught_exceptions_frame_limit_));
DCHECK_GE(stack_trace_limit, 0);
if (static_cast<int>(stack_trace_limit) *
CallSiteInfo::Fields::kCount <
raw_data_for_call_site_infos->length()) {
// Compare in frames rather than raw slots to avoid overflowing for
// large Error.stackTraceLimit values.
uint32_t frame_count = raw_data_for_call_site_infos->ulength() /
CallSiteInfo::Fields::kCount;
if (static_cast<uint32_t>(stack_trace_limit) < frame_count) {
call_site_infos_or_formatted_stack = FixedArray::RightTrimOrEmpty(
this, raw_data_for_call_site_infos,
stack_trace_limit * CallSiteInfo::Fields::kCount);
static_cast<uint32_t>(stack_trace_limit) *
CallSiteInfo::Fields::kCount);
}
// Notify the debugger.
OnStackTraceCaptured(stack_trace);
Expand Down
28 changes: 28 additions & 0 deletions deps/v8/test/cctest/test-api-stack-traces.cc
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,34 @@ TEST(CaptureStackTraceForUncaughtException) {
CHECK_EQ(1, report_count);
}

TEST(CaptureStackTraceForUncaughtExceptionHugeStackTraceLimit) {
LocalContext env;
v8::Isolate* isolate = env.isolate();
v8::HandleScope scope(isolate);
isolate->SetCaptureStackTraceForUncaughtExceptions(true);

CompileRun(
"function foo() { return new Error().stack; }\n"
"function bar() { return foo(); }\n"
"function stackWithLimit(limit) {\n"
" Error.stackTraceLimit = limit;\n"
" return bar();\n"
"}\n");
Local<Value> expected = CompileRun("stackWithLimit(10)");
CHECK(expected->IsString());

// For these limits, limit * CallSiteInfo::Fields::kCount overflows.
for (const char* limit : {"858993460", "858993461", "Infinity"}) {
std::string source = std::string("stackWithLimit(") + limit + ")";
CHECK(CompileRun(source.c_str())->StrictEquals(expected));
}

// Small limits must still trim the stack trace.
CHECK(CompileRun("stackWithLimit(1).split('\\n').length === 2")->IsTrue());

isolate->SetCaptureStackTraceForUncaughtExceptions(false);
}

// Test uncaught exception in a setter
const char uncaught_setter_exception_source[] =
"var setters = ['column', 'lineNumber', 'scriptName',\n"
Expand Down
Loading