Skip to content

fix(decoder): wait for both slot fences before reusing a slot - #66

Open
trmosala wants to merge 1 commit into
hgaiser:mainfrom
trmosala:fix/decoder-slot-fences
Open

trmosala wants to merge 1 commit into
hgaiser:mainfrom
trmosala:fix/decoder-slot-fences

Conversation

@trmosala

Copy link
Copy Markdown
Contributor

A copied picture's slot could be reused while its decode fence was still pending. The completion thread waited only for the most recent fence of each picture, the copy's transfer_fence. The next decode into that slot then reset the decode fence, and the validation layer reports VUID-vkResetFences-pFences-01123 ("is in use").

Waiting on the copy alone isn't enough. The copy waits on the decode's timeline semaphore, so the decode's GPU work has finished, but the decode submission's fence is a separate signal operation and isn't ordered before a waiter on that semaphore proceeds.

This keeps the fence of each successful decode and copy submission for a picture, and the completion thread waits for both before releasing the slot.

Testing (RTX 4080 SUPER, NVIDIA 620.70.06)

The race needs load to show up. Pinning the process to two CPUs (taskset -c 6-7) made it reliable:

Reproducer Before After
Plain H.264 decode of bframes.264, copying path 10/10 runs hit the VUID 0/10
Same, under a debugger 8/8 0/8
  • New ignored test in tests/decode_streams.rs: decodes and flushes 64 full H.264 streams on the forced-copy path, checks every frame, and with PIXELFORGE_VALIDATION=1 fails on the reset message. On main it failed with five of them; it passes with the fix.
  • A separate soak ran 9,000 reset/flush rounds (222,815 pictures) with no reset findings.
  • Everything CI runs passes, apart from the three drop_non_drop Clippy warnings that main also has. cargo test -- --ignored passes.
  • Other validation messages in the decode tests are unchanged by this: the decode/copy barrier hazards that fix(decoder): clear the sync-validation hazards in the copy path #63 addresses, plus a few in the adopted-device and AV1 resize tests that also show on main.

🤖 Investigated and fixed with GPT-6.2 Astra in Codex, reviewed with Claude Opus 5.5 in Claude Code.

The transfer queue can finish copying a picture before the decode queue signals its fence. Keep the fences from both successful submissions and wait for them together before releasing the slot.
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