Skip to content

Task #109: bisect zimg's Linux resize abort to graphengine f6211289 (report, repro, upstream zimg#245) - #260

Merged
StuartCameronCode merged 6 commits into
mainfrom
stuart/109-zimg-master-e2e43d09-graphengine-91c6af4
Nov 24, 2026
Merged

StuartCameronCode merged 6 commits into
mainfrom
stuart/109-zimg-master-e2e43d09-graphengine-91c6af4

Conversation

@StuartCameronCode

Copy link
Copy Markdown
Owner

The upstream side of task #103's Linux abort ("double free or corruption" in VapourSynth R78's vszimg::real_get_frame). This PR changes no product code and no build script. It adds an investigation report, the scripts and data behind it, and a Linux bisect workflow. The upstream bug is now reported as sekrit-twc/zimg#245.

Finding

  • zimg master e2e43d09 moved graphengine from cb5b2ce1 to 91c6af4c. Within that range, f6211289 ("Exclude fused nodes from buffer sizing calculation") added an early continue in compile_simulation_result. That continue also skips context_size and the tmp_size addition, so a fused node's context is left out of get_tmp_size().
  • zimg's error-diffusion node is fused and has a context of 2×(w+2)×4 bytes. Every conversion that uses error diffusion therefore writes past the buffer: 792 B at width 96, 5784 B at 720. VapourSynth allocates exactly tmp_size bytes, so glibc aborts.
  • Bisect: cb5b2ce1 … 562889d3 are clean. f6211289 and every later commit, graphengine HEAD e9b10267 included, fail. In each case it is the same 36 error-diffusion graphs out of 158 (the conversions VapourSynth makes, at 96x64, 98x64 and 720x480, progressive and per field).
  • The result is the same on Linux x64 (gcc 13, clang 18), Linux arm64 (gcc 13), macOS arm64 and macOS x86_64 (Rosetta). AddressSanitizer and valgrind both name the same write (init_context / begin_frame, 0 bytes after the region). The bad deps bundle's own vspipe confirms it: 50 of 50 runs abort per conversion.
  • A one-line fix (skip only the plane loop) makes all 158 graphs clean, with and without NDEBUG and under ASan. It went upstream with the issue; VapourBox does not ship it.
  • Exposure: none in VapourBox. Linux is pinned by task CPU-tiered x86 deps bundles (fixes #92) #103, macOS ships zimg releases, and the Windows R78 wheel predates f6211289.

What's in it

  • docs/reports/task-109-graphengine-tmp-overrun/: the report (index.html), the upstream issue text, and scripts/:
    • a C-API repro that mirrors vsresize.cpp (tmp_overrun.c) and a minimal one (upstream_repro.c)
    • the case generator and case list
    • build and bisect scripts (vs / guard / asan modes)
    • the VapourSynth confirmation and the macOS runs
    • the patch
  • data/ holds the recorded results.
  • .github/workflows/zimg-graphengine-bisect.yml: the Linux bisect over three toolchains, plus a vspipe confirmation against the two deps-build artifacts.
  • ENGINEERING_NOTES entry, reports index row, and a CLAUDE.md rule: bump ZIMG_COMMIT / ZIMG_GRAPHENGINE_COMMIT only to an upstream commit that fixes this. Check a candidate with build.sh in guard mode plus run_cases.sh over cases.tsv; its 36 error-diffusion cases must not abort.

Testing

  • The bisect ran in CI on Linux (x64 gcc/clang, arm64 gcc) and locally on macOS arm64/x86_64. The tables in the report come from those runs' data/.
  • Review checks:
    • make_cases.py regenerates cases.tsv byte for byte.
    • Every script passes bash -n and shellcheck -S warning.
    • The workflow YAML parses.
    • The report has no personal paths or network dependencies.
    • flutter test test/zimg_pin_test.dart passes (3/3).
  • Review fixes: the CLAUDE.md bump check was corrected (it named bisect.sh, which can't test an arbitrary zimg commit). The workflow inputs now go through env:.

Notes

  • This push starts zimg-graphengine-bisect.yml (~1–2 h), because the branch touches the workflow. Harmless; cancel it if the runner time isn't wanted.
  • The workflow's vspipe confirmation needs the build-deps-linux run artifacts (44931836464, 44982770125), which expire around 2027-02. The recorded results stay in data/.

🤖 Generated with Claude Code

@StuartCameronCode
StuartCameronCode force-pushed the stuart/109-zimg-master-e2e43d09-graphengine-91c6af4 branch 2 times, most recently from 4ed0e30 to 4e1b3e9 Compare November 24, 2026 11:34
StuartCameronCode and others added 6 commits November 24, 2026 23:18
…nd VapourSynth confirmation scripts; Linux workflow

tmp_overrun.c builds zimg graphs through the C API as VapourSynth R78's
resize does and measures writes outside the get_tmp_size() buffer. On macOS
arm64 graphengine f6211289 is the first commit that overruns (every graph
with error-diffusion dither); graphengine-fused-node-context.patch fixes it.
The workflow repeats the bisect on Linux x64 (gcc 13, clang 18) and arm64,
and runs repro.vpy through the aborting and the pinned rc3 bundles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… minimal upstream repro; dither check [vs-only]

The copied wrapper found Python relative to its own directory, so every
valgrind run failed to start (0 invalid writes meant nothing).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ount a Linux ASan error as an abort; keep failed build logs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on node's context out of tmp_size; engineering note, index row, CLAUDE.md bump rule

Bisected on macOS arm64/x86_64 and Linux x64 (gcc 13, clang 18) and arm64:
f6211289 is the first bad commit everywhere, graphengine HEAD still has it,
and a one-line change (size the context of a node with no live rows) makes
all 158 graphs clean. Bundle A's vspipe aborts 50/50 per error-diffusion
conversion with valgrind's invalid write in begin_frame <- real_get_frame;
B2 is clean. The upstream issue is drafted, not filed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ild.sh guard + run_cases.sh); workflow inputs through env; unused loop variable

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@StuartCameronCode
StuartCameronCode force-pushed the stuart/109-zimg-master-e2e43d09-graphengine-91c6af4 branch from 4e1b3e9 to 0ad4c37 Compare November 24, 2026 12:19
@StuartCameronCode
StuartCameronCode merged commit bd1ed4b into main Nov 24, 2026
18 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant