Skip to content

v8: Node 26.9.0 crashes with Check failed: new_capacity > 0. when Error.stackTraceLimit is set above 357913941 with --trace-uncaught #66074

Description

@silverwind

Version

v26.9.0

Platform

Darwin 25.6.0 Darwin Kernel Version 25.6.0: Fri Jul 31 19:18:53 PDT 2026; root:xnu-12377.161.14~5/RELEASE_ARM64_T6031 arm64 arm Darwin

Subsystem

v8

What steps will reproduce the bug?

node --trace-uncaught -e 'Error.stackTraceLimit=Infinity; Error()'

How often does it reproduce? Is there a required condition?

Every time

What is the expected behavior? Why is that the expected behavior?

No crash

What do you see instead?

#
# Fatal error in , line 0
# Check failed: new_capacity > 0.
#
#
#
#FailureMessage Object: 0x16b45a7a8
----- Native stack trace -----

 1: 0x104b48804 node::NodePlatform::GetStackTracePrinter()::$_0::__invoke() [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
 2: 0x1066bf2bc V8_Fatal(char const*, ...) [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
 3: 0x1070c9f84 v8::internal::Handle<v8::internal::FixedArray> v8::internal::FixedArray::RightTrimOrEmpty<v8::internal::Handle>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::FixedArray>, unsigned int) (.cold.2) [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
 4: 0x1051d4884 v8::internal::Handle<v8::internal::FixedArray> v8::internal::FixedArray::RightTrimOrEmpty<v8::internal::Handle>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::FixedArray>, unsigned int) [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
 5: 0x104ea831c v8::internal::Isolate::CaptureAndSetErrorStack(v8::internal::DirectHandle<v8::internal::JSObject>, v8::internal::FrameSkipMode, v8::internal::Handle<v8::internal::Object>) [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
 6: 0x104ec5510 v8::internal::ErrorUtils::Construct(v8::internal::Isolate*, v8::internal::DirectHandle<v8::internal::JSFunction>, v8::internal::DirectHandle<v8::internal::Object>, v8::internal::DirectHandle<v8::internal::Object>, v8::internal::DirectHandle<v8::internal::Object>, v8::internal::FrameSkipMode, v8::internal::DirectHandle<v8::internal::Object>, v8::internal::ErrorUtils::StackTraceCollection) [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
 7: 0x104d7d074 v8::internal::Builtin_ErrorConstructor(int, unsigned long*, v8::internal::Isolate*) [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
 8: 0x105a8cbec Builtins_CEntry_Return1_ArgvOnStack_BuiltinExit [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
 9: 0x1059e9424 Builtins_InterpreterEntryTrampoline [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
10: 0x1059e6788 Builtins_JSEntryTrampoline [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
11: 0x1059e6478 Builtins_JSEntry [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
12: 0x104e97970 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
13: 0x104e97e54 v8::internal::Execution::CallScript(v8::internal::Isolate*, v8::internal::DirectHandle<v8::internal::JSFunction>, v8::internal::DirectHandle<v8::internal::Object>, v8::internal::DirectHandle<v8::internal::Object>) [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
14: 0x104d1bb78 v8::Script::Run(v8::Local<v8::Context>, v8::Local<v8::Data>) [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
15: 0x104aa57b0 node::contextify::ContextifyScript::EvalMachine(v8::Local<v8::Context>, node::Environment*, long long, bool, bool, bool, v8::MicrotaskQueue*, v8::FunctionCallbackInfo<v8::Value> const&) [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
16: 0x106fb1230 node::contextify::ContextifyScript::RunInContext(v8::FunctionCallbackInfo<v8::Value> const&) [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
17: 0x1059eb20c Builtins_CallApiCallbackGeneric [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
18: 0x1059e9424 Builtins_InterpreterEntryTrampoline [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
19: 0x1059e9424 Builtins_InterpreterEntryTrampoline [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
20: 0x1059e9424 Builtins_InterpreterEntryTrampoline [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
21: 0x1059e9424 Builtins_InterpreterEntryTrampoline [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
22: 0x1059e9424 Builtins_InterpreterEntryTrampoline [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
23: 0x1059e9424 Builtins_InterpreterEntryTrampoline [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
24: 0x1059e9424 Builtins_InterpreterEntryTrampoline [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
25: 0x1059e6788 Builtins_JSEntryTrampoline [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
26: 0x1059e6478 Builtins_JSEntry [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
27: 0x104e97970 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
28: 0x104e97344 v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::DirectHandle<v8::internal::Object>, v8::internal::DirectHandle<v8::internal::Object>, v8::base::Vector<v8::internal::DirectHandle<v8::internal::Object> const>) [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
29: 0x104d27794 v8::Function::Call(v8::Isolate*, v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
30: 0x104a8e334 node::builtins::BuiltinLoader::CompileAndCall(v8::Local<v8::Context>, char const*, node::Realm*) [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
31: 0x106fe6db8 node::Realm::ExecuteBootstrapper(char const*) [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
32: 0x106f9ee04 node::StartExecution(node::Environment*, char const*) (.cold.1) [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
33: 0x104a6edc0 node::StartExecution(node::Environment*, char const*) [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
34: 0x104a6ed38 node::StartExecution(node::Environment*, std::__1::function<v8::MaybeLocal<v8::Value> (node::StartExecutionCallbackInfoWithModule const&)>) [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
35: 0x1049b59d0 node::LoadEnvironment(node::Environment*, std::__1::function<v8::MaybeLocal<v8::Value> (node::StartExecutionCallbackInfoWithModule const&)>, std::__1::function<void (node::Environment*, v8::Local<v8::Value>, v8::Local<v8::Value>)>) [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
36: 0x106fdb5b8 node::NodeMainInstance::Run() (.cold.1) [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
37: 0x104b03a5c node::NodeMainInstance::Run() [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
38: 0x104a732b4 node::Start(int, char**) [/Users/silverwind/.local/share/nodejs/v26.9.0/bin/node]
39: 0x18f5a04e4 start [/usr/lib/dyld]
[1]    45370 trace trap  node -e 'Error.stackTraceLimit=Infinity; Error()'

Additional information

Any stack trace limit above 357913941 (2^32 / 12) triggers the crash. v26.8.2 does not crash. Requires --trace-uncaught to crash.

Likely culprit is #65764
Popular module triggering the crash: https://github.com/wooorm/import-meta-resolve/blob/4.2.0/lib/errors.js#L427-L436

Activity

changed the title [-]Node 26.9.0 crashes with `Check failed: new_capacity > 0.` when `Error.stackTraceLimit` is set above 357913941[/-] [+]v8: Node 26.9.0 crashes with `Check failed: new_capacity > 0.` when `Error.stackTraceLimit` is set above 357913941[/+] on Sep 16, 2026

inoway46 commented on Sep 17, 2026

@inoway46
Contributor

Reproduced on v26.9.0 and local main at 99f0dde (macOS x64) with --trace-uncaught.

@silverwind Could you add that flag to the repro command? It doesn't crash without it in my environment.

added
confirmed-bugIssues and PRs for confirmed bugs.
v8 engineIssues and PRs related to the V8 dependency.
on Sep 17, 2026

silverwind commented on Sep 17, 2026

@silverwind
ContributorAuthor

You are right, this requires the flag to crash which I had set in NODE_OPTIONS, updated. Minimal reproduction is now this and I reproduced this on Linux too.

node --trace-uncaught -e 'Error.stackTraceLimit=Infinity; Error()'
changed the title [-]v8: Node 26.9.0 crashes with `Check failed: new_capacity > 0.` when `Error.stackTraceLimit` is set above 357913941[/-] [+]v8: Node 26.9.0 crashes with `Check failed: new_capacity > 0.` when `Error.stackTraceLimit` is set above 357913941 with `--trace-uncaught`[/+] on Sep 17, 2026

eliau2005 commented on Sep 18, 2026

@eliau2005
Contributor

@inoway46 I’d like to work on fixing this. Before I start, should the fix be made directly in nodejs/node under deps/v8, or should this be addressed upstream in v8/v8 first and then backported to Node.js?

I’d also be happy to add a regression test covering the Error.stackTraceLimit overflow case.

richardlau commented on Sep 18, 2026

@richardlau
Member

eliau2005 commented on Sep 18, 2026

@eliau2005
Contributor

I'm working on an upstream fix in V8 for the underlying stack trace limit overflow.

Following @richardlau guidance, I'll work on getting the fix into V8 first, and then it can be backported to Node.js if appropriate.

I'll update this issue once there's progress on the V8 side.

eliau2005 commented on Sep 19, 2026

@eliau2005
Contributor

The upstream V8 fix is now uploaded for review:

https://chromium-review.googlesource.com/c/v8/v8/+/8426465

It fixes the overflow by comparing Error.stackTraceLimit in frames before converting it to raw CallSiteInfo slots, and adds a regression test covering the large-limit cases and Infinity.

The CL has passed upload presubmit and is currently awaiting V8 review. Once it lands upstream, the fix can be considered for backport to Node.js.

17630966776 commented on Sep 20, 2026

@17630966776

Confirmed on Windows 11 x64 (10.0.26100). This also affects an attached Inspector session, without --trace-uncaught.

Version comparison

Reproduction v26.8.1 v26.9.0
Error.stackTraceLimit = Infinity; new Error() without debugging Exit 0 Exit 0
Same expression with --trace-uncaught Exit 0 Exit 2147483651
Same expression with an external Inspector client attached as below Exit 0 Exit 2147483651

The failing cases print:

# Fatal error in , line 0
# Check failed: new_capacity > 0.

The Windows exit code is 0x80000003.

Inspector reproduction, no third-party dependencies

Start the target:

node --inspect-brk=127.0.0.1:0 -e 'Error.stackTraceLimit=Infinity;new Error();console.log("OK")'

Connect an external Chrome DevTools Protocol client to the WebSocket URL printed on stderr. Send these commands in order, waiting for each response:

{"id":1,"method":"Runtime.enable"}
{"id":2,"method":"Debugger.enable"}
{"id":3,"method":"Runtime.runIfWaitingForDebugger"}

When Debugger.paused is received, send:

{"id":4,"method":"Debugger.resume"}

On v26.9.0 the target crashes with the assertion above. On v26.8.1 it prints OK; disconnect the client to let the target exit. Both NODE_OPTIONS and VSCODE_INSPECTOR_OPTIONS were removed from the target environment for these comparisons.

This was initially encountered while debugging an electron-vite application in VS Code. Importing unplugin-vue-components/vite (32.0.0) under an attached debugger also reproduced it outside VS Code. Reducing the reproduction to the expression above removes Electron, VS Code, and all npm dependencies from the required setup.

The external Inspector detail matters: a same-thread node:inspector Session with only Debugger.enable did not reproduce the crash in a separate test.

eliau2005 commented on Sep 23, 2026

@eliau2005
Contributor

V8 asked for a tracking bug before review, so I've filed one:

https://issues.chromium.org/issues/565047704

The CL (8426465) now carries the Bug: line and links back to this issue.

Root cause, for the record: Error.stackTraceLimit counts frames, but since crrev.com/c/7673818 the raw call site data stores CallSiteInfo::Fields::kCount slots per frame. CaptureAndSetErrorStack multiplies the limit by kCount before comparing it against the array length, and that product overflows for large limits. Node's V8 14.6 backport has kCount == 6 with signed arithmetic, so INT_MAX * 6 wraps negative and trips Check failed: new_capacity > 0.. On current V8 main the same expression wraps in uint32_t instead, which silently drops frames from error.stack rather than crashing. The fix compares against the frame count (length / kCount) so the multiplication only happens once it is known to be bounded.

@17630966776 — your Inspector finding is consistent with this and isn't a separate bug. The trim path runs whenever capture-for-uncaught-exceptions is enabled, and an attached Inspector session turns that on just as --trace-uncaught does.

The CL is awaiting V8 review. I'll update here once it lands and backport becomes relevant.

eliau2005 commented on Sep 23, 2026

@eliau2005
Contributor

The upstream V8 fix has landed:

It compares Error.stackTraceLimit in frames before converting it to raw CallSiteInfo slots, and adds a cctest regression test covering the large-limit values and Infinity.

One practical note: it landed on V8 main, which is currently at 15.6, while deps/v8 here is at 14.6.202.34. So this won't reach Node through the regular V8 update path for a long while, and the reported crash stays reproducible until then.

@richardlau — following your earlier pointer to maintaining-V8.md, would a floating patch onto deps/v8 be welcome here, or would you rather wait for the next V8 upgrade? I'm happy to open the PR via git node v8 backport 8426465 if that's the preferred route.

3 remaining items

added a commit that references this issue on Sep 28, 2026
added a commit that references this issue on Sep 28, 2026
added a commit that references this issue on Oct 4, 2026
added a commit that references this issue on Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.v8 engineIssues and PRs related to the V8 dependency.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions