-
-
Notifications
You must be signed in to change notification settings - Fork 161
fix(hir): per-evaluation statics for class expressions with heritage (#6438) #6449
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
Merged
proggeramlug
merged 5 commits into
main
from
fix/6438-class-expr-heritage-per-evaluation-statics
Jul 16, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2f76fb6
fix(hir): per-evaluation statics for class expressions with heritage …
97735ce
fix(runtime): inherited statics on a per-evaluation class object must…
ec5f479
Merge remote-tracking branch 'origin/main' into HEAD
b521df4
fix(runtime): reject the handle band in class_object_own_field_bytes;…
3187ef3
fix(runtime): bind `this` to the receiver for a method inherited by a…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // Per-evaluation statics for class expressions: two evaluations that extend | ||
| // DIFFERENT top-level classes must each read THEIR OWN parent's static, not the | ||
| // last-registered sibling's (the shared template's parent edge is last-wins). | ||
| class P1 { static v = "p1"; static who() { return "P1"; } } | ||
| class P2 { static v = "p2"; static who() { return "P2"; } } | ||
| function makeChild(p: any) { return class extends p {}; } | ||
| const C1 = makeChild(P1); | ||
| const C2 = makeChild(P2); | ||
| console.log("C1.v:", (C1 as any).v); // p1 (its own pinned parent) | ||
| console.log("C2.v:", (C2 as any).v); // p2 | ||
| console.log("C1.who:", (C1 as any).who()); // P1 (inherited static method) | ||
| console.log("C2.who:", (C2 as any).who()); // P2 | ||
| // A third evaluation extending P1 again must still be p1. | ||
| const C3 = makeChild(P1); | ||
| console.log("C3.v:", (C3 as any).v); // p1 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win
Stale pointers due to GC during method resolution and rebinding.
Both changed paths invoke
closure_get_dynamic_prop(which can run prototype getters) andclone_closure_rebind_this(which allocates closures). These operations can trigger garbage collection. Because the conservative stack scanner does not pin NaN-boxedf64values or theargs_ptrbuffer (their tags hide the raw heap addresses), the referents can be relocated, leaving the unrooted locals stale and leading to memory corruption.crates/perry-runtime/src/object/native_call_method.rs#L1348-L1378: useobject_handle.get_nanbox_f64()instead of the unrootedrecv_bits, andrefreshed_args().as_ptr()instead ofargs_ptr. Re-read the receiver handle both before and after the allocation.crates/perry-runtime/src/object/native_call_method.rs#L1077-L1088: useobject_handle.get_nanbox_f64()instead of the unrootedobject, andrefreshed_args().as_ptr()instead ofargs_ptr. Re-read the receiver handle both before and after the allocation.🐛 Proposed fixes
For lines 1348-1378:
// "Cannot convert undefined or null to object" out of // `Object.keys` — killing `HttpApi` construction at module init. + let current_recv = object_handle.get_nanbox_f64(); let bound = crate::closure::clone_closure_rebind_this( dyn_val.to_bits(), - f64::from_bits(recv_bits), + current_recv, ); - let prev_this = IMPLICIT_THIS.with(|c| c.replace(recv_bits)); + let current_recv_post = object_handle.get_nanbox_f64(); + let prev_this = IMPLICIT_THIS.with(|c| c.replace(current_recv_post.to_bits())); + let args = refreshed_args(); let result = - crate::closure::js_native_call_value(f64::from_bits(bound), args_ptr, args_len); + crate::closure::js_native_call_value(f64::from_bits(bound), args.as_ptr(), args.len());For lines 1077-1088:
// (an object-literal method binds the literal) would otherwise // win over IMPLICIT_THIS and leave `this` as the PROTO. + let current_obj = object_handle.get_nanbox_f64(); let bound = crate::closure::clone_closure_rebind_this( dyn_val.to_bits(), - f64::from_bits(object.to_bits()), + current_obj, ); - let prev_this = IMPLICIT_THIS.with(|c| c.replace(object.to_bits())); + let current_obj_post = object_handle.get_nanbox_f64(); + let prev_this = IMPLICIT_THIS.with(|c| c.replace(current_obj_post.to_bits())); + let args = refreshed_args(); let result = - crate::closure::js_native_call_value(f64::from_bits(bound), args_ptr, args_len); + crate::closure::js_native_call_value(f64::from_bits(bound), args.as_ptr(), args.len());📝 Committable suggestion
📍 Affects 1 file
crates/perry-runtime/src/object/native_call_method.rs#L1348-L1378(this comment)crates/perry-runtime/src/object/native_call_method.rs#L1077-L1088🤖 Prompt for AI Agents