Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions .github/workflows/zimg-graphengine-bisect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: zimg graphengine bisect (Linux)

# Task #109: zimg e2e43d09 (graphengine 91c6af4c) made VapourSynth R78's resize
# abort with "double free or corruption" on Linux. This runs the evidence in
# docs/reports/task-109-graphengine-tmp-overrun on Linux, where it was seen:
# c-bisect every graphengine commit cb5b2ce1..91c6af4c, plus graphengine
# HEAD and 91c6af4c with graphengine-fused-node-context.patch,
# built into zimg 67e06032 the way R78 builds it, run over
# cases.tsv (tmp_overrun.c): VapourSynth's build (NDEBUG),
# graphengine's guard pages, and ASan. gcc 13 and clang 18 on
# x64 (what the deps build uses), gcc 13 on arm64.
# vs-confirm repro.vpy through the bundles themselves: the rc3 candidate
# that aborted (zimg e2e43d09) and the pinned rebuild
# (67e06032), plainly and under valgrind.
#
# Dispatch it, or push a change to this file on a branch (a workflow that is
# not on the default branch cannot be dispatched). A push whose commit message
# contains [vs-only] runs vs-confirm alone.

on:
workflow_dispatch:
inputs:
repeat:
description: 'Plain vspipe runs per conversion in vs-confirm'
default: '50'
push:
branches-ignore: [main]
paths: ['.github/workflows/zimg-graphengine-bisect.yml']

permissions:
contents: read
actions: read

env:
R: docs/reports/task-109-graphengine-tmp-overrun/scripts

jobs:
c-bisect:
if: ${{ !contains(github.event.head_commit.message, '[vs-only]') }}
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-24.04, arch: x64, cc: gcc-13, cxx: g++-13 }
- { os: ubuntu-24.04, arch: x64, cc: clang-18, cxx: clang++-18 }
- { os: ubuntu-24.04-arm, arch: arm64, cc: gcc-13, cxx: g++-13 }
runs-on: ${{ matrix.os }}
timeout-minutes: 90
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
steps:
- uses: actions/checkout@v5

- name: Tools
run: |
sudo apt-get update
sudo apt-get install -y ninja-build gcc-13 g++-13 clang-18 llvm-18
pipx install meson==1.5.2
meson --version; $CC --version | head -1
grep -m1 'model name' /proc/cpuinfo || true
grep -m1 -o 'avx512[a-z]*' /proc/cpuinfo | head -1 || echo "no avx512"
ldd --version | head -1

- name: Fetch zimg, graphengine, VapourSynth
run: bash $R/fetch.sh "$RUNNER_TEMP/src"

- name: Bisect
run: |
mkdir -p out
bash $R/bisect.sh "$RUNNER_TEMP/src" "$RUNNER_TEMP/bisect" "vs guard asan" | tee out/bisect.tsv

- name: The patch on 91c6af4c and on graphengine HEAD
run: |
P=$PWD/$R/graphengine-fused-node-context.patch
HEAD=$(git -C "$RUNNER_TEMP/src/graphengine" rev-parse origin/HEAD)
printf 'graphengine\tmode\tcases\toverrun\tabort\n' > out/patched.tsv
for ge in 91c6af4c "$HEAD"; do
for mode in vs guard asan; do
b="$RUNNER_TEMP/fix-${ge:0:8}-$mode"
GE_PATCH=$P bash $R/build.sh "$RUNNER_TEMP/src" 67e06032 "$ge" "$b" "$mode"
opts=(); [ "$mode" = asan ] && opts=(--exact)
bash $R/run_cases.sh "$b/tmp_overrun" $R/cases.tsv "${opts[@]}" > "out/patched-${ge:0:8}-$mode.tsv"
awk -F'\t' -v g="${ge:0:8}+patch" -v m="$mode" 'NR>1{n++; if($7=="OVERRUN")o++; else if($7~/^abort/)a++}
END{printf "%s\t%s\t%d\t%d\t%d\n", g, m, n, o, a}' "out/patched-${ge:0:8}-$mode.tsv" | tee -a out/patched.tsv
done
done

- name: Per-case results
if: always()
run: cp "$RUNNER_TEMP"/bisect/*.tsv "$RUNNER_TEMP"/bisect/*.build.log out/ 2>/dev/null || true

- uses: actions/upload-artifact@v4
if: always()
with:
name: c-bisect-${{ matrix.arch }}-${{ matrix.cc }}
path: out/

vs-confirm:
strategy:
fail-fast: false
matrix:
include:
- { label: 'A-e2e43d09', run_id: '44931836464' }
- { label: 'B2-67e06032', run_id: '44982770125' }
runs-on: ubuntu-24.04 # the deps-build image (glibc 2.39)
timeout-minutes: 120
steps:
- uses: actions/checkout@v5

- name: Tools
run: |
sudo apt-get update
sudo apt-get install -y valgrind unzip
grep -m1 'model name' /proc/cpuinfo
grep -m1 -o 'avx512[a-z]*' /proc/cpuinfo | head -1 || echo "no avx512"

- name: Install the bundle (build-deps-linux ${{ matrix.run_id }})
env:
GH_TOKEN: ${{ github.token }}
DEPS_RUN_ID: ${{ matrix.run_id }}
run: bash .github/scripts/install-deps-bundle.sh linux-x64 deps-v1.18.0-rc3 1.18.0-rc3 deps/linux-x64

- name: repro.vpy, plain and under valgrind
env:
LABEL: ${{ matrix.label }}
REPEAT: ${{ inputs.repeat || '50' }}
run: |
mkdir -p out
bash $R/vs_confirm.sh "$PWD/deps/linux-x64" "$LABEL" "$REPEAT" out/logs | tee out/vs-confirm.tsv

- uses: actions/upload-artifact@v4
if: always()
with:
name: vs-confirm-${{ matrix.label }}
path: out/
8 changes: 8 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3768,6 +3768,14 @@ reads a field (ZIMG_API_VERSION 2.5) no release has. zimg is VapourSynth's
own resize, so bumping either commit changes every resize on Linux: A/B it
through `deps_run_id` first. `zimg_pin_test.dart` (push gate) fails on an
unpinned wrap or clone; `zimg_colorspace_test.rs` is what caught the crash.
The crash is graphengine `f6211289` (task #109): a fused node's context is
left out of `get_tmp_size()`, so every error-diffusion conversion writes past
the buffer, and graphengine HEAD still has it. **Bump `ZIMG_COMMIT` /
`ZIMG_GRAPHENGINE_COMMIT` only to an upstream commit that fixes it**: build
the candidate with `docs/reports/task-109-graphengine-tmp-overrun/scripts/build.sh`
in `guard` mode and run `run_cases.sh` over `cases.tsv`; its 36
error-diffusion cases must not abort. That needs VapourSynth's source (R78's
zimg overlay), not a VapourSynth build.
macOS ships zimg releases (arm64 Homebrew's, x64 3.0.5 from source), Windows
the wheel's (docs/reports/task-103-linux-zimg-pin).

Expand Down
41 changes: 41 additions & 0 deletions docs/ENGINEERING_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6380,3 +6380,44 @@ x64-v2; about 2 in 10 legs, never elsewhere.
measured at 23-31 s state 5 minutes now; the detectors are bounded at 2.

Report: [docs/reports/task-99-av1-conformance-flake](reports/task-99-av1-conformance-flake/index.html).

### graphengine f6211289 leaves an error-diffusion node's context out of tmp_size (task #109, 2026-11-22)

The upstream side of task #103's abort. Bisected and reproduced without
VapourSynth; the cause is in graphengine, not in VapourSynth or our build.

- **Cause.** graphengine `f6211289` ("Exclude fused nodes from buffer sizing
calculation", 2026-07-30; in zimg since master `e2e43d09`) added
`if (!live_rows) continue;` to `compile_simulation_result`. That skips the
cache sizing, as meant, and also the node's `context_size` and its addition
to `tmp_size`. zimg's error-diffusion node is fused and has a real context
(two float error rows, `2 × (width + 2) × 4` bytes), so `init_context`
writes it past the buffer `zimg_filter_graph_get_tmp_size()` asked for:
792 bytes at width 96, 5784 at 720. VapourSynth allocates exactly that size
in `vszimg::real_get_frame`, and glibc caught the overrun at `free()`.
graphengine HEAD (`e9b10267`) still has it.
- **Measured.** `tmp_overrun.c` (zimg's C API, as `vsresize.cpp` uses it) over
158 graphs, with zimg built by R78's own overlay meson.build. On graphengine
`cb5b2ce1` through `562889d3`, nothing overruns. From `f6211289` on,
**every graph with error diffusion** corrupts the buffer: 36 of 36 trip
graphengine's own guard pages without NDEBUG, and with NDEBUG (as shipped)
18 to 24 of them write past the end and the rest overwrite another region.
`none`, ordered and random dither never do. Measured on macOS arm64 and
x86_64 (Rosetta) and on Linux x64 and arm64 (gcc 13, clang 18), and in zimg
master built by its own autotools. Through bundle A's vspipe on Linux:
50 of 50 runs abort per error-diffusion conversion, and valgrind finds the
write `0 bytes after a block of size 384` in `begin_frame` ←
`real_get_frame`. The pinned bundle B2 is clean.
- **Fix (upstream's to make).** Skip only the plane loop for a node with no
live rows (`graphengine-fused-node-context.patch`, a one-line change). It
is clean on every case and mode, and keeps f6211289's saving (1216 against
1344 bytes in the minimal repro). Reported as sekrit-twc/zimg#245
(https://github.com/sekrit-twc/zimg/issues/245). VapourBox never ships the patch.
- **Exposure.** None in VapourBox: Linux is pinned to `cb5b2ce1` (task
#103); macOS ships zimg releases; the Windows R78 wheel (2026-07-24)
predates f6211289. A bump of `ZIMG_COMMIT` must land on an upstream commit
with the fix, A/B'd through `deps_run_id`.
- **Separate.** gcc 13 ASan on Linux arm64 also flags 32 4:2:0 conversions
at every commit, the good one included. That has not been examined (task #115).

Report: [docs/reports/task-109-graphengine-tmp-overrun](reports/task-109-graphengine-tmp-overrun/index.html).
1 change: 1 addition & 0 deletions docs/reports/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ to it.

| Date | Report | Outcome |
|---|---|---|
| 2026-11-22 | [Task #109: graphengine f6211289 leaves an error-diffusion node's context out of tmp_size](task-109-graphengine-tmp-overrun/index.html) | Upstream bug found and bisected; VapourBox unaffected (#103's pin). zimg master's graphengine update made `get_tmp_size()` omit a fused node's context, so every error-diffusion graph writes past the buffer (792 B at width 96, 5784 at 720). Reproduced through the C API alone on macOS arm64/x86_64 and Linux x64/arm64, and through bundle A's vspipe (50 of 50 aborts per conversion, valgrind invalid write in `begin_frame`). First bad commit f6211289; a one-line patch makes all 158 graphs clean in every mode. Reported as sekrit-twc/zimg#245 |
| 2026-11-22 | [Task #89: QTGMC InputType 2/3 at more than 8 bits](task-89-qtgmc-mask-high-bit-depth/index.html) | Fixed in the template: havsfunc's QTGMC runs MVTools' `mv.Mask` (ProgSADMask) on InputType 2/3 at Placebo–Medium, and Mask refuses any clip above 8 bits, so every 10–16-bit job (and every High Precision one) failed. `havsfunc_mask_any_depth` runs it on an 8-bit stand-in with `ml × 2^(bits−8)`: kind 1 never reads the clip's pixels, and MVTools takes the SAD shift from the clip but the scene-change thresholds from the vectors. 10-bit vs 8-bit output 0.16 levels (Slow/Medium), 0.07 (Placebo), below the Mask-off control (0.28 / 0.12); 8-bit unchanged (0 / 0); the factor sweep's minimum is ×4 at 10 bits and ×256 at 16. A correction is kept visible: the mask is exact only where SADs scale exactly (pel 1; pel 2's interpolation rounds per depth). macOS arm64 only, synthetic low bits |
| 2026-11-22 | [Task #100: 4:4:0 sources decoded as 4:4:4](task-100-440-sources/index.html) | Fixed in the worker: the pipe-format classifier put 4:4:0 (some JPEG/MJPEG cameras) with 4:2:2, judging one axis, so the decoder halved its horizontal chroma (1-px colour columns: mean 70 levels off, the columns gone; testsrc2 1.78 / 21 against a one-step 4:4:4 rendering). It is piped as 4:4:4 now: 0 / 0, an encode bit-identical to ffmpeg's own 4:4:4 decode, and an odd-width 4:4:0 source runs. Output change: "Match source" makes 4:4:4 from such a source (was 4:2:2). A property test checks both axes for every code. Synthetic fixtures, macOS arm64 |
| 2026-11-22 | [Task #103: Linux VapourSynth linked zimg master at build time](task-103-linux-zimg-pin/index.html) | Fixed in the deps (1.18.0-rc3 Linux assets replaced): R78's `subprojects/zimg.wrap` (`revision = HEAD`) is what Linux VapourSynth links, because its `meson setup` never receives `PKG_CONFIG_PATH`. zimg master's `e2e43d09` (graphengine update) made every resize abort ("double free or corruption", 617 of 6861 sweep rows). The wrap is pinned to 67e06032 and `libvapoursynth.so.4` is byte-identical to rc2's again. A correction is kept visible: pinning the script's own zimg clone first changed nothing (that library is unused). Graphengine cause not bisected (task #109); arm64 built but not tested |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# valgrind memcheck, vspipe -a src=GRAY16 -a dst=GRAY8 -a dither=error_diffusion -a size=96x64 -a threads=1 repro.vpy, bundle A (build-deps-linux 44931836464), run 44994952747

Thread 2:
Invalid write of size 8
at 0x4852CCC: memset (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x8363538: graphengine::zimg::(anonymous namespace)::TransformNodeBase::begin_frame(graphengine::zimg::FrameState*, unsigned int, unsigned int, unsigned int) const (in deps/linux-x64/vapoursynth/libvapoursynth.so.4)
by 0x8365108: graphengine::zimg::GraphImpl::impl::run_node(graphengine::zimg::Node*, graphengine::zimg::GraphImpl::impl::SimulationResult const&, graphengine::Graph::Endpoint const*, unsigned int, void*) const (in deps/linux-x64/vapoursynth/libvapoursynth.so.4)
by 0x836876D: graphengine::zimg::GraphImpl::run(graphengine::Graph::Endpoint const*, void*) const (in deps/linux-x64/vapoursynth/libvapoursynth.so.4)
by 0x8350997: zimg_filter_graph_process (in deps/linux-x64/vapoursynth/libvapoursynth.so.4)
by 0x834DAE6: (anonymous namespace)::vszimg::real_get_frame(VSFrame const*, VSCore*, VSAPI const*) (in deps/linux-x64/vapoursynth/libvapoursynth.so.4)
by 0x834E584: (anonymous namespace)::vszimg::static_get_frame(int, int, void*, void**, VSFrameContext*, VSCore*, VSAPI const*) (in deps/linux-x64/vapoursynth/libvapoursynth.so.4)
by 0x833DEE2: VSNode::getFrameInternal(int, int, VSFrameContext*) (in deps/linux-x64/vapoursynth/libvapoursynth.so.4)
by 0x8353F94: VSThreadPool::runTasks(bool&) (in deps/linux-x64/vapoursynth/libvapoursynth.so.4)
by 0x495EDB3: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.33)
by 0x4BBCB63: start_thread (pthread_create.c:447)
by 0x4C49C83: clone (clone.S:100)
Address 0x9341440 is 0 bytes after a block of size 384 alloc'd
at 0x484E366: posix_memalign (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x834D8E7: (anonymous namespace)::vszimg::real_get_frame(VSFrame const*, VSCore*, VSAPI const*) (in deps/linux-x64/vapoursynth/libvapoursynth.so.4)
by 0x834E584: (anonymous namespace)::vszimg::static_get_frame(int, int, void*, void**, VSFrameContext*, VSCore*, VSAPI const*) (in deps/linux-x64/vapoursynth/libvapoursynth.so.4)
by 0x833DEE2: VSNode::getFrameInternal(int, int, VSFrameContext*) (in deps/linux-x64/vapoursynth/libvapoursynth.so.4)
by 0x8353F94: VSThreadPool::runTasks(bool&) (in deps/linux-x64/vapoursynth/libvapoursynth.so.4)
by 0x495EDB3: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.33)
by 0x4BBCB63: start_thread (pthread_create.c:447)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
bundle conversion size runs aborts abort_message vg_invalid_writes vg_first_frame
A-e2e43d09 GRAY16>GRAY8/error_diffusion 96x64 50 50 exit 134: Fatal glibc error: malloc.c:2599 (sysmalloc): assertion failed: (old_top == initial_top (av) && old_size == 0) 2 real_get_frame
A-e2e43d09 GRAY16>GRAY8/error_diffusion 720x480 50 50 exit 134: Fatal glibc error: malloc.c:2599 (sysmalloc): assertion failed: (old_top == initial_top (av) && old_size == 0) 2 real_get_frame
A-e2e43d09 YUV420P16>YUV420P8/error_diffusion 96x64 50 50 exit 134: Fatal glibc error: malloc.c:2599 (sysmalloc): assertion failed: (old_top == initial_top (av) && old_size == 0) 2 real_get_frame
A-e2e43d09 YUV420P16>YUV420P8/error_diffusion 720x480 50 50 exit 139: 2 real_get_frame
A-e2e43d09 YUV444PS>YUV444P16/error_diffusion 96x64 50 50 exit 134: Fatal glibc error: malloc.c:2599 (sysmalloc): assertion failed: (old_top == initial_top (av) && old_size == 0) 2 real_get_frame
A-e2e43d09 YUV444PS>YUV444P16/error_diffusion 720x480 50 50 exit 134: Fatal glibc error: malloc.c:2599 (sysmalloc): assertion failed: (old_top == initial_top (av) && old_size == 0) 2 real_get_frame
A-e2e43d09 YUV444PS>YUV420P8/error_diffusion 96x64 50 0 - 0 -
A-e2e43d09 YUV444PS>YUV420P8/error_diffusion 720x480 50 0 - 0 -
A-e2e43d09 GRAY16>GRAY8/none 96x64 50 0 - 0 -
A-e2e43d09 GRAY16>GRAY8/none 720x480 50 0 - 0 -
A-e2e43d09 YUV420P16>YUV420P8/none 96x64 50 0 - 0 -
A-e2e43d09 YUV420P16>YUV420P8/none 720x480 50 0 - 0 -
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
bundle conversion size runs aborts abort_message vg_invalid_writes vg_first_frame
B2-67e06032 GRAY16>GRAY8/error_diffusion 96x64 50 0 - 0 -
B2-67e06032 GRAY16>GRAY8/error_diffusion 720x480 50 0 - 0 -
B2-67e06032 YUV420P16>YUV420P8/error_diffusion 96x64 50 0 - 0 -
B2-67e06032 YUV420P16>YUV420P8/error_diffusion 720x480 50 0 - 0 -
B2-67e06032 YUV444PS>YUV444P16/error_diffusion 96x64 50 0 - 0 -
B2-67e06032 YUV444PS>YUV444P16/error_diffusion 720x480 50 0 - 0 -
B2-67e06032 YUV444PS>YUV420P8/error_diffusion 96x64 50 0 - 0 -
B2-67e06032 YUV444PS>YUV420P8/error_diffusion 720x480 50 0 - 0 -
B2-67e06032 GRAY16>GRAY8/none 96x64 50 0 - 0 -
B2-67e06032 GRAY16>GRAY8/none 720x480 50 0 - 0 -
B2-67e06032 YUV420P16>YUV420P8/none 96x64 50 0 - 0 -
B2-67e06032 YUV420P16>YUV420P8/none 720x480 50 0 - 0 -
Loading
Loading