file_system: T:\ is a drive root for file calls; move and copy hold the folder lock (RT-FS-OVERLAY-ROOT-LOCK-LONGPATH) #2534
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2534
Loading…
Reference in a new issue
No description provided.
Delete branch "claude/fs-overlay-root-lock-longpath"
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 successfully merged and closed
Claimed in the coordination issue as: RT-FS-OVERLAY-ROOT-LOCK-LONGPATH (claim: https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7231487470). Found by @kevincommits, item 2 of https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7231276991. Thanks!
What and why
Three fixes to the
GAME:/T:overlay inruntime/shims/file_system.cpp:T:\slipped past the root checks.parse_console(L"T:\\")gives the scratch folder's parts (.gta6rt-temp,<run>), not an empty list.RemoveDirectoryandMoveFileExalready usedrive_root()for that, but the write-open (write_target),DeleteFileW, the copy destination andSetFileAttributesWonly checkedparts.empty(). SoSetFileAttributesW(T:\)changed the host scratch folder's attributes, and a write-open ofT:\was not refused. All four now usedrive_root()and giveT:\the same error they giveGAME:\(ERROR_INVALID_NAME, orERROR_ACCESS_DENIEDfor attributes).CreateDirectoryholdfolder_lock(parent)from "does the folder exist" to the host call that makes the entry, so a concurrentRemoveDirectoryof that folder comes wholly before or after (the comment atg_folder_locks).MoveFileExandcopy_destination(CopyFileW,CopyFileExW,CopyFile2) did not, so the remove-then-resurrect race stayed open for them. Now:MoveFileExholds the lock from its destination checks to the host move.copy_destinationtakes it before its checks and hands it to the caller, which holds it through the host copy.CopyFileExWwithprogress,CopyFile2withpProgressRoutine) keeps the old behaviour. The routine is the title's code, and nothing that holds a folder lock may call back into the title (the same comment). A routine that touched a folder in the same lock stripe would otherwise deadlock.CreateDirectory. Recreating a removed folder deletes its marker withstd::filesystem::remove(marker(...) / kRemovedDirMarker)and nowin32_io_path(), unlike every other marker access. On a host without long path support, a marker beyondMAX_PATHcannot be removed, and the new folder is rolled back. It now goes throughwin32_io_path().Tested
file_system_test(CPU only, synthetic package and overlay folders, no game data):T:\root cases:SetFileAttributesWis refused and the host folder is not hidden;DeleteFileW, aGENERIC_WRITEopen andCopyFileWontoT:\areERROR_INVALID_NAME. Onmainall 4 fail; with the fix the whole test passes (544 checks, 0 failures).CreateDirectoryWrecreates a removed folder whose marker lies beyondMAX_PATH, and the folder is listed again. It also passes onmainon this machine, because long path support is on here (LongPathsEnabled = 1), so it does not show the bug; it keeps the path covered.RemoveDirectoryto land between the check and the host call, which a test cannot place reliably. The existing move, copy andCopyFile2cases all pass with the lock held.GPUs tested: n/a (CPU test).
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).MoveFileExa few lines above the new lock; whichever lands second needs a small merge there. No other open PR touches these lines.🤖 Generated with Claude Code
Reviewed at head
11b63a53bon Windows 11 (MSVC 202219.44).Verification
file_system_test.file_system_test: 544/544 checks passed (including the 2,000-round create/remove directory concurrency checks).Notes (non-blocking)
T:\(file_system.cpp:249-266,310-313,531,1136-1139,1389-1390,1563), extended-length marker cleanup (1213-1220), and holding the destination folder lock across ordinary moves and callback-free copies while dropping it around title progress callbacks (1319-1455,1543-1551) all look solid.file_system_test.cpp:939-997,1437-1456): Consider adding the sameRemoveDirectoryWrace test forMoveFileExWand callback-freeCopyFileW/CopyFileExW/CopyFile2against removal of the destination parent to directly pin the new lock scope.file_system.cpp:1297-1335,1394-1411): Renaming an overlay-only source directory only locks the new parent stripe, so a concurrent copy into that directory can still race a rename; noted as pre-existing and outside this PR'sRemoveDirectoryWscope.Approve.
AI-assisted review + local MSVC verification.
#2534 | head 11b63a53b02c52e1bd17038c15b3ba69f9473f98 (merged cleanly with main 6dfca642807631bbe41d6925f152529f99c71ce2) |
ctest --test-dir runtime/build -C RelWithDebInfo -R "^file_system$" --output-on-failure| red on main:file_system_testfails (544 check(s), 4 failure(s):SetFileAttributesW(T:\),DeleteFileW(T:\), write-openCreateFileW(T:\), andCopyFileWontoT:\treatedT:\as its per-process host folder rather than a drive root becausepartswas non-empty) | green on PR+main:1/1CTest passes (file_system544/544checks in17.10s, coveringT:\drive-root refusal, destinationfolder_lockserialization acrossMoveFileExW/CopyFile*, and extended-length> MAX_PATH.leonida_removed_dirmarker cleanup onCreateDirectoryW);check_no_game_data.py0violations | Windows 11, RTX 3090 (610.88), Vulkan SDK 1.4.363.1 | AI-assisted: yesVerified by OreoFR
c1ecf04ed+ PR head11b63a53b; green run in a merge package of 11 PRs, no new ctest failure vs mainctest -R "^file_system$"AI-assisted (Claude Code, Claude Opus 5.5).
Tested
11b63a53bmerged (no commit) withmainaa918e5d9. GPUs tested: NVIDIA GeForce RTX 3080, driver 621.40, Windows 11 10.0.26300; MSVC 19.52 (Visual Studio 18), RelWithDebInfo, Ninja.file_systempasses.runtime/shims/file_system.cppback tomain,file_systemfails 4 of its 544 checks, all on theT:\root:SetFileAttributesW(T:\) is refused (ERROR_ACCESS_DENIED) and leaves the host folder aloneDeleteFileW(T:\) is ERROR_INVALID_NAME, as for GAME:\a write-open of T:\ is ERROR_INVALID_NAME, as for GAME:\CopyFileW onto T:\ is ERROR_INVALID_NAME, as onto GAME:\mainfor the move/copy folder-lock half. The race rounds only printNOTEcounts (both succeeded 0onmainhere), so that half is not pinned by a failing test.No blocker from my side. AI-assisted (Claude Code).
Merged after TheGeogeo's red/green check (check: green with this PR, red with
main's code, no regression over the relinked tests) and a re-check here: no conflict withmaine6bd9943f, same head as checked,no-game-datagreen, and the only ctest failures in the Windows/macOS CI jobs are tests this diff does not touch (known onmainor Vulkan: vk_xdxr_postbuild_readback vk_bindless_dimensions d3d12_compile_pool xbox_present ). The Python jobs fail onmaintoo.AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.