Skip to content

Commit 5205e1e

Browse files
author
Ralph Küpper
committed
style: use addr_class::is_handle_band for the handle-band guards (lint gate)
1 parent a0cc25a commit 5205e1e

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

crates/perry-runtime/src/event_target.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,10 @@ unsafe fn is_event_target(target: *const ObjectHeader) -> bool {
389389
return false;
390390
}
391391
// Handle-based receivers (EventEmitter ids live at 0x38000..0x40000,
392-
// widget/stream handles lower) are small integers, not heap pointers —
393-
// the runtime-wide convention is "below 0x100000 = handle". Probing the
394-
// GcHeader at handle-8 read unmapped memory and SIGSEGV'd when
395-
// events.on(emitter, ...) validated its target (#4633).
396-
if (target as usize) < crate::gc::GC_HEADER_SIZE + 0x100000 {
392+
// widget/stream handles lower) are small integers, not heap pointers.
393+
// Probing the GcHeader at handle-8 read unmapped memory and SIGSEGV'd
394+
// when events.on(emitter, ...) validated its target (#4633).
395+
if crate::value::addr_class::is_handle_band(target as usize) {
397396
return false;
398397
}
399398
let gc_header =

crates/perry-runtime/src/node_stream_readwrite.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ pub(super) fn string_value_eq(value: f64, expected: &[u8]) -> bool {
7676

7777
pub(super) fn object_ptr_from_value(value: f64) -> Option<*mut ObjectHeader> {
7878
let raw = raw_ptr_from_value(value);
79-
// Below 0x100000 is the handle band (EventEmitter ids sit at
80-
// 0x38000..0x40000, widget/stream handles lower) never a heap object.
81-
// The old 0x10000 floor let an EventEmitter handle through to the
82-
// GcHeader probe at raw-8, which is unmapped memory (#4633 SIGSEGV in
79+
// The handle band (EventEmitter ids sit at 0x38000..0x40000,
80+
// widget/stream handles lower) is never a heap object. The old 0x10000
81+
// floor let an EventEmitter handle through to the GcHeader probe at
82+
// raw-8, which is unmapped memory (#4633 SIGSEGV in
8383
// events.on(emitter, name, { signal }) target validation).
84-
if raw < 0x100000 || crate::buffer::is_registered_buffer(raw) {
84+
if crate::value::addr_class::is_handle_band(raw) || crate::buffer::is_registered_buffer(raw) {
8585
return None;
8686
}
8787
unsafe {

0 commit comments

Comments
 (0)