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

Manually merged
github merged 1 commit from github-bot/gh-1597 into main 2026-11-29 08:21:20 +00:00 AGit
Owner

@⁠mizzied on GitHub · 2026-11-28 22:11 UTC · original
mizzied:up/queue-lines-fences → main · +288 −73 · 4 files · 1 commits · merged 2026-11-29 08:16 UTC

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.

**@⁠mizzied** on GitHub · 2026-11-28 22:11 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1597) `mizzied:up/queue-lines-fences` → `main` · +288 −73 · 4 files · 1 commits · merged 2026-11-29 08:16 UTC **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.
release_held dereferenced the address of a queue the title may have
released meanwhile, and a queued wait or signal read a fence by address
after the title had released and freed it.

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

Tests: the line a thread runs a queue's commands from outlives the queue and
is retired and off the list when the queue is gone; a queued wait or signal
keeps its fence whatever the title does with its own reference, and lets it
go when the command has run or the queue is gone.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 22:13:12 +00:00
github manually merged commit 4b823e1c26 into main 2026-11-29 08:21:20 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

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