Skip to content

Commit dff644f

Browse files
Ralph Kuepperclaude
andcommitted
fix: JS_HANDLE_TAG extraction in js_nanbox_get_pointer, layout guard
- js_nanbox_get_pointer now extracts pointers from JS_HANDLE_TAG (0x7FFB) values. Previously these fell through to the default case returning 0, causing null pointer dereferences when widget handles crossed module boundaries via inline_nanbox_pointer's "already tagged" path. - Guard unwrap() in layout_stack against None from try_borrow re-entrancy Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 73d7469 commit dff644f

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

crates/perry-runtime/src/value.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ pub extern "C" fn js_nanbox_is_pointer(value: f64) -> bool {
674674

675675
/// Extract a pointer from a NaN-boxed f64 value.
676676
/// Also handles raw pointer bits (bitcast from i64) for backward compatibility.
677-
/// Handles both POINTER_TAG and STRING_TAG.
677+
/// Handles POINTER_TAG, STRING_TAG, BIGINT_TAG, and JS_HANDLE_TAG.
678678
/// Returns the pointer as i64.
679679
#[no_mangle]
680680
pub extern "C" fn js_nanbox_get_pointer(value: f64) -> i64 {
@@ -693,6 +693,12 @@ pub extern "C" fn js_nanbox_get_pointer(value: f64) -> i64 {
693693
return jsval.as_bigint_ptr() as i64;
694694
}
695695

696+
// JS_HANDLE_TAG (0x7FFB): used for V8 handles and Perry UI widget handles
697+
// when values pass through inline_nanbox_pointer's "already tagged" path.
698+
if (bits & TAG_MASK) == JS_HANDLE_TAG {
699+
return (bits & POINTER_MASK) as i64;
700+
}
701+
696702
if bits != 0 && bits <= POINTER_MASK {
697703
let upper = bits >> 48;
698704
if upper == 0 || (upper > 0 && upper < 0x7FF0) {

0 commit comments

Comments
 (0)