mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:05:53 +01:00
[PR #688] [MERGED] OLD-9215: restore old upstream PR 9215 - file_system: RemoveDirectory and a create inside the folder are ordered as on the host #728
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#728
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/688
Author: @aslan2142
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/26/2026
Merged by: @aslan2142
Base:
main← Head:game-rmdir-create-race📝 Commits (1)
de8cb53file_system: RemoveDirectory and a create inside the folder are ordered as on the host📊 Changes
3 files changed (+113 additions, -1 deletions)
View changed files
📝
docs/runtime_imports.md(+3 -1)📝
runtime/shims/file_system.cpp(+40 -0)📝
runtime/test/file_system_test.cpp(+70 -0)📄 Description
Claimed in the coordination issue as: OLD-9215 https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7130909581
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).
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.