OLD-9215: restore old upstream PR 9215 - file_system: RemoveDirectory and a create inside the folder are ordered as on the host #688
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!688
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/688/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@aslan2142 on GitHub · 2026-11-24 12:07 UTC · original
aslan2142:game-rmdir-create-race→main· +113 −1 · 3 files · 1 commits · merged 2026-11-25 23:00 UTCClaimed in the coordination issue as: OLD-9215 #14
Restoration of my original pull request, old upstream PR 9215 in
ItsNotRexed/Leonida, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Ported onto main at21625bca8; the write-open keeps main's long-pathdisk_path()for its overlay path, and the new race test sits after main's tests that recreate a removed package folder. Nothing else changed from the original.What and why
GAME:write-open orCreateDirectory*inside a folder could run its "does the folder exist" check, and then aRemoveDirectory*of that folder on another thread could run its emptiness check and write its marker. No lock covered either step.ERROR_PATH_NOT_FOUND, or the remove withERROR_DIR_NOT_EMPTY.std::mutex(no function-local static).write_targetholds the lock of the folder it opens in, from the parent check until theTargetis gone after the hostCreateFile/CreateFile2.CreateDirectory*holds the parent's lock from its check to the host call, which includes main's marker clean-up.RemoveDirectory*holds the folder's lock from its view to the marker.file_system_testraces the two calls on two threads, 2,000 rounds for a creatingCreateFileW(CREATE_NEW,CREATE_ALWAYS,OPEN_ALWAYS) and 2,000 forCreateDirectoryW. It checks three things: the two never both succeed, the loser fails with the host's error, and a removed folder stays removed.docs/runtime_imports.mddescribes the ordering.CreateDirectoryof a removed package folder X racingRemoveDirectoryof X itself. Main'sCreateDirectorydeletes X's removal marker after it makes the overlay folder, and a remove in between leaves X visible again although both calls succeeded.Tested
Linux, Wine 11.22 (Staging),
file_system_testbuilt with clang 23 forx86_64-w64-mingw32. MSVC/W4 /permissive-is left to CI.21625bca8: 494 checks, 11 failures.MAXIMUM_ALLOWEDopens, long paths, and the hostReadFileERROR_NOACCESSprobe.CreateFileW: both calls succeeded in 1,972 of 2,000 rounds.CreateDirectoryW: both calls succeeded in 1,012 of 2,000 rounds.CreateFileW: create first 1,964, remove first 36, both 0.CreateDirectoryW: remove first 2,000, both 0.git diff --checkis clean, andpython -I scripts/check_no_game_data.pypasses on the three changed files.git merge-treeshows no conflict with the other open pull requests that touchfile_system.cpp: #684, #400, #317, #287, #271 and #115.GPUs tested: n/a
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.AI-assisted (Claude Code, Claude Opus 5.5).
@abnalstlll-byte on GitHub · 2026-11-24 12:18 UTC · original · approved these changes
Technical Review: APPROVE (OLD-9215)
Concurrency Correctness:
Clean-Room & Verification:
21625bca8(0 conflicts).LGTM!
@aslan2142 on GitHub · 2026-11-25 23:00 UTC · original
Merged:
file_systemordersRemoveDirectoryand a create inside the folder as on the host.mainand with #684, and no review point is open.main5fab93967with all nine of these runtime PRs merged together (#634, #643, #684, #657, #677, #638, #710, #688, #671), on llvmpipe and the gfx1036 iGPU (RADV): no test went from pass to fail.file_systemfails only on theBCryptOpenAlgorithmProvidercheck, as on the baseline.maind4681041e+de8cb53d5: it merges cleanly; the semantic suite passes (493 files, 6,318 tests, 0 files failed); the 15 docs and writer tests pass;check_no_game_data.pyis clean on the 3 changed files.AI-assisted (Claude Code, Claude Opus 5.5).
latencyframes in flight while armed (mailbox replace) #671