VFS: synchronize merged directory handle access #1405

Open
hajduzsolt wants to merge 1 commit from upstream-pr/1415 into main
hajduzsolt commented 2026-11-24 15:44:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by hajduzsolt on 2026-11-24T15:44:07Z.


What is in it

  • crates/xcl/src/vfs_hooks.rs: synchronize merged-handle iteration and close; add synthetic concurrent iteration and close coverage.

Tested

  • Windows 11 Pro x64 build 26300, AMD Ryzen 7 9800X3D, AMD Radeon RX 9070 XT 16 GB, driver 32.0.32029.2010; Rust 1.98.1 MSVC, debug.
  • cargo test -p xcl --lib merged_find_serializes_iteration_and_close: 1 passed, 0 failed.
  • cargo test --workspace -- --test-threads=4 --nocapture: 752 passed, 0 failed, 41 ignored. The reported passes include tests that return early.
  • SKIPPED: test_title_draws_with_a_root_signature_under_the_debug_layer and uploads_start_from_each_subresources_state (D3D12 debug layer unavailable).

Regression run

main:

xcl-smoke v1
commit: b7aa9f3bd212088e0d927439284dc5ed325ce3c7
gpu: AMD Radeon RX 9070 XT
title: A newer retail game
seconds: 60
exit: 0x0
frames shown: 1675 (PresentX 1675)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14837 MB

PR:

xcl-smoke v1
commit: cd47fe2c8e61395ab5ee13cee5bbacc207b93006
gpu: AMD Radeon RX 9070 XT
title: A newer retail game
seconds: 60
exit: 0x0
frames shown: 1675 (PresentX 1675)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14708 MB

Not tested

  • Retail title and D3D12 debug-layer validation. The caller-pointer checks also described in #1388 are outside this change.

AI use

  • Codex (GPT-6): wrote implementation and unit tests, ran validation, and drafted this description.
<!-- greyfinch-sync:ivall/xcl:issue:5475437034 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1415). Originally posted by [hajduzsolt](https://github.com/hajduzsolt) on 2026-11-24T15:44:07Z. --- **What is in it** - `crates/xcl/src/vfs_hooks.rs`: synchronize merged-handle iteration and close; add synthetic concurrent iteration and close coverage. **Tested** - Windows 11 Pro x64 build 26300, AMD Ryzen 7 9800X3D, AMD Radeon RX 9070 XT 16 GB, driver 32.0.32029.2010; Rust 1.98.1 MSVC, debug. - `cargo test -p xcl --lib merged_find_serializes_iteration_and_close`: 1 passed, 0 failed. - `cargo test --workspace -- --test-threads=4 --nocapture`: 752 passed, 0 failed, 41 ignored. The reported passes include tests that return early. - SKIPPED: `test_title_draws_with_a_root_signature_under_the_debug_layer` and `uploads_start_from_each_subresources_state` (D3D12 debug layer unavailable). **Regression run** main: ``` xcl-smoke v1 commit: b7aa9f3bd212088e0d927439284dc5ed325ce3c7 gpu: AMD Radeon RX 9070 XT title: A newer retail game seconds: 60 exit: 0x0 frames shown: 1675 (PresentX 1675) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14837 MB ``` PR: ``` xcl-smoke v1 commit: cd47fe2c8e61395ab5ee13cee5bbacc207b93006 gpu: AMD Radeon RX 9070 XT title: A newer retail game seconds: 60 exit: 0x0 frames shown: 1675 (PresentX 1675) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14708 MB ``` **Not tested** - Retail title and D3D12 debug-layer validation. The caller-pointer checks also described in #1388 are outside this change. **AI use** - Codex (GPT-6): wrote implementation and unit tests, ran validation, and drafted this description.
DavidM1911 commented 2026-11-24 18:08:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T17:13:08Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (One parallel run showed a single flaky failure; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7138864209 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1415#issuecomment-7138864209). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T17:13:08Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. (One parallel run showed a single flaky failure; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
github-actions[bot] commented 2026-11-27 21:26:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-27T21:26:27Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7228445829 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1415#issuecomment-7228445829). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-27T21:26:27Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 05:40:14 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:40:14Z.


Triage (#1607) – head cd47fe2

#1662 fixes the same MergedFind use-after-free in vfs_hooks.rs (#1388) differently: the MERGED map owns the entries under synthetic handles, plus null-pointer checks. This PR was opened first, merges cleanly and has a concurrency test; it keeps the boxed handles and does the lookup, iteration and free under the one MERGED lock.
Minor: merged_next/close_merged use MERGED.lock().unwrap() inside extern "system" hooks, so a poisoned lock aborts where the old code fell through; the test module now has two 'use super::*;' lines and the diff leaves a double blank line.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7302013057 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1415#issuecomment-7302013057). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:40:14Z. --- **Triage (#1607)** – head cd47fe2 #1662 fixes the same MergedFind use-after-free in vfs_hooks.rs (#1388) differently: the MERGED map owns the entries under synthetic handles, plus null-pointer checks. This PR was opened first, merges cleanly and has a concurrency test; it keeps the boxed handles and does the lookup, iteration and free under the one MERGED lock. Minor: merged_next/close_merged use MERGED.lock().unwrap() inside extern "system" hooks, so a poisoned lock aborts where the old code fell through; the test module now has two 'use super::*;' lines and the diff leaves a double blank line. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
fromthemoonx commented 2026-12-03 09:14:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-12-03T09:14:51Z.


merge-check
base: 16c2fd082a
head: cd47fe2c8e
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3013 passed, 0 failed, 56 ignored (base: 3012 passed, 0 failed, 56 ignored, counted on 395405e4; only docs and scripts changed since); SKIPPED: 25, the same as base (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps); failing: none
review: read the whole diff (1 file, +67 -18). No blocking finding.

  1. The fix does what #1388 point 1 asks for. merged_next looks the handle up, reads the entry and moves the position under one MERGED lock, and close_merged removes and frees under the same lock. The entry is copied out, so the caller's buffer is written after the lock is released.
  2. The new test notices the old order. With the lock released before the entry is used (a one-line scratch change), it failed 35 of 40 runs. As submitted it passed 40 of 40, and the vfs tests passed 40 of 40 at 8 threads.
  3. Low: MERGED.lock().unwrap() in the two helpers would end the process on a poisoned lock, where main's code went on to the real function (also in the triage comment above). Nothing inside the two locked sections is expected to panic.
  4. Style only: a double blank line where is_merged was, and the test sits above the module's use super::*; with its own copy of it.
  5. Scope: the null-pointer and dwSize checks of #1388 (point 2) are not in this PR, as its description says, so the issue should stay open after the merge. #1662, the other PR for this bug, is closed.
  6. Not tested: a retail title (none on this machine), AMD.
    performance: none expected: FindNextFile on a merged listing took this lock once before and takes it once now, held for one entry copy.
    verdict: safe to merge
    hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5)
<!-- greyfinch-sync:ivall/xcl:comment:7373385553 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1415#issuecomment-7373385553). Originally posted by [fromthemoonx](https://github.com/fromthemoonx) on 2026-12-03T09:14:51Z. --- merge-check base: 16c2fd082ae2e96967a2ab553bc2e1032e491f70 head: cd47fe2c8e61395ab5ee13cee5bbacc207b93006 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3013 passed, 0 failed, 56 ignored (base: 3012 passed, 0 failed, 56 ignored, counted on 395405e4; only docs and scripts changed since); SKIPPED: 25, the same as base (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps); failing: none review: read the whole diff (1 file, +67 -18). No blocking finding. 1) The fix does what #1388 point 1 asks for. `merged_next` looks the handle up, reads the entry and moves the position under one `MERGED` lock, and `close_merged` removes and frees under the same lock. The entry is copied out, so the caller's buffer is written after the lock is released. 2) The new test notices the old order. With the lock released before the entry is used (a one-line scratch change), it failed 35 of 40 runs. As submitted it passed 40 of 40, and the `vfs` tests passed 40 of 40 at 8 threads. 3) Low: `MERGED.lock().unwrap()` in the two helpers would end the process on a poisoned lock, where main's code went on to the real function (also in the triage comment above). Nothing inside the two locked sections is expected to panic. 4) Style only: a double blank line where `is_merged` was, and the test sits above the module's `use super::*;` with its own copy of it. 5) Scope: the null-pointer and `dwSize` checks of #1388 (point 2) are not in this PR, as its description says, so the issue should stay open after the merge. #1662, the other PR for this bug, is closed. 6) Not tested: a retail title (none on this machine), AMD. performance: none expected: `FindNextFile` on a merged listing took this lock once before and takes it once now, held for one entry copy. verdict: safe to merge hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1415:upstream-pr/1415'
git switch 'upstream-pr/1415'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1415'
git switch 'upstream-pr/1415'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1415'
git switch 'upstream-pr/1415'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1415'
git switch 'main'
git merge --squash 'upstream-pr/1415'
git switch 'main'
git merge --ff-only 'upstream-pr/1415'
git switch 'main'
git merge 'upstream-pr/1415'
git push origin 'main'
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
xcl-dev/xcl!1405
No description provided.