-
Notifications
You must be signed in to change notification settings - Fork 5k
Fix crashes when inspecting objects whose property enumeration throws #37175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
493876b
79b42b1
37d37cd
bd8a5ac
af229dc
bdd7a2e
6db3197
8e1c770
d2806ce
d4446c7
54367dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2077,14 +2077,21 @@ | |
| if (key_mode == napi_key_include_prototypes) { | ||
| // Climb up the prototype chain to find inherited properties | ||
| while (!owner->getOwnPropertyDescriptor(globalObject, propKey, desc)) { | ||
| JSObject* proto = owner->getPrototype(globalObject).getObject(); | ||
| // A throwing "getOwnPropertyDescriptor" proxy trap must stop the walk | ||
| // before getPrototype runs more JS with the exception pending. | ||
| NAPI_RETURN_IF_EXCEPTION(env); | ||
| JSValue protoValue = owner->getPrototype(globalObject); | ||
| // A throwing proxy trap leaves protoValue empty; getObject() on it is a null deref. | ||
| NAPI_RETURN_IF_EXCEPTION(env); | ||
|
Check warning on line 2085 in src/jsc/bindings/napi.cpp
|
||
|
claude[bot] marked this conversation as resolved.
Comment on lines
+2083
to
+2085
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 The sibling sweep of Extended reasoning...What the finding isThe PR's sibling sweep of throwing- result.set(env, object.get_prototype(env.to_js()));
env.ok()
Step-by-step proof
Node.js returns Why existing code doesn't prevent it
ImpactNo release crash (the empty JSValue is stored, not dereferenced). The addon receives Why this belongs in scope, and why it's still a nitREVIEW.md, Correctness: the bug class, not the bug: "Fix the whole class in the same PR (same-class sites are ONE concern, not scope creep). Grep for every sibling site sharing the pattern… If a site is intentionally excluded, say so in the PR." This is a direct sibling of the napi.cpp site the PR fixes and adds a test for, in the same N-API surface ( How to fixEither: result.set(env, object.get_prototype(env.to_js()));
if env.has_pending_exception() {
return env.pending_exception();
}
env.ok()…or note in the PR body that Rust-side |
||
| JSObject* proto = protoValue.getObject(); | ||
|
coderabbitai[bot] marked this conversation as resolved.
claude[bot] marked this conversation as resolved.
|
||
| if (!proto) { | ||
| break; | ||
| } | ||
| owner = proto; | ||
| } | ||
| } else { | ||
| owner->getOwnPropertyDescriptor(globalObject, propKey, desc); | ||
| NAPI_RETURN_IF_EXCEPTION(env); | ||
| } | ||
|
|
||
| // V8 never applies ONLY_WRITABLE/ONLY_CONFIGURABLE to Proxy keys | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the report gone this returns to the static lookup with the exception pending, and the sql tree has the shape fix 4 removes for the shell: internal/sql/shared.ts reads Bun.env at module scope before errors.ts evaluates, so if the tree throws (
globalThis.Error = -6; Bun.sql) the Bun object has transitioned under the lookup and debug builds hit the storedPrototype assertion. Still asserts on main via the frame this deletes; once it is gone the outer lookup takes the same path. Changing that read to process.env plus a spawned test closes it on every OS; otherwise say in the body that it is left.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in b70bae7: shared.ts reads process.env now, which was the only module-scope Bun property read in the sql tree, plus a spawned test in test/js/sql/adapter-env-var-precedence.test.ts that aborts the debug build without the shared.ts change.