forge
Explore
Log in

Don't you dare go Hollow

Merge lane-av1cheapwins: GIT_DIR leak fix in the runner locator + oracle depth-assumption docs

Browse files at this commit

66148c5d809eaf35b36283c7e18bfc21c6679f98Ahmet Kaan GümüşParent: 972e329a3d402b
.cargo/config.toml: the runner locator's rev-parse now strips GIT_DIR/GIT_WORK_TREE/GIT_INDEX_FILE,
which a leaked GIT_DIR (e.g. git bisect run) otherwise lets resolve the test package dir - the
class behind exit 127 and GIT_DISCOVERY_ACROSS_FILESYSTEM in worktrees. Proven both directions:
five leak shapes go 127 -> 0 while the normal path is unchanged. scripts/instrument-aom-oracle.sh:
63 comment lines documenting the 1-byte-per-sample assumption on rungs 1/6/7/15 (rung 12 is the
only depth-aware one), with the AST check that no added line lands inside an emitted C string.
.cargo/config.tomlmodified+4 -2
@@ -3,8 +3,10 @@
3 # allocation gets killed inside its own cgroup instead of OOM-killing the3 # allocation gets killed inside its own cgroup instead of OOM-killing the
4 # machine. Located via `git rev-parse --show-toplevel` from the invoker's cwd4 # machine. Located via `git rev-parse --show-toplevel` from the invoker's cwd
5 # (cargo does not resolve runner paths relative to this file, and an absolute5 # (cargo does not resolve runner paths relative to this file, and an absolute
6-# path would break other worktree checkouts of this repo).6+# path would break other worktree checkouts of this repo). `git bisect run`
7-runner = ["bash", "-c", "root=$(git rev-parse --show-toplevel) && exec \"$root/scripts/memguard-runner.sh\" \"$@\"", "--"]7+# exports GIT_DIR, which would make that rev-parse resolve the test package
8+# dir instead of the repo. Strip the leaked git vars first.
9+runner = ["bash", "-c", "root=$(env -u GIT_DIR -u GIT_WORK_TREE -u GIT_INDEX_FILE git rev-parse --show-toplevel) && exec \"$root/scripts/memguard-runner.sh\" \"$@\"", "--"]
8 10
9 [env]11 [env]
10 # The AV1 rate-target tests keep several frames' worth of encoder state on the12 # The AV1 rate-target tests keep several frames' worth of encoder state on the
lanes/av1cheapwins.report.mdadded+270 -0
@@ -0,0 +1,270 @@
1+# lane-av1cheapwins — recover 2 of 5 cheap wins, triage 3
2+
3+Base `main` @ `3aa16dd1`. Worktree `/home/user/.cache/wt/av1cheapwins`, branch
4+`lane-av1cheapwins`. Private `CARGO_TARGET_DIR=/home/user/.cache/ct/av1cheapwins`.
5+
6+**Landed: A** (1 commit) and **B** (2 commits, the second is my line-ref correction).
7+**Triaged, not landed: C1/C2/C3** (table in §4).
8+
9+## Commits on this branch
10+
11+```
12+3a621d80 scripts: re-point the oracle DEPTH ASSUMPTION blocks at today's decode.rs lines <- mine
13+abd4fb0e scripts: document the 1-byte-per-sample depth assumption on oracle dump rungs <- 98d878d6
14+71f1f09c ec-av1: ignore leaked GIT_DIR when the test runner locates the repo <- 082ef153
15+```
16+
17+No conflicts on either cherry-pick. Commands:
18+
19+```
20+git worktree add -b lane-av1cheapwins /home/user/.cache/wt/av1cheapwins 3aa16dd1
21+git -C /home/user/.cache/wt/av1cheapwins cherry-pick 082ef153 # A
22+git -C /home/user/.cache/wt/av1cheapwins cherry-pick 98d878d6 # B
23+```
24+
25+---
26+
27+## A — `lane-infra-gitdir` @ `082ef153` — LANDED
28+
29+### What the change actually does
30+
31+One line in `.cargo/config.toml`. The cargo target runner is a `bash -c` string
32+that locates the repo before exec'ing `scripts/memguard-runner.sh`:
33+
34+```diff
35+-runner = [... "root=$(git rev-parse --show-toplevel) && exec \"$root/scripts/memguard-runner.sh\" \"$@\"" ...]
36++runner = [... "root=$(env -u GIT_DIR -u GIT_WORK_TREE -u GIT_INDEX_FILE git rev-parse --show-toplevel) && exec ..." ...]
37+```
38+
39+Scope check: the three `env -u` vars are stripped **only** for the root-locating
40+`git rev-parse`. They are not stripped for the test binary, not exported, and
41+`scripts/memguard-runner.sh` is not touched (`.cargo/config.toml` is the only file
42+in the commit). So the blast radius is exactly "which directory is treated as the
43+repo root when locating the runner" — nothing else.
44+
45+### Direction 1 — leaked `GIT_DIR` (the case the fix claims)
46+
47+Isolating the command itself, `GIT_DIR` leaked to a package dir, cwd =
48+`crates/ec-av1`:
49+
50+```
51+leaked GIT_DIR=/home/user/Documents/Code/Rust/edith_codecs/crates/ec-av1/.git
52+OLD: fatal: not a git repository: '.../crates/ec-av1/.git'
53+ OLD runner=MISSING->exit 127 <- root empty, the reported symptom
54+NEW: NEW root=[/home/user/Documents/Code/Rust/edith_codecs]
55+ NEW runner=FOUND
56+```
57+
58+End to end, one named test (`temporal_delimiter_round_trips`, `-p ec-av1-syntax`),
59+OLD runner supplied via `--config` at CLI precedence, NEW = the committed one:
60+
61+| leaked `GIT_DIR` | OLD | NEW |
62+|---|---|---|
63+| (unset — normal case) | exit=0 | exit=0 |
64+| `<wt>/av1cheapwins/.git` | exit=127 | exit=0 |
65+| `<main>/.git/worktrees/av1cheapwins` | exit=127 | exit=0 |
66+| `<main>/.git` | exit=127 | exit=0 |
67+| `<main>/crates/ec-av1/.git` | exit=128 | exit=0 |
68+
69+The 127 is the exact reported failure:
70+
71+```
72+--: line 1: /home/user/.cache/wt/av1cheapwins/crates/ec-av1-syntax/scripts/memguard-runner.sh: No such file or directory
73+error: test failed, to rerun pass `-p ec-av1-syntax --lib`
74+ exit=127
75+```
76+
77+### Direction 2 — `GIT_DIR` unset (normal case), no regression
78+
79+```
80+$ env -u GIT_DIR -u GIT_WORK_TREE -u GIT_INDEX_FILE cargo test -p ec-av1-syntax --lib temporal_delimiter_round_trips
81+ Finished `test` profile [unoptimized + debuginfo] target(s) in 0.01s
82+ Running unittests src/lib.rs (.../deps/ec_av1_syntax-5faa43bfed45d870)
83+
84+running 1 test
85+test tests::temporal_delimiter_round_trips ... ok
86+
87+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 20 filtered out; finished in 0.00s
88+EXIT=0
89+```
90+
91+### One finding worth recording — the fix is necessary but not sufficient while checkouts disagree
92+
93+Measuring OLD vs NEW in a *worktree* while the primary checkout is still on
94+unfixed `main`, the leak case failed **nondeterministically** (exit 127 on some
95+runs, 0 on others), because a leaked `GIT_DIR` pointing into the primary checkout
96+makes cargo also load the primary checkout's `.cargo/config.toml`, and the
97+unfixed runner wraps the fixed one:
98+
99+```
100+Caused by:
101+ process didn't exit successfully: `bash -c 'root=$(git rev-parse --show-toplevel) && exec ...' -- bash -c 'root=$(env -u GIT_DIR ...)' -- ...
102+ (exit status: 127)
103+```
104+
105+Confirmed the diagnosis rather than assuming it — with the **fixed** runner
106+supplied for both levels, every leak passes 5/5:
107+
108+```
109+LEAK=<wt>/av1cheapwins/.git BOTH configs fixed: 0 0 0 0 0
110+LEAK=<main>/.git/worktrees/av1cheapwins BOTH configs fixed: 0 0 0 0 0
111+LEAK=<main>/.git BOTH configs fixed: 0 0 0 0 0
112+LEAK=<main>/crates/ec-av1/.git BOTH configs fixed: 0 0 0 0 0
113+```
114+
115+So the 127s were the split-state artifact of testing pre-merge, not a defect in
116+the change: **once this merges, every checkout carries the fix and the leak case
117+holds everywhere.** It does mean the fix only becomes fully effective when the
118+whole machine is on it — worth knowing, not worth handing back.
119+
120+### Verdict
121+
122+Landed. Both directions hold; behaviour is unchanged outside the leak case.
123+
124+---
125+
126+## B — `lane-av1oraclerungdepth` @ `98d878d6` — LANDED (with my correction)
127+
128+### Correction to the charter's premise
129+
130+The charter described this as "a loud abort plus a checker". **It is neither.**
131+The commit is **comments only** — 63 added lines to
132+`scripts/instrument-aom-oracle.sh`, every one a `#` comment, plus a 177-line
133+report. There is no abort, no assertion, no runtime check. The branch's own
134+report §3 argues why (the script is a source patcher with no `bit_depth`, no
135+frame index and no produced-file path to assert on) and that reasoning holds.
136+
137+So it closes the trap at the **human/script-reading level**, not the runtime
138+level. A lane that never opens the script still gets a 0-byte dump with no error.
139+Landed anyway: the four rungs are byte-paired with u8-narrowing decoder dumps by
140+design, so any loud abort would need both sides changed plus every existing
141+byte-pairing gate re-pinned. That is a separate lane, correctly deferred.
142+
143+### Generator evidence
144+
145+Comments-only, mechanically proven three ways:
146+
147+```
148+$ git diff 3aa16dd1 -U0 -- scripts/instrument-aom-oracle.sh | grep -E '^\+[^+]' | grep -vE '^\+ *#'
149+OK: still comments-only # zero non-comment added lines
150+
151+$ bash -n scripts/instrument-aom-oracle.sh
152+OK
153+
154+$ python3 ... compile every <<'PY…' heredoc body
155+heredoc bodies: 19 compiled: 19 failed: none
156+```
157+
158+The decisive one — added lines must not land inside a triple-quoted string, since
159+those *are* emitted into the oracle C. AST-walked all 50 C-emitting string
160+literals and mapped their lines back to the script:
161+
162+```
163+triple-quoted C-emitting string literals found: 50
164+added lines that land INSIDE an emitted C string: NONE
165+any emitted C string containing 'DEPTH': [732, 998]
166+```
167+
168+The two `DEPTH` hits are the pre-existing `YV12_FLAG_HIGHBITDEPTH` symbol, not
169+this commit's text (`DEPTH ASSUMPTION` / `DEPTH TRAP` appear 6 and 2 times, all
170+in shell or Python comments). **Emitted oracle bytes are unchanged.**
171+
172+### Every substantive claim re-verified against today's tree — all still true
173+
174+```
175+rung 1 PREFILT HBD-check=False fwrite(y_buffer + r*y_stride, 1, y_crop_width, f)
176+rung 6 POSTDEBLOCK HBD-check=False fwrite(y_buffer + r*y_stride, 1, y_width, f)
177+rung 7 PREFILT_WIDE HBD-check=False fwrite(y_buffer + r*y_stride, 1, y_width, f)
178+rung 15 POSTCDEF HBD-check=False fwrite(y_buffer + r*y_stride, 1, y_width, f)
179+rung 12 FINAL HBD-check=True fwrite(ec_s + r*ec_st[ec_pl], 2, ...) <- depth-aware
180+```
181+
182+The load-bearing justification also holds: the decoder-side pairs really do
183+narrow to u8 on purpose (`dump_stage` at `decode.rs:20048`, narrowing at `:20054`;
184+`dump_prefilter_wide` at `:20078`, narrowing at `:20090`).
185+
186+### What I had to fix before landing
187+
188+The four `DEPTH ASSUMPTION` blocks cited decoder line numbers that had **drifted**
189+(`decode.rs` is now 56341 lines; `:35263`, `:35336`, `:35356`, `:19734` and the
190+"same at `:53126`/`:53048`/`:53148`" duplicates no longer point at the narrowing
191+code). A comment whose entire job is "read this before you blame your decoder"
192+must not point at the wrong lines. Re-pointed all four (commit `3a621d80`):
193+
194+| block | was | now |
195+|---|---|---|
196+| rung 1 PREFILT | `decode.rs:35263-35273` | `decode.rs:20048-20054` |
197+| rung 6 POSTDEBLOCK | `:35336`, dup `:53126` | `:20048-20054`, dup `:53489` |
198+| rung 7 PREFILT_WIDE | `:19734-19762`, dup `:53048` | `:20078-20090`, dup `:53489` |
199+| rung 15 POSTCDEF | `:35356`, dup `:53148` | `:20048-20054`, dup `:53489` |
200+
201+`stream.rs:2129-2155` (rung 12's u16 LE writer) was already correct — verified,
202+left alone. Script-internal refs (`:146`, `:352`, `:416`, `:730`, `:934`) all
203+verified correct. Still comments-only after the correction.
204+
205+### Dry run
206+
207+The generator's first act is rewriting `~/.cache/aom-oracle/src`, so I sandboxed
208+it with `AOM_ORACLE_SRC` rather than touch the shared tree:
209+
210+```
211+$ AOM_ORACLE_SRC=<sandbox> bash scripts/instrument-aom-oracle.sh
212+already instrumented (no-op)
213+no oracle source at <sandbox>/av1/decoder/decodemv.c
214+SCRIPT EXIT=1
215+```
216+
217+The sandbox copy was **already instrumented** (9 `EC_INSTRUMENTED` markers — so is
218+`aom-oracle`, `aom-oracle2`, `aom-oracle3`), so the rungs took their no-op path
219+and the run stopped on a file I had not seeded. A true end-to-end patcher run
220+needs pristine libaom source, which does not exist in any local oracle tree and
221+would require a re-extract. **Not demonstrated** — the AST proof above is the
222+strongest available substitute. The shared oracle was verified untouched
223+(`decodeframe.c` mtime unchanged, 9 markers before and after, sandbox deleted).
224+
225+---
226+
227+## C — TRIAGE ONLY, nothing landed
228+
229+| branch @ sha | charter said | what it actually is | verdict |
230+|---|---|---|---|
231+| `lane-av1444chr` @ `49e30db7` | `decode.rs +13` | **Report-only** (`lanes/av1444chr.report.md` +37, zero `crates/` change) — a bounded probe that exonerates the reach: `tu_reach` and `of_tu` agree on all 528 units, and the walk has no 4-wide block, so `below_left=false` is correct. Own commit says "the only line left to change is one whose owner this round did not identify", and names the settling measurement (block-layout census) that must be re-run on merged main. | **record only** — it is a dead end worth not re-chasing, and its own next step is explicitly unre-run. Nothing to land. |
232+| `lane-av1-ibcwrite` @ `25f5c729` | `decode.rs +33/-4` | **Real change, instrumentation only** — adds the env-gated `EC_AV1_PIXPROBE=x,y` rung (`pix_write` at 4 reconstruction-store sites). It *names* an open defect (8x8 leaf at (296,128) stores pred 170 + res 19 = 189 where the oracle's all-zero `TX_32X32` stores 170, so the partition tree diverges around skipped intrabc leaves) and fixes nothing. `EC_AV1_PIXPROBE` is **absent from main**, so not superseded. | **land after rebase** — pins a still-open defect with an inert-when-unset rung; but **not a clean cherry-pick**: `reconstruct_rect`/`reconstruct` still exist, while the two mc sites moved to `decode.rs:36489`/`:36502` in a since-restructured `reconstruct_mc_rect`, so the hunks need manual re-anchoring. |
233+| `lane-av1-c10` @ `a2806383` | `mc.rs +214` | **Report-only** (`lanes/av1c10.report.md`, +6/-5) — a *disclosure correction* to a report that had wrongly called the branch test-only. The `mc.rs +214` is real but lives in ancestor `295dc3fe`, not at this sha. That change is the `u8` cast moving onto the `let m` binding in `diffwtd_mask`, and it is genuinely byte-identical: `m` is clamped to `[0,64]` first, so both forms emit the same mask bytes. **Main does not have it** (main: `let m = (...).clamp(0, 64);` / branch: `... .clamp(0, 64) as u8;`). | **record only** at this sha (a report edit that duplicates whatever the report becomes). The *substance* — `295dc3fe`'s byte-identical cast move plus its compound 8/10-bit gate — is **land after rebase** if that gate is still wanted. |
234+
235+Note on all three: none is an ancestor of `main` (`git merge-base --is-ancestor`
236+= no for all three), and each branch tip is exactly the sha in the charter.
237+
238+---
239+
240+## Build check
241+
242+My edits are `.cargo/config.toml` and `scripts/instrument-aom-oracle.sh` — zero
243+Rust. But the config change gates *every* cargo invocation, so the crate used
244+for the A proof was checked under it:
245+
246+```
247+$ cargo check --all-targets -p ec-av1-syntax
248+ Checking ec-core v0.1.0
249+ Checking ec-av1-syntax v0.1.0
250+ Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.30s
251+EXIT=0
252+```
253+
254+`crates/ec-av1` was not checked: I changed nothing in it, and the box is loaded.
255+
256+## What I deliberately did not do
257+
258+- **Did not land any of C.** Triaged only, as scoped.
259+- **Did not run the generator against the shared oracle.** Its first act rewrites
260+ `~/.cache/aom-oracle/src`; I used `AOM_ORACLE_SRC` to sandbox and deleted the
261+ sandbox. Shared tree verified untouched.
262+- **Did not rebuild the oracle.** A true end-to-end patcher run needs pristine
263+ libaom source, which no local oracle tree has. Left undone rather than faked.
264+- **Did not add a loud abort / size assertion to the four rungs.** That changes
265+ emitted bytes and breaks the u8 byte-pairing by design; it needs both sides plus
266+ a re-pin of every existing gate. Correctly deferred, and the branch says so.
267+- **Did not run any full suite.** Scoped to one named test in one crate.
268+- **Did not touch the main checkout.** `git status --porcelain` there is empty
269+ after every batch.
270+- **Did not push.**
lanes/av1oraclerungdepth.report.mdadded+177 -0
@@ -0,0 +1,177 @@
1+# lane-av1oraclerungdepth — make the oracle dump-rung DEPTH ASSUMPTION explicit
2+
3+Branch: `lane-av1oraclerungdepth`, worktree `/home/user/.cache/wt/av1rungdepth`,
4+base HEAD `aa0ac8c2` (main). **Comments only** — `scripts/instrument-aom-oracle.sh`,
5++63 lines, every added line a `#` comment (verified: `git diff -U0 | grep '^+' |
6+grep -v '^ *#'` is empty). No decoder change, no gate change, no oracle rebuild,
7+no change to the shared `~/.cache/aom-oracle`.
8+
9+## 1. What the four rungs are
10+
11+Verified by reading the emitted C (no re-derivation):
12+
13+| rung | env var | writes | depth check | paired decoder-side dump |
14+|---|---|---|---|---|
15+| 1 PREFILT | `EC_AV1_PREFILT_DUMP` | `fwrite(..., 1, y_crop_width, ...)` per row | **none** | `EC_AV1_PREFILT_DUMP`, `decode.rs:35263-35273` — `p.data.iter().map(\|&s\| s as u8)` |
16+| 6 POSTDEBLOCK | `EC_AV1_POSTDEBLOCK_DUMP` | `fwrite(..., 1, y_width, ...)` per row | **none** | `EC_AV1_POSTDEBLOCK_DUMP`, `decode.rs:35336` (dup `:53126`) |
17+| 7 PREFILT_WIDE | `EC_AV1_PREFILT_WIDE_DUMP` | `fwrite(..., 1, y_width, ...)` per row | **none** | `EC_AV1_PREFILT_WIDE_DUMP`, `decode.rs:19734-19762` (dup `:53048`) |
18+| 15 POSTCDEF | `EC_AV1_POSTCDEF_DUMP` | `fwrite(..., 1, y_width, ...)` per row | **none** | `EC_AV1_POSTCDEF_DUMP`, `decode.rs:35356` (dup `:53148`) |
19+| **12 FINAL** | `EC_AV1_FINAL_DUMP` | `fwrite(..., ec_hbd ? 2 : 1, ...)` | **yes** (`YV12_FLAG_HIGHBITDEPTH`) | `EC_AV1_FINAL_DUMP`, `stream.rs:2129-2155` (u16 LE) |
20+
21+Each of the four is `fwrite(ptr, 1, w, f)` — one byte per sample, no
22+`YV12_FLAG_HIGHBITDEPTH` branch. Rung 12 is the only one that checks. All four
23+stay as-is: the pairing with a u8-narrowing decoder dump is the reason they
24+exist, and changing one side breaks the diff. **Behaviour unchanged.**
25+
26+## 2. What was added
27+
28+A `DEPTH ASSUMPTION` block directly under each of the four rung headers, at
29+the point a reader editing that rung reads first:
30+
31+- `scripts/instrument-aom-oracle.sh:129` (rung 1), `:321` (rung 6), `:385`
32+ (rung 7), `:891` (rung 15)
33+
34+Each block states, in six to ten lines: the assumption (1 B/sample, no
35+`YV12_FLAG_HIGHBITDEPTH` check), why it is deliberate (byte-paired with the
36+named decoder-side dump that narrows to u8, with its file:line), the failure
37+signature on an HBD stream (SIGSEGV / a file exactly half `w*h*bps`, which
38+reads like a truncated decode), and the HBD-correct alternative (rung 12
39+`EC_AV1_FINAL_DUMP`, with its line).
40+
41+Two summary pointers were added so the trap is visible without opening a rung:
42+
43+- `:10-17` — the file header, right under "Rungs provided", before the first
44+ rung entry.
45+- `:703-714` — the rung-12 block that already said "unlike the u8-narrowing
46+ debug dumps", now expanded into the full trap with the measured numbers and
47+ the `stat -c%s` vs `w*h*bps` check to run before blaming a decoder.
48+
49+Final line references in the file (all verified against the committed
50+script): rung 1 block `:131`, rung 6 `:328`, rung 7 `:396`, rung 15 `:905`;
51+rung 1 emitted C `:146`, rung 6 `:352`, rung 7 `:416`, rung 15 `:934`,
52+rung 12 emitted C `:730`.
53+
54+## 3. Item 2 — no assertion added, and why
55+
56+The instruction's escape clause applies: **the script has no natural
57+non-byte-affecting failure point.**
58+
59+- The script is a source patcher. It runs `python3 - "$F" <<'PY...'` sixteen
60+ times, rewriting `~/.cache/aom-oracle/src/av1/decoder/decodeframe.c`. It
61+ never runs `aomdec`, never opens a dump file, never has a frame index.
62+- Its only per-rung "ok" signal is 16 `print("... instrumented")` /
63+ `print("... already instrumented (no-op)")` lines emitted at
64+ *instrumentation* time. They fire before any byte is written.
65+- The script has no depth value. Grepped: no `bit_depth`, no `bps`, no
66+ `ftell`/`fseek`/`stat`/`getsize`, no run-time state at all.
67+
68+A size assertion there would need the stream's `bit_depth`, the frame count and
69+the produced file path — none of which exist in this script. Plumbing them in
70+would mean the script parsing a fixture and re-running the oracle, which is
71+`build-aom-oracle.sh`'s job and is explicitly out of scope (no oracle
72+rebuild). **Comments alone shipped**, per the instruction.
73+
74+The equivalent check a lane runs by hand is now written into the two summary
75+blocks: `stat -c%s <dump>.f0` against `w*h*bps`.
76+
77+## 4. Proof
78+
79+### 4a. Static
80+
81+```
82+$ bash -n scripts/instrument-aom-oracle.sh
83+bash -n OK
84+$ # every <<'PY…' heredoc body compiled in isolation
85+python heredocs compile OK: 16
86+$ git diff -U0 scripts/instrument-aom-oracle.sh | grep -E '^\+[^+]' | grep -vE '^\+ *#'
87+(no output) # every added line is a comment
88+```
89+
90+### 4b. The trap, measured on the shared oracle (read-only use)
91+
92+The shared build is already instrumented (`grep -c EC_INSTRUMENTED
93+decodeframe.c` = 7) and is a high-bitdepth build
94+(`aom_config.h: #define CONFIG_AV1_HIGHBITDEPTH 1`). It was only *run*, never
95+edited or rebuilt. Fixture: the committed
96+`crates/ec-av1/fixtures/av112bit-key.obu`, which the y4m header reports as
97+`W160 H128 C420p12` — 160·128 + 2·(80·64) = **30720 samples**, bps = 2, so
98+`w*h*bps` = **61440 B**.
99+
100+Each env var tested in isolation:
101+
102+| env var | exit | dump written |
103+|---|---|---|
104+| (none) | 0 | — (61496 B y4m) |
105+| `EC_AV1_FINAL_DUMP` (rung 12) | **0** | `fin.f0` = **61440 B** = `w*h*bps` ✅ |
106+| `EC_AV1_PREFILT_DUMP` (rung 1) | **139** | `pf.f0` = 0 B |
107+| `EC_AV1_POSTDEBLOCK_DUMP` (rung 6) | **139** | 0 B |
108+| `EC_AV1_PREFILT_WIDE_DUMP` (rung 7) | **139** | 0 B |
109+| `EC_AV1_POSTCDEF_DUMP` (rung 15) | **139** | 0 B |
110+
111+The 139 is a genuine SIGSEGV inside this rung's own `fwrite`, not a decode
112+refusal — gdb on rung 1:
113+
114+```
115+#3 fwrite ()
116+#4 av1_decode_tg_tiles_and_wrapup (pbi=…, …) <- rung 1's insertion point
117+#5 read_one_tile_group_obu (…)
118+```
119+
120+Same four rungs on the 8-bit fixture `444_lossy_superres_256x128_d12.obu`
121+(`W256 H128 C444`): rung 1 exits **0** and writes `p8.f0` = 65664 B. So the
122+four rungs are fine at 8 bits and broken at 12.
123+
124+**Correction to the charter's premise, kept in the comments:** on this build
125+the four rungs do not reach the "silently half-length" state — they crash
126+first (0-byte file), which reads the same way, worse. Where the 1-byte write
127+*does* stay in bounds the arithmetic is exactly as predicted. Replicated on
128+the real rung-12 output rather than asserted:
129+
130+```
131+$ python3 -c "…unpack fin.f0 as <30720H, take each low byte, write…"
132+rung12 EC_AV1_FINAL_DUMP size = 61440 (160*128 + 2*80*64 = 30720 samples x 2 B)
133+what a 1 B/sample rung emits = 30720 == exactly half: True
134+expected 8-bit rung size (w*h*bps=1) = 30720
135+```
136+
137+Both numbers are now in the comments: the comment at `:136-141` and the two
138+summary blocks name 61440 expected / 30720 actual, so a lane hitting this sees
139+the numbers it will actually measure.
140+
141+### 4c. What could NOT be demonstrated without touching the shared oracle
142+
143+- **The half-length file as an actual artifact.** On this build the four rungs
144+ SIGSEGV before finishing, so a real 30720 B file cannot be produced from the
145+ shared `aomdec`. Producing one would need a rebuild of an instrumented
146+ oracle with a fixed pointer/scale in the rung, which the charter forbids
147+ (no oracle rebuild) and which would also be a behaviour change. The 30720 B
148+ figure is therefore **derived byte arithmetic on a real 30720-sample file**
149+ (`fin.f0`), not a captured half-length dump.
150+- **The root cause of the SIGSEGV** is not diagnosed — only located to the
151+ rung's `fwrite` on the u16 buffer. Fixing it would change emitted bytes and
152+ break the pairing, i.e. out of scope here; it is a separate lane if anyone
153+ wants HBD pre-filter/post-deblock/post-CDEF ladders.
154+- **`bash scripts/instrument-aom-oracle.sh` was not executed end-to-end**, for
155+ the same reason: its first act is rewriting the shared oracle source. The
156+ `bash -n` plus 16/16 heredoc compile is the strongest check available
157+ without it.
158+
159+## 5. Follow-ups this lane did not do (not done on purpose)
160+
161+1. The four rungs could take a `YV12_FLAG_HIGHBITDEPTH` branch like rung 12,
162+ which would make them HBD-usable — but the decoder-side pair narrows to u8
163+ on purpose (`as u8`), so both sides would have to change together, and every
164+ existing byte-pairing gate would need re-pinning. That is a behaviour
165+ change, not a comment.
166+2. A reusable `stat -c%s … vs w*h*bps` check as a real assertion belongs in the
167+ gate that decodes through these rungs, not in the patcher.
168+
169+## 6. Constraint compliance
170+
171+- `scripts/instrument-aom-oracle.sh` only (plus this report).
172+- Comments only — no emitted byte changes (diff verified in §4a).
173+- No decoder change, no gate change.
174+- `~/.cache/aom-oracle` was executed read-only; no rebuild, no source edit.
175+ `git status --porcelain` in the primary checkout is unchanged (verified empty
176+ before and after).
177+- Never pushed.
scripts/instrument-aom-oracle.shmodified+64 -0
@@ -7,6 +7,14 @@
7 # this script reproduce the full ladder from scratch.7 # this script reproduce the full ladder from scratch.
8 #8 #
9 # Rungs provided (both env-gated, so an uninstrumented run is unchanged):9 # Rungs provided (both env-gated, so an uninstrumented run is unchanged):
10+# DEPTH TRAP (lane-av1oraclerungdepth): the DUMP rungs 1 / 6 / 7 / 15 write
11+# 1 byte per sample with no YV12_FLAG_HIGHBITDEPTH check (they are paired
12+# with decoder-side dumps that narrow to u8 on purpose). On a 10/12-bit
13+# stream they crash the oracle, or where they survive produce a file of
14+# EXACTLY HALF w*h*bps -- which looks like a truncated decode but is the
15+# rung's depth assumption. Each of those four carries a
16+# `DEPTH ASSUMPTION` block naming its decoder-side pair; rung 12
17+# (EC_AV1_FINAL_DUMP) is the depth-correct one.
10 # EC_AV1_PREFILT_DUMP=<prefix> -> <prefix>.f<N> per frame, Y then U then V,18 # EC_AV1_PREFILT_DUMP=<prefix> -> <prefix>.f<N> per frame, Y then U then V,
11 # crop-sized rows, written after tile decode and BEFORE any loop filter,19 # crop-sized rows, written after tile decode and BEFORE any loop filter,
12 # CDEF or LR. Diff against our own EC_AV1_PREFILT_DUMP to separate a20 # CDEF or LR. Diff against our own EC_AV1_PREFILT_DUMP to separate a
@@ -120,6 +128,20 @@ assert old_sig in s, "read_partition signature moved"
120 s = s.replace(old_sig, new_sig, 1)128 s = s.replace(old_sig, new_sig, 1)
121 129
122 # --- rung 1: pre-filter recon dump --------------------------------------130 # --- rung 1: pre-filter recon dump --------------------------------------
131+# DEPTH ASSUMPTION (lane-av1oraclerungdepth): this rung writes 1 byte per
132+# sample and has NO YV12_FLAG_HIGHBITDEPTH check. That is deliberate -- it is
133+# byte-paired with our own EC_AV1_PREFILT_DUMP, which narrows 10/12-bit to u8
134+# on purpose (decode.rs:20048-20054, `p.data.iter().map(|&s| s as u8)` in
135+# `dump_stage`).
136+# TRAP: on an HBD stream the file is EXACTLY HALF w*h*2 = w*h bytes, which
137+# reads like a truncated/short decode, not a decoder bug. For HBD use rung 12
138+# EC_AV1_FINAL_DUMP (:730) -- it IS depth-correct (u8 / u16 LE).
139+# OBSERVED 2026-09-29 on the HBD oracle build (CONFIG_AV1_HIGHBITDEPTH=1) with
140+# the committed `av112bit-key.obu` (160x128 4:2:0 12-bit = 30720 samples):
141+# rung 12 wrote 61440 B (w*h*bps) and this rung's 1-byte fwrite SIGSEGVs inside
142+# fwrite (exit 139, 0-byte file); the bytes it would have written are 30720 B
143+# = exactly half. Either way this is the RUNG's depth assumption, not a decoder
144+# defect -- never read a half-length/empty file here as a truncated decode.
123 anchor = """ av1_alloc_cdef_buffers(cm, &pbi->cdef_worker, &pbi->cdef_sync,145 anchor = """ av1_alloc_cdef_buffers(cm, &pbi->cdef_worker, &pbi->cdef_sync,
124 pbi->num_workers, 1);"""146 pbi->num_workers, 1);"""
125 dump = """ {147 dump = """ {
@@ -304,6 +326,16 @@ print("intra mode-info instrumented")
304 PYI326 PYI
305 327
306 # --- rung 6: post-deblock, pre-superres row dump ------------------------328 # --- rung 6: post-deblock, pre-superres row dump ------------------------
329+# DEPTH ASSUMPTION (lane-av1oraclerungdepth): 1 byte per sample, NO
330+# YV12_FLAG_HIGHBITDEPTH check. Deliberate -- byte-paired with our
331+# EC_AV1_POSTDEBLOCK_DUMP, which narrows to u8 (decode.rs:20048-20054,
332+# `dump_stage(..., &y, &u, &v)` over the u16 planes; same closure at :53489).
333+# TRAP: on an HBD stream the file is EXACTLY HALF w*h*2, which reads like a
334+# truncated/short decode, not a decoder bug. For HBD use rung 12
335+# EC_AV1_FINAL_DUMP (:730) -- depth-correct (u8 / u16 LE).
336+# OBSERVED 2026-09-29 (HBD build, av112bit-key.obu): the 1-byte fwrite SIGSEGVs
337+# (exit 139); where it survives it writes 30720 B where 61440 B is expected --
338+# exactly half. That is this rung, not a truncated decode.
307 python3 - "$F" <<'PYD'339 python3 - "$F" <<'PYD'
308 import sys340 import sys
309 path = sys.argv[1]341 path = sys.argv[1]
@@ -362,6 +394,16 @@ PYD
362 # additive env var at the SAME anchor (pre-loop-filter) but dumping the full394 # additive env var at the SAME anchor (pre-loop-filter) but dumping the full
363 # y_width/y_height aligned buffer, so a margin-region reconstruction bug can395 # y_width/y_height aligned buffer, so a margin-region reconstruction bug can
364 # be told apart from a margin-region deblock bug.396 # be told apart from a margin-region deblock bug.
397+# DEPTH ASSUMPTION (lane-av1oraclerungdepth): 1 byte per sample, NO
398+# YV12_FLAG_HIGHBITDEPTH check. Deliberate -- byte-paired with our
399+# EC_AV1_PREFILT_WIDE_DUMP, which narrows to u8 (decode.rs:20078-20090,
400+# `dump_prefilter_wide`; same closure at :53489). TRAP: on an HBD
401+# stream the file is EXACTLY HALF w*h*2, which reads like a truncated/short
402+# decode, not a decoder bug. For HBD use rung 12 EC_AV1_FINAL_DUMP (:730) --
403+# depth-correct (u8 / u16 LE).
404+# OBSERVED 2026-09-29 (HBD build, av112bit-key.obu): the 1-byte fwrite SIGSEGVs
405+# (exit 139); where it survives it writes 30720 B where 61440 B is expected --
406+# exactly half. That is this rung, not a truncated decode.
365 python3 - "$F" <<'PYW'407 python3 - "$F" <<'PYW'
366 import sys408 import sys
367 path = sys.argv[1]409 path = sys.argv[1]
@@ -659,6 +701,19 @@ PYC11
659 # y_crop_width), 8-bit as u8 and high bitdepth as u16 LE -- bit-depth701 # y_crop_width), 8-bit as u8 and high bitdepth as u16 LE -- bit-depth
660 # correct, unlike the u8-narrowing debug dumps.702 # correct, unlike the u8-narrowing debug dumps.
661 #703 #
704+# DEPTH TRAP (lane-av1oraclerungdepth) -- READ BEFORE USING ANY DUMP RUNG:
705+# rungs 1 (PREFILT :146), 6 (POSTDEBLOCK :352), 7 (PREFILT_WIDE :416) and
706+# 15 (POSTCDEF :934) write 1 byte per sample with NO YV12_FLAG_HIGHBITDEPTH
707+# check, because each is byte-paired with a decoder-side dump that narrows to
708+# u8 on purpose. On a 10/12-bit stream those four are unusable: measured on the
709+# HBD oracle build with `av112bit-key.obu` (160x128 4:2:0 12-bit, 30720
710+# samples) their 1-byte fwrite SIGSEGVs (exit 139, 0-byte file), and where it
711+# survives it writes 30720 B where w*h*bps = 61440 B is expected -- EXACTLY
712+# HALF, which reads like a truncated decode. Check `stat -c%s` against
713+# w*h*bps before calling either a decoder defect. This rung (12) is the
714+# depth-correct one for HBD. Each of those four rungs carries a
715+# `DEPTH ASSUMPTION` block naming its decoder-side pair and line.
716+#
662 # Rungs 1/6 (pre-filter / post-deblock) stop before CDEF+LR+superres, and717 # Rungs 1/6 (pre-filter / post-deblock) stop before CDEF+LR+superres, and
663 # every ffmpeg/aomdec pixel gate in this repo compares SHOWN frames only718 # every ffmpeg/aomdec pixel gate in this repo compares SHOWN frames only
664 # (class gate-blind-to-hidden-frames), so before this rung no instrument in719 # (class gate-blind-to-hidden-frames), so before this rung no instrument in
@@ -848,6 +903,15 @@ PYST
848 # builds (its 8-bit run SEGFAULTS); this rung is the 8-bit one. lane-903 # builds (its 8-bit run SEGFAULTS); this rung is the 8-bit one. lane-
849 # av1422filter added it to the live oracle tree by hand first, then it was904 # av1422filter added it to the live oracle tree by hand first, then it was
850 # transcribed here (class: instrument that lives only in a build tree).905 # transcribed here (class: instrument that lives only in a build tree).
906+# DEPTH ASSUMPTION (lane-av1oraclerungdepth): 1 byte per sample, NO
907+# YV12_FLAG_HIGHBITDEPTH check. Deliberate -- byte-paired with our
908+# EC_AV1_POSTCDEF_DUMP, which narrows to u8 (decode.rs:20048-20054; same
909+# closure at :53489). TRAP: on an HBD stream the file is EXACTLY HALF w*h*2,
910+# which reads like a truncated/short decode, not a decoder bug. For HBD use rung 12
911+# EC_AV1_FINAL_DUMP (:730) -- depth-correct (u8 / u16 LE).
912+# OBSERVED 2026-09-29 (HBD build, av112bit-key.obu): the 1-byte fwrite SIGSEGVs
913+# (exit 139); where it survives it writes 30720 B where 61440 B is expected --
914+# exactly half. That is this rung, not a truncated decode.
851 python3 - "$F" <<'PYC'915 python3 - "$F" <<'PYC'
852 import sys916 import sys
853 path = sys.argv[1]917 path = sys.argv[1]