Repository navigation
runtime: preserve overlay files when deletion markers fail - #4885
illusionart453-max wants to merge 3 commits into
Conversation
|
APPROVE. Built The diff is correct: markers are prepared before Three non-blocking nits:
AI-assisted review, no game files. |
|
Tested b557671 on Windows 10.0.26200, MSVC 14.52 (Visual Studio 18 2026, x64, RelWithDebInfo): pass. Built and ran |
|
Thanks @tupacfan04. Follow-up 2598b855 addresses the diagnostics/documentation notes: the docs now state that the global mutation lock is held across copy/flush and can delay unrelated GAME: deletes/moves, and explain harmless empty marker-parent leftovers. A failed rollback DeleteFileW now reports its error while restoring the original operation's GetLastError. The ANSI replacement-move regression already includes MOVEFILE_WRITE_THROUGH at runtime/test/file_system_test.cpp:148; it was present in b557671. The fixture currently has no deterministic concurrency test, so I am keeping the serialization claim based on code inspection and the explicit process-wide mutex rather than presenting one as tested. Rebuilt with MSVC 19.44 /W4: 268 checks, 0 failures. Docs links 6 passed, text-line-ending tests 3 passed, git diff --check clean. CPU-only synthetic files, AI-assisted (Codex). |
|
[P1] |
|
Tested 2598b85 merged with main 3faac55 on native Windows (MSVC 14.51, RelWithDebInfo, Ninja) and Linux (docs tests only), Python 3.12.16 / 3.13.1: pass Windows: built file_system_test and ran ctest file_system: Passed (all checks in the new marker-failure and marker-rollback scenarios). Linux: all tests/test_docs_*.py pass (runtime_imports.md changes). |
|
@editrice, fixed in eb7b78b. The process mutex is now paired with a Windows byte-range lock on a persistent file inside the private copy directory, acquired before marker-state reads and held through rollback/commit. Processes opening the same overlay through different spellings share the same file lock; the file is kept in place rather than unlinked/recreated. The new child-process regression reproduces your interleaving for delete and move. Against 2598b85, the initial 292-check fixture gives four failures: B finishes while A owns the pending marker, and A's rollback exposes the package after B succeeded. Fixed: all 295 checks pass, including aliased overlay paths and lock-acquisition failure preserving both files. CTest file_system passes; docs/registration/line-ending checks pass, diff clean. No game files, CPU only, AI-assisted (Codex). |
|
Re-tested the current head
None of the runs left anything behind in the AI-assisted (Claude Code). |
|
Tested
AI-assisted (Claude Code). Synthetic files only, no game files. |
|
@illusionart453-max I independently rechecked the cross-process fix at The marker-mutating A/W entry points route through the three locked W implementations. The lock is acquired before marker/view reads and held through commit or rollback; lock acquisition failure precedes source/destination mutation. This resolves my reported race. My local |
|
Tested eb7b78b merged with main 3faac55 on native Windows 11 (MSVC 14.51, RelWithDebInfo, Ninja; This re-tests the cross-process lock head; my earlier comment (#4885 (comment)) was for 2598b85.
|
|
Verified statically on current main (3faac55, merges cleanly). The PendingMarker pattern is sound: process mutex plus the exclusive byte-range lock on the marker-lock file (persistent, never replaced), marker-before-destructive ordering in all three entry points (the ANSI variants and move_file_w delegate to the locked _w paths — verified), rollback deletes only a marker created by this operation, and GetLastError is preserved across the destructor's own calls. The new coverage (obstructed marker directory, rollback both ways, a real second process racing a different overlay spelling) targets exactly the failure mode described. The ctest file_system suite needs a Windows build and was not run here; on the Python side test_exe_checklist, test_pe_inspect and the docs guards all pass. CI reports no checks for this branch. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only review). |
|
@kapitche Verified the integration note: I merged the declared #4621 dependency and #4965 into a local review branch, keeping all test blocks and moving our marker/child-process checks after the API cases so they retain the intended configuration. The resulting file_system_test passes 360/360; no production conflict resolution was needed. This branch stays local, with our canonical PR unchanged. A targeted additional probe found a marker-preflight defect in #4965's new ReplaceFileW path, also reproduced on #4965 alone (211 checks / 5 failures). Report and test-only patch are on the owning PR: #4965 (review). The original #4885 test is restored and passes 295/295. AI-assisted, CPU only, no game files. |
ReplaceFile wrote the marker that hides a package replacement after the host's ReplaceFile had consumed the overlay copy, so a marker that couldn't be written failed the call after the replace was done, and the package's replacement became visible again under its name (the failure ItsNotRexed#4885 fixes for DeleteFile and MoveFile). The marker is now written after both copy-ups and before ReplaceFile, and removed again when ReplaceFile fails. file_system: 212 checks, 0 failures. Three new checks: an obstructed marker folder fails the call with nothing replaced (fails with the old order), the retry succeeds, and a refused ReplaceFile leaves no marker. ctest 151/151, docs tests 30/30. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested together with #4965, which adds Merge onto #4965: 2 conflicts, both mechanical. In
Three checks added: with the marker folder obstructed (your method), Results: AI-assisted (Claude Code). No game files used. |
ReplaceFile wrote the marker that hides a package replacement after the host's ReplaceFile had consumed the overlay copy, so a marker that couldn't be written failed the call after the replace was done, and the package's replacement became visible again under its name (the failure ItsNotRexed#4885 fixes for DeleteFile and MoveFile). The marker is now written after both copy-ups and before ReplaceFile, and removed again when ReplaceFile fails. file_system: 212 checks, 0 failures. Three new checks: an obstructed marker folder fails the call with nothing replaced (fails with the old order), the retry succeeds, and a refused ReplaceFile leaves no marker. ctest 151/151, docs tests 30/30. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Integration update at main 22037f7 + this PR: resolving source/test conflicts while preserving all checks gives 582 checks, initially 16 read-only failures. The merged DeleteFile code still uses if (!removed) for the package read-only test, but this PR moves the overlay deletion later, so removed is still false even when a writable overlay supplies the visible attributes. Checking !std::filesystem::exists(overlay_path, ec) instead restores the intended visible-overlay rule. Baseline then passes 582/582. This adjustment is committed in the local directory-over-file follow-up branch, which depends on #4885, alongside 46 new checks (628/628 final). Full configured CPU suite on that branch passes 104 tests, skips 7 game-input cases, disables GameInput, zero failures. Publishing the follow-up is awaiting workflow-scope reauthorization after GitHub rejected its newer upstream history. AI-assisted (Codex), Windows/MSVC 19.44, synthetic files only. |
A failed
GAME:delete or move could lose newer overlay contents: the old code removed the overlay source or replaced the destination before creating the marker that hides the original package file. Marker creation could then fail after those changes, exposing older packaged data despite reporting an operation failure.Required markers are now prepared before
DeleteFile*,RemoveDirectory*, or the file path ofMoveFile*changes the overlay. Failed host operations roll back only the attempt-created marker, retain pre-existing markers and preserve GetLastError. Rollback failures are reported. Write-through moves flush the marker before changing either file.Marker transactions hold the process mutex and an exclusive Windows byte-range lock on
<overlay>/.gta6rt-copy/.marker-lockbefore reading the marker state, through commit or rollback. Another process sharing the overlay therefore cannot adopt an uncommitted marker. Using the filesystem lock also handles different path spellings. The persistent private lock file is never replaced or deleted by the protocol. If locking fails, source/destination changes are refused. The lock is held across copies/flushes, which can delay other mutations; this tradeoff and harmless empty marker-parent leftovers are documented. See LockFileEx for the Windows locking/handle-close behavior.New RT item, ID pending: claim before implementation.
Validation on Windows 11, MSVC 19.44, Windows SDK 10.0.26100, RelWithDebInfo, head eb7b78b:
file_system_testwith/W4, no compiler warnings.file_systempassed (1/1).... On previous head 2598b85 these two scenarios produced 4 failures (292-check initial regression): B returned while A held the transaction and the package source reappeared after rollback.python -I tests/test_docs_links.py: 6 passed.python -I tests/test_text_write_line_endings.py: 3 passed.python -I tests/test_ctest_registration.py: 4 passed.git diff --check: clean.This handles reported filesystem failures and concurrent cooperating processes; it is not power-loss recovery or a general transactional filesystem. RT-240's default overlay location remains a maintainer decision. #3651 owns logical-parent checks/same-name moves, and #3489 owns delete-on-close opens.
CPU-only synthetic files; no game files or GPU used. Host GPU RTX 5060, driver 610.88. AI-assisted (Codex).