Skip to content

test(cuda): pin the allocating state on host-pinned pictures - #1649

Merged
lusoris merged 2 commits into
masterfrom
fix/cuda-pic-prealloc-check
Oct 1, 2026
Merged

lusoris merged 2 commits into
masterfrom
fix/cuda-pic-prealloc-check

Conversation

@lusoris

@lusoris lusoris commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Upstream Netflix/vmaf master's test_cuda_pic_preallocation dies with SIGSEGV in its host-pinned case due to a NULL priv->cuda.state dereference in default_release_pinned_picture() (Netflix/vmaf#1573 hunk a). The fork's core/src/cuda/picture_cuda.c:260 already sets the state on the pinned path. This PR adds a device-free regression test test_pinned_picture_release_uses_the_allocating_state in core/test/test_cuda_runtime_unwind.c that runs on any host with nv-codec headers, updates docs/state.md and AGENTS.md, and ships the changelog fragment.

Type

  • feat — new feature
  • fix — bug fix
  • perf — performance improvement
  • refactor — no behavior change
  • docs — documentation only
  • test — test-only
  • build / ci — tooling / infra
  • port — cherry-pick from upstream Netflix/vmaf
  • sycl / cuda / simd — backend-specific

Checklist

  • Commits follow Conventional Commits (the commit-msg hook enforces this).
  • make format && make lint is green locally.
  • Unit tests pass: python3 scripts/ci/run_meson_test.py -- -C build.
  • If I touched any SIMD/GPU code path, I ran /cross-backend-diff and the worst ULP is ≤ 2.
  • If I touched a feature extractor with SIMD/GPU twins, I either updated every twin or listed the gap under "Known follow-ups" below.
  • If I added a new .c / .cpp / .cu / .h / .hpp, it has the appropriate license header (see CONTRIBUTING.md).
  • If this is a breaking change, the commit message uses ! or BREAKING CHANGE: and the migration path is documented below.
  • If this PR adds an ADR, the ADR row lives in docs/adr/_index_fragments/<NNNN-slug>.md and the slug is appended to docs/adr/_index_fragments/_order.txt — do not edit docs/adr/README.md directly (regenerated by scripts/docs/concat-adr-index.sh; see ADR-0221).

Bug-status hygiene (ADR-0165)

  • docs/state.md updated in this PR with a row in the appropriate section (Open / Recently closed / Confirmed not-affected / Deferred), OR no state delta: REASON.

Netflix golden-data gate (ADR-0024)

  • I did not modify any assertAlmostEqual(...) score in the Netflix golden Python tests.
  • If I believe a golden value must change, I have explained why below AND pinged @lusoris for a CODEOWNERS exception.

Cross-backend numerical results

no numeric change: test and state documentation only

Performance (if perf or feat)

Deep-dive deliverables (ADR-0108)

  • Research digest — no digest needed: test-only verification of existing in-tree state assignment.
  • Decision matrix — no alternatives: only-one-way fix.
  • AGENTS.md invariant note — added to the relevant package's AGENTS.md, OR "no rebase-sensitive invariants".
  • Reproducer / smoke-test command — pasted below under "Reproducer".
  • CHANGELOG fragment — a new file under changelog.d/<section>/<topic>.md (added / changed / deprecated / removed / fixed / security). Do not edit CHANGELOG.md directly — scripts/release/concat-changelog-fragments.sh renders the Unreleased block from the fragment tree (see ADR-0221).
  • Rebase note — entry added to docs/rebase-notes.md under a new ID, OR no rebase impact: REASON.

Reproducer

./build-cuda/test/test_cuda_runtime_unwind
./build-cuda/test/test_cuda_pic_preallocation

Known follow-ups

None.

Breaking changes / migration

None.

@github-actions github-actions Bot added the type:test Test-only change label Sep 30, 2026
@lusoris
lusoris force-pushed the fix/cuda-pic-prealloc-check branch from cb11e87 to 48e3811 Compare October 1, 2026 00:43
Upstream master's test_cuda_pic_preallocation dies with SIGSEGV in its
host-pinned case. Checked on the RTX 4090: the fault is in
default_release_pinned_picture() at `mov 0x18(%rdx),%rbp` with rdx = 0,
a load of state->f through a NULL priv->cuda.state on the first unref.
Upstream's vmaf_cuda_picture_alloc_pinned() sets only priv->cuda.ctx; the
fix is the still-open Netflix/vmaf#1573, hunk (a).

The fork is not affected. picture_cuda.c:260 sets the state on the pinned
path. On the 4090 the fork's test_cuda_pic_preallocation passes 5/5, and
so does upstream's own test source built against the fork once its
handles start as NULL. The device test proves this only on a GPU host, so
test_cuda_runtime_unwind gains
test_pinned_picture_release_uses_the_allocating_state. It allocates a
pinned picture through the fake driver table and unrefs it. It fails,
without crashing, when the assignment is removed, and runs on any host
with the nv-codec headers.

The touched file is now clean under clang-tidy (CUDA lane: 8 findings on
master, 0 here) and cppcheck:
- the allocation checks free what they already allocated before
  returning;
- the lifecycle-close test asserts through a helper after its frees;
- the legacy runner is split in three.

docs/state.md refreshes the Netflix/vmaf#1573 hunk (a) row with this
evidence and the current line numbers. core/src/cuda/AGENTS.md and
docs/rebase-notes.md record the invariant for upstream syncs.
@lusoris
lusoris force-pushed the fix/cuda-pic-prealloc-check branch from 48e3811 to 1f0abd5 Compare October 1, 2026 07:04
@lusoris
lusoris merged commit 5a6c2cc into master Oct 1, 2026
74 of 76 checks passed
@lusoris
lusoris deleted the fix/cuda-pic-prealloc-check branch October 1, 2026 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:test Test-only change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant