Skip to content

gc(runtime): natively-compiled cli.js agent-loop init hits non-deterministic GC/heap corruption (number-for-Map, undefined reads, SIGSEGV @ tagged ptr) — cc-boot layer 5 #8770

Description

@proggeramlug

Summary

With the startup chain fixed (#8726/#8738/#8739/#8763), the natively-compiled Claude Code cli.js 2.1.112 bundle now boots and enters the agent loop (--help works; -p progresses through hooks / skills attachment / autocompact per --debug-file). But -p then fails non-deterministically during agent-loop init (num_turns: 0), with a different symptom nearly every run — the signature of GC / heap corruption under the app's allocation churn:

  • TypeError: (number).get is not a function / (number).set is not a function — a Map/object comes back as a number (its header/box clobbered)
  • TypeError: Cannot read properties of undefined (reading 'def') — a live object read as undefined
  • SIGSEGVEXC_BAD_ACCESS, KERN_INVALID_ADDRESS at 0x00000000ff00fff7 (a corrupted/tagged value dereferenced as a raw pointer)
  • intermittent hangs

Not fixed by GC pacing

12-run probe: default, PERRY_GC_MOVING_LOOP_POLLS=0, and PERRY_GEN_GC=0 all hang/err; both-off gives the .set error + SIGSEGV. No configuration stabilizes it, so it's not a single pacing knob.

Node parity

node cli_2.1.112.js --help and the agent loop run cleanly under Node — this is perry-runtime GC/memory correctness under a large real workload, i.e. the memory-parity frontier (cf. #7019 scavenge parity and the live-sweep fixes), not an app bug.

Next step to pin it

The shipped binary is stripped. Build a PERRY_DEBUG_SYMBOLS=1 cc (invalidates the codegen cache → full ~50 min recodegen + link; needs ~15 GB transient), reproduce the SIGSEGV, and symbolicate the .ips faulting frames to locate the clobbered allocation / missed root. The reduced-repro will likely be a churn pattern in the agent-loop init (skill/hook registries, token counting) rather than a one-liner.

Found while verifying the natively-compiled Claude Code boots end-to-end after the startup-chain fixes.

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