lane-av1enchang: box the DPB CdfSnapshot (Av1Encoder 139960 -> 18168 bytes), gate the tight-stack requirement, and add a measured SLOW-not-hung backstop
THE REAL DEFECT: Av1Encoder was 139,960 bytes BY VALUE (eight inline CdfSnapshot DPB slots) and is
returned by value through three nested Result<Self> constructors (with_pyramid_and_rate_target ->
with_pyramid -> new). Any caller on a normal 2 MiB thread stack CRASHES: reproduced twice on the
pre-fix binary built from unmodified main, 'fatal runtime error: stack overflow, aborting' at
Av1Encoder::new (encoder.rs:1519), from coredumpctl. The repo HID this behind
'.cargo/config.toml [env] RUST_MIN_STACK = 67108864' -- a 64 MiB stack for the workspace's own cargo
runs only, which is also why 'cargo test' wedges instead of aborting when the test binary is invoked
directly. Box the per-slot snapshot: 139960 -> 18168 bytes (7.7x). The tables' VALUES are untouched.
GATE: the_pyramid_constructors_fit_on_a_tight_stack spawns a 1 MiB thread and constructs both the flat
and the pyramid encoder. Red/green in milliseconds instead of a 6m35s debug run. Verified by Main:
with the Box removed the gate dies 'fatal runtime error: stack overflow, aborting' (SIGABRT); with it,
green in 0.00s. Post-fix clean from 384 KiB (2.7x margin at 1 MiB), pre-fix overflowed up to 2 MiB.
THE ~7 HOUR TEST IS NOT A HANG, and this lane measured it rather than guessing: it terminates and
passes (old pin ea8fa18f, same test, byte-identical output, 275.53s RELEASE). evals per search are
61.3 / 64.5 / 64.9 across 384k / 1.5M / 2M bps -- FLAT, equal to the search's designed bound, so the
search is not pathological. The cost is full search x 60 superblocks x 48 frames x 8 arms x ~13x debug
penalty, and the HIGH-BITRATE arms dominate because the rate loop must walk q_idx DOWN from seed 100
into the 20s to spend an 8000-byte budget. 3 gdb backtraces 20s apart show 3 different functions, 3
different blocks and a changing base_q_idx (32/32/30) -- progress, not a spin.
BACKSTOP, reported as a backstop and NOT as a fix for the cost: a per-CALL wall-clock ceiling on a
worker thread (1800s default, EC_AV1_ENCODE_CALL_BUDGET_SECS) = ~16x the worst honest debug call
(~110s, derived) and 1730x the worst optimized call (1.04s, measured). Red-proofed both ways:
EC_AV1_ENCODE_CALL_BUDGET_SECS=1 -> FAILED, exit 101, message carries the test name, the arm name, the
arm's elapsed seconds, the stuck call index and the text 'SLOW, NOT HUNG'; an injected spin_loop in
encode_frames fails at 5m00s where pre-fix it hangs forever (injection reverted, 0 grep hits).
BIT-EXACTNESS: round_trip_encode 108 passed 0 failed 40 ignored after the Box change; the bitrate gate
8/8 arms byte-identical to pre-fix; pyramid decode gates (display order through both decoders, three-
and four-level) all ok. Main re-ran the round_trip family in release: 20 passed 0 failed.
Lane report: lanes/av1enchang.report.md.