-
-
Notifications
You must be signed in to change notification settings - Fork 158
fix(release): guard dynamic receiver probes by GC kind #8999
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
ae27001
2fd6452
d4ce655
4999b12
74f2d49
e8bde8d
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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| ### Fixed | ||
|
|
||
| - Dynamic indexed reads now inspect `ObjectMeta.elements` only for receivers whose GC kind is an object. Array, string, Error, and other layouts can no longer be interpreted as an object metadata pointer, eliminating the release parity crashes introduced with Array-subclass elements storage. | ||
| - Managed heap cells are classified as closures only when their authoritative GC kind is `GC_TYPE_CLOSURE`. Reused `Error` storage whose padding retained the closure magic marker no longer loses `.message` or custom fields during property lookup. | ||
| - Removed the stale Linux parity allowance for `test_class_field_layout`, which now matches Node, and recorded the timezone-provider dependency added to the runtime in `Cargo.lock`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -419,6 +419,24 @@ pub fn is_closure_ptr(ptr: usize) -> bool { | |
| if !ptr.is_multiple_of(std::mem::align_of::<ClosureHeader>()) { | ||
| return false; | ||
| } | ||
| // Arena ownership gives us an authoritative discriminator. Do not let a | ||
| // coincidental CLOSURE_MAGIC in another managed cell's payload win: in | ||
| // particular, ErrorHeader has padding at the closure tag offset and an | ||
| // arena slot reused after a closure can retain "CLOS" in those bytes. | ||
| // Headerless/external allocations remain on the exact-magic fallback. | ||
| if !matches!( | ||
| crate::arena::classify_heap_generation(ptr), | ||
| crate::arena::HeapGeneration::Unknown | ||
| ) { | ||
| let Some(header) = (unsafe { crate::value::addr_class::try_read_gc_header(ptr) }) else { | ||
| return false; | ||
| }; | ||
| if header.obj_type != crate::gc::GC_TYPE_CLOSURE | ||
| || header.gc_flags & crate::gc::GC_FLAG_FORWARDED != 0 | ||
| { | ||
| return false; | ||
| } | ||
| } | ||
| unsafe { | ||
| let type_tag = *((ptr as *const u8).add(CLOSURE_TYPE_TAG_OFFSET) as *const u32); | ||
| type_tag == CLOSURE_MAGIC | ||
|
|
@@ -1012,6 +1030,36 @@ mod tests_1802 { | |
| ); | ||
| } | ||
| } | ||
|
|
||
| /// A managed cell's GC kind must outrank bytes that merely look like a | ||
| /// closure tag. ErrorHeader's bytes 12..16 are padding on 64-bit targets; | ||
| /// reused arena storage can therefore retain CLOSURE_MAGIC there. | ||
| #[test] | ||
| fn managed_error_with_closure_magic_in_padding_is_not_a_closure() { | ||
| unsafe { | ||
| let message = crate::string::js_string_from_bytes(b"survives".as_ptr(), 8); | ||
| let error = crate::error::js_error_new_with_message(message); | ||
| // GC_STORE_AUDIT(POINTER_FREE): writes the u32 magic constant into | ||
| // an ErrorHeader's padding on purpose, so the assertion below proves | ||
| // the GC kind outranks look-alike bytes. No heap pointer is stored, | ||
| // so there is nothing for a barrier to track. | ||
| std::ptr::write_unaligned( | ||
| (error as *mut u8).add(CLOSURE_TYPE_TAG_OFFSET) as *mut u32, | ||
| CLOSURE_MAGIC, | ||
| ); | ||
|
|
||
| assert!(!is_closure_ptr(error as usize)); | ||
| assert_eq!((*error).message, message); | ||
|
|
||
| let key = crate::string::js_string_from_bytes(b"message".as_ptr(), 7); | ||
| let value = crate::object::js_object_get_field_by_name(error.cast(), key); | ||
|
Comment on lines
+1040
to
+1055
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. 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win Root the managed test values before later allocations. Line 1040 retains As per coding guidelines, “A GC-managed value's root store must dominate every subsequent site that can collect.” 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| assert_eq!( | ||
| value.bits() & crate::value::POINTER_MASK, | ||
| message as usize as u64, | ||
| "property lookup must reach Error handling, not the closure path", | ||
| ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Issue #450: clone an accessor closure (from `Object.defineProperty(obj, k, { get, set })`) | ||
|
|
||
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Check the conditional branch direction.
The assertion checks that
GC_TYPE_OBJECT,arrlike.elem.meta, andarrlike.ic.missappear in the block. It does not check which edge reaches each label. An invertedcond_brcould pass this test and reintroduce the wrong-layout dereference. Assert that the true edge reachesarrlike.elem.metaand the false edge reachesarrlike.ic.miss.🤖 Prompt for AI Agents