fix(runtime): node:zlib 58/58 — slab-buffer fake-GcHeader SIGBUS in brand probes#5044
Merged
Conversation
Small buffers (<256B) come from a per-thread bump slab with no GcHeader. Brand probes (Temporal/Date/Map/Set) that read addr-8 as a GcHeader on a slab buffer see the previous slab entry's data bytes — a content-dependent fake header. Observed: String(buffer) on a zlib unzipSync result matched GC_TYPE_TEMPORAL via js_to_primitive's Temporal probe (which runs before to_string's buffer-registry check) and dereferenced the buffer's (length,capacity) words as a TemporalCell Box pointer -> SIGBUS. Guard at the choke point: try_read_gc_header returns None for addresses inside small-buffer slab ranges, covering every brand probe at once. node-suite zlib: 57/58 -> 58/58 (unzip/auto-detect-deflate crashed).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Raises
node:zlibnode-suite parity to 58/58 (100%), from 57/58 on currentmain.The crash (zlib/unzip/auto-detect-deflate.ts, SIGBUS exit 138)
unzipSync(deflateSync(Buffer.from(input)))crashed for some inputs and not others — content-dependent.Root cause is not in zlib at all:
buffer/header.rs), which carries no GcHeader.String(buffer)/.toString()entersjs_to_primitive, whose Temporal brand probe (is_temporal_cell_addr) runs beforeto_string's buffer-registry check and readsaddr - GC_HEADER_SIZEas aGcHeader.obj_type == GC_TYPE_TEMPORAL, the value is misrouted into the Temporal path, which dereferences the buffer's(length, capacity)words (0x2f0000002ffor a 47-byte result) as aTemporalCellbox pointer → SIGBUS.Date/Map/Set/WeakRef brand probes share the same
try_read_gc_headerhelper, so the same content-dependent misroute was latent for all of them.Fix
Guard at the choke point:
addr_class::try_read_gc_headernow returnsNonefor addresses inside small-buffer slab ranges (newis_small_buf_slab_addr, also reused byis_registered_buffer's existing fast path). One check covers every brand probe; large buffers are unaffected (they get real arena GcHeaders withGC_TYPE_BUFFER).3 files, +26/−7. No Cargo.toml / CLAUDE.md / CHANGELOG edits (maintainer folds metadata at merge).
Verification (local macOS, node v26.3.0 oracle, print-and-diff)
cargo test -p perry-runtimeZero regressions: every non-zlib failure was re-run against a baseline build with the fix reverted and failed identically there.