Found while validating PR #6917's size mode. Building perry-runtime with std::alloc::System instead of mimalloc (the new alloc-mimalloc feature off) produces binaries that misbehave silently:
console.log("x") prints nothing, exit 0
- heavier programs throw spurious empty-message
TypeErrors
Root cause: value/addr_class.rs classifies a NaN-boxed payload as a dereferenceable heap pointer only inside [0x200_0000_0000, 0x8000_0000_0000) — i.e. [2 TB, 128 TB). That window encodes mimalloc's macOS mapping range (3-5 TB). macOS system-malloc allocations land far below 2 TB, so with the system allocator every string/object allocation fails is_plausible_heap_addr and is treated as a handle/non-pointer.
Repro: build any program with the auto-optimize rebuild passing --no-default-features --features perry-runtime/full (i.e. without alloc-mimalloc) and run it. Identical build with alloc-mimalloc behaves correctly (verified both ways on macOS arm64, -Oz archives).
PR #6917 sidesteps this by force-adding alloc-mimalloc on every auto-optimize rebuild; the cfg gate remains in place. To actually offer a system-allocator build (~140 KB smaller, and a prerequisite for allocator flexibility on new targets), the heap-window predicates need an audit:
Related: the existing handle-band work (addr_class::is_plausible_heap_addr is the canonical predicate per repo policy).
Found while validating PR #6917's size mode. Building perry-runtime with
std::alloc::Systeminstead of mimalloc (the newalloc-mimallocfeature off) produces binaries that misbehave silently:console.log("x")prints nothing, exit 0TypeErrorsRoot cause:
value/addr_class.rsclassifies a NaN-boxed payload as a dereferenceable heap pointer only inside[0x200_0000_0000, 0x8000_0000_0000)— i.e. [2 TB, 128 TB). That window encodes mimalloc's macOS mapping range (3-5 TB). macOS system-malloc allocations land far below 2 TB, so with the system allocator every string/object allocation failsis_plausible_heap_addrand is treated as a handle/non-pointer.Repro: build any program with the auto-optimize rebuild passing
--no-default-features --features perry-runtime/full(i.e. withoutalloc-mimalloc) and run it. Identical build withalloc-mimallocbehaves correctly (verified both ways on macOS arm64,-Ozarchives).PR #6917 sidesteps this by force-adding
alloc-mimallocon every auto-optimize rebuild; the cfg gate remains in place. To actually offer a system-allocator build (~140 KB smaller, and a prerequisite for allocator flexibility on new targets), the heap-window predicates need an audit:is_valid_obj_ptr/is_plausible_heap_addrbounds per (OS, allocator)0x200_0000_0000and the "3-5 TB" comments inarray/header.rs,symbol.rs,map.rs,set.rs)Related: the existing handle-band work (
addr_class::is_plausible_heap_addris the canonical predicate per repo policy).