XTaskQueue: terminating a composite queue cancels another queue's pending callback #243

Open
opened 2026-11-26 03:39:11 +00:00 by github-bot · 1 comment
Owner

@⁠Bennet0k on GitHub · 2026-11-24 22:59 UTC · original

Source

Reproduction. Create a manual base queue and a composite queue using the base ports. Enqueue one immediate callback on each. Terminate the composite queue, then dispatch the base queue. Running the queue logic from 2119b0e returned canceled=true for both callbacks and no work from base dispatch. The base callback should remain queued and run with canceled=false, following the independent queue lifetimes documented by Microsoft.

Proposed fix. Store the submitting queue identity on each pending callback and cancel only callbacks owned by the terminating queue. Retain others in FIFO order and invoke cancellation callbacks outside the port lock. Add a manual-queue regression with the above sequence. #198 covers callbacks that are still delayed. This case uses callbacks already present in the shared port.

Found in an AI-assisted audit of 2119b0e.

**@⁠Bennet0k** on GitHub · 2026-11-24 22:59 UTC · [original](https://github.com/fxceless/victory-fork/issues/243) [Source](https://github.com/fxceless/victory-fork/blob/2119b0e44c53aa9648307b0c5c73590290305b1f/crates/victory-hle/src/modules/xasync.rs#L374-L397) **Reproduction.** Create a manual base queue and a composite queue using the base ports. Enqueue one immediate callback on each. Terminate the composite queue, then dispatch the base queue. Running the queue logic from `2119b0e` returned `canceled=true` for both callbacks and no work from base dispatch. The base callback should remain queued and run with `canceled=false`, following the [independent queue lifetimes documented by Microsoft](https://github.com/microsoft/libHttpClient/blob/main/Include/XTaskQueue.h#L1152-L1156). **Proposed fix.** Store the submitting queue identity on each pending callback and cancel only callbacks owned by the terminating queue. Retain others in FIFO order and invoke cancellation callbacks outside the port lock. Add a manual-queue regression with the above sequence. #198 covers callbacks that are still delayed. This case uses callbacks already present in the shared port. Found in an AI-assisted audit of `2119b0e`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:39:11 +00:00
Author
Owner

@⁠avt0m4t48 on GitHub · 2026-11-24 23:42 UTC · original

Independent public-API tests on exact heads 98e608b8 (#296) and 843eff1b (#324) confirm that both preserve sibling FIFO when terminating a composite queue, including delayed callbacks already on the port. Both checks failed on main 2119b0e.

A separate dispatch-time case persists on all three. While terminate is canceling its work port, the queue is already marked terminated. If a manual reentrant dispatch or the serialized worker dequeues an owned completion in that interval, it passes canceled=false. The sibling's completion correctly gets false. Both invocation paths currently supply a hard-coded flag. Five public API probe outcomes on #296 repeated 25 times in the source-built Linux harness. Fork source · libHttpClient reference

This finding is for callbacks dequeued after termination was marked. A still-sleeping delayed callback is the separate #198 path. Native Windows execution was outside this check.

**@⁠avt0m4t48** on GitHub · 2026-11-24 23:42 UTC · [original](https://github.com/fxceless/victory-fork/issues/243#issuecomment-7147713245) Independent public-API tests on exact heads `98e608b8` (#296) and `843eff1b` (#324) confirm that both preserve sibling FIFO when terminating a composite queue, including delayed callbacks already on the port. Both checks failed on main `2119b0e`. A separate dispatch-time case persists on all three. While terminate is canceling its work port, the queue is already marked terminated. If a manual reentrant dispatch or the serialized worker dequeues an owned completion in that interval, it passes `canceled=false`. The sibling's completion correctly gets `false`. Both invocation paths currently supply a hard-coded flag. Five public API probe outcomes on #296 repeated 25 times in the source-built Linux harness. [Fork source](https://github.com/fxceless/victory-fork/blob/98e608b87e0357ddbdecb95a46dd2b7f63d4c2d6/crates/victory-hle/src/modules/xasync.rs#L349-L416) · [libHttpClient reference](https://github.com/microsoft/libHttpClient/blob/d940b02301f2ff1a4b3298766827d7d68f88e1f0/Source/Task/TaskQueue.cpp#L775-L798) This finding is for callbacks dequeued after termination was marked. A still-sleeping delayed callback is the separate #198 path. Native Windows execution was outside this check.
This discussion has been locked. Commenting is limited to contributors.
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/fxceless--victory-fork#243
No description provided.