Skip to content

addr_class heap window [2TB,128TB) assumes mimalloc mappings — system-allocator runtime builds silently misclassify all heap pointers #6918

Description

@proggeramlug

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions