Skip to content

fix(test): zero-initialise the SAD tables of the motion-window stream tests - #2671

Merged
lusoris merged 2 commits into
masterfrom
fix/cppcheck-motion-window-sad-uninitvar
Oct 9, 2026
Merged

lusoris merged 2 commits into
masterfrom
fix/cppcheck-motion-window-sad-uninitvar

Conversation

@lusoris

@lusoris lusoris commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Summary

The Cppcheck job of the Lint workflow fails on master since #2290 (e584c79a6). cppcheck 2.19.0, the Ubuntu 26.04 package CI installs, reports uninitvar on sad in core/test/test_motion_window_incremental.c at lines 256 and 289.

Verdict: false positive. Both loops write every entry that mwi_values_match() reads:

  • In mwi_stream() the writes go through the permuted index mwi_arrival(k, n, shuffled). That order is a permutation of 0..n-1 for every stream length the test uses (0, 1, 2, 3, 4, 5, 9 and 17; checked).
  • In test_flush_without_state_equals_upstream_flush() the writes are in order.

Each loop stops early only on an error, and the read is guarded by !err. cppcheck cannot see coverage through the permuted index.

Fix: both tables are zero-initialised before their loops, so they are whole on every path. A comment names the permutation. There is no suppression.

#2645 carries the same change from before #2290 landed. It has been blocked on a conflict in this file since 00:34. I have not closed it or marked it superseded; that is for its owner to decide.

Type

  • fix — bug fix
  • test — test-only

Checklist

  • Commits follow Conventional Commits (the commit-msg hook enforces this).
  • Every commit is signed off (git commit -s; fix a branch with git rebase --signoff origin/master). See DCO sign-off.
  • clang-format --dry-run --Werror is clean. cppcheck 2.19.0 with the CI flags is clean on the file.
  • Unit tests pass: test_motion_window_incremental (5 tests) and test_motion_window_advance_contract.

Bug-status hygiene (ADR-0165)

  • docs/state.md updated in this PR with a row in Recently closed (T-CPPCHECK-MOTION-WINDOW-SAD-UNINITVAR-2026-10-09).

Netflix golden-data gate (ADR-0024)

  • I did not modify any assertAlmostEqual(...) score in the Netflix golden Python tests.

Deep-dive deliverables (ADR-0108)

  • Research digest — no digest needed: one static-analysis false positive, explained above.
  • Decision matrix — no alternatives: cppcheck cannot follow a permuted index, and a suppression is ruled out.
  • AGENTS.md invariant note — no rebase-sensitive invariants: test-only change.
  • Reproducer / smoke-test command — see "Reproducer" below.
  • CHANGELOG fragment — no changelog needed: test-only change.
  • Rebase note — no rebase impact: fork-only test.

Reproducer

meson setup build core -Denable_cuda=false -Denable_sycl=false
python3 scripts/ci/write-compile-commands.py --build-dir build
docker run --rm -v "$PWD:$PWD" -w "$PWD" ubuntu:26.04 bash -c '
  apt-get update -qq && apt-get install -y -qq cppcheck python3 >/dev/null
  python3 scripts/ci/write_cppcheck_posix_model.py --cppcheck cppcheck --output build/cppcheck-posix-vmafx.cfg
  cppcheck --enable=warning,performance,portability --check-level=exhaustive --inline-suppr \
    --library=build/cppcheck-posix-vmafx.cfg --library=scripts/ci/cppcheck-public-entrypoints.cfg \
    --suppressions-list=.cppcheck-suppressions.txt --project=build/compile_commands.json \
    --file-filter="*core/test/test_motion_window_incremental.c" --error-exitcode=1 -q'
# origin/master: uninitvar at :256:55 and :289:70, exit 1.   This branch: no output, exit 0.
python3 scripts/ci/run_meson_test.py -- -C build test_motion_window_incremental test_motion_window_advance_contract

Known follow-ups

None.

@github-actions github-actions Bot added the type:bug Something isn't working label Oct 9, 2026
…tal instance (#2660)

* feat(metal): evaluate two ADM viewing distances in one integer_adm_metal instance

integer_adm_metal takes adm_norm_view_dist_extra and the shared merge
callback and name hook (adm_view_dist.c). iadm_metal_view_stages() gives
each distance its stage plan: the first runs every stage of
iadm_metal_stages(), a later one only the stages after the DWT, which
read the bands the first distance's DWT left. submit encodes each
scale's distances in turn, each with its own options, uniforms and
reduction buffers (accum, accum_x); collect concludes each distance with
iadm_metal_scores() and files the second under the <base>:nvde keys,
without debug scores (ADR-2795).

No Apple device runs anything for the project. The host replay holds
both distances to the CPU with == (test_two_viewing_distances: 8 and 10
bits, model options); the Metal parity test gains
test_adm_two_views_exact and test_adm_merged_registrations_exact for the
device and runs them as a CPU self-test on every host. The device run
is carried as T-METAL-ADM-SECOND-VIEW-DIST-DEVICE-2026-10-09, mapped to
those two cases in the macOS tester bundle's metal-rows.json.

* docs: regenerate the indexes and the citation map after rebasing

Signed-off-by: Lusoris <lusoris@proton.me>
… tests (#2671)

* fix(test): zero-initialise the SAD tables of the motion-window stream tests

The Cppcheck job fails on master since #2290: cppcheck 2.19.0 reports
uninitvar on sad in test_motion_window_incremental.c at lines 256 and
289. The loops write every entry the check reads (the arrival order is
a permutation of 0..n-1 for every stream length used) and stop early
only on an error, after which nothing is read: a false positive that
cppcheck cannot see through the permuted index.

Both tables are zero-initialised, so they are whole on every path. No
suppression; both findings are gone with the CI flags.

The state row is T-CPPCHECK-MOTION-WINDOW-SAD-UNINITVAR-2026-10-09.

Signed-off-by: Lusoris <lusoris@proton.me>
@lusoris
lusoris force-pushed the fix/cppcheck-motion-window-sad-uninitvar branch from 3b0ed45 to eefcd6f Compare October 9, 2026 14:57
@lusoris
lusoris merged commit eefcd6f into master Oct 9, 2026
13 of 40 checks passed
@lusoris
lusoris deleted the fix/cppcheck-motion-window-sad-uninitvar branch October 9, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant