Queue: lines are shared and queued fences are held, not addressed #1597

Merged
mizzied merged 1 commit from upstream-pr/1597 into main 2026-11-29 08:16:55 +00:00
mizzied commented 2026-11-28 22:11:00 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by mizzied on 2026-11-28T22:11:00Z.


What was wrong. Two use-after-free paths in the queue code:

  • release_held dereferenced the address of a queue the title may already have released.
  • A queued wait or signal read a fence by address after the title had released and freed it.

The fix.

  • A queue's line is now an Arc<QueueLine> with a retired flag. It's registered in WAITING with its address (for diagnostics only), and the queue's drop retires it and takes it off the list, so release_held reads a line it holds a reference to.
  • A queued wait or signal holds a FenceRef, a reference to the fence, instead of its address. This covers queue::Held, the line's Job::Wait, Job::Signal and joined signals, and host::Late::Signal, so a fence the title released isn't read after it's freed.
  • The line's diagnostic label no longer reads the queue.

How it was tested. RTX 5070, Windows 11. New tests check two things:

  • The line a thread runs a queue's commands from outlives the queue, and is retired and off the list once the queue is gone.
  • A queued wait or signal keeps its fence whatever the title does with its own reference, and lets it go once the command has run or the queue is gone.

cargo test --workspace passes apart from repository_passes_policy, which already fails on main: lower.rs is over the 640 KiB file-size limit there (#1493 raises it). Clippy reports only the 16 findings already on main, none on lines this PR changes.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5545063483 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1597). Originally posted by [mizzied](https://github.com/mizzied) on 2026-11-28T22:11:00Z. --- **What was wrong.** Two use-after-free paths in the queue code: - `release_held` dereferenced the address of a queue the title may already have released. - A queued wait or signal read a fence by address after the title had released and freed it. **The fix.** - A queue's line is now an `Arc<QueueLine>` with a retired flag. It's registered in `WAITING` with its address (for diagnostics only), and the queue's drop retires it and takes it off the list, so `release_held` reads a line it holds a reference to. - A queued wait or signal holds a `FenceRef`, a reference to the fence, instead of its address. This covers `queue::Held`, the line's `Job::Wait`, `Job::Signal` and joined signals, and `host::Late::Signal`, so a fence the title released isn't read after it's freed. - The line's diagnostic label no longer reads the queue. **How it was tested.** RTX 5070, Windows 11. New tests check two things: - The line a thread runs a queue's commands from outlives the queue, and is retired and off the list once the queue is gone. - A queued wait or signal keeps its fence whatever the title does with its own reference, and lets it go once the command has run or the queue is gone. `cargo test --workspace` passes apart from `repository_passes_policy`, which already fails on `main`: `lower.rs` is over the 640 KiB file-size limit there (#1493 raises it). Clippy reports only the 16 findings already on `main`, none on lines this PR changes.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
trustno1-coder/VIctory-NVIDIA!1597
No description provided.