Windows SMB: shader disk-cache retained-reader replacement fails; local NTFS passes #10833

Closed
opened 2026-10-25 03:36:14 +00:00 by Amoenus · 0 comments
Amoenus commented 2026-10-25 03:36:14 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-25T03:36:14Z.


Resolved on main via #11434, merge a453b29ebe4b. The selected contract is now in main: atomic production replacement semantics remain; affected retained-reader/mapped-replacement test subcases are omitted only when the filesystem POSIX-rename probe reports error87, and the SMB limitation is documented. This does not add atomic SMB replacement support. Our original real-NAS reproduction remains historical; we have not independently retested the merged change on that NAS. AI-assisted report maintenance: yes (Codex).

Maintainer decision and existing candidate — 26 October 2026

MarcZX10 selected option 1: retain atomic production replacement semantics, document the SMB limitation, and omit only retained-reader replacement assertions when the POSIX rename probe specifically returns ERROR_INVALID_PARAMETER (87). Other replacement failures must remain failures. The rename-aside approach is not accepted because it introduces a missing-path window.

Existing candidate: #11434 by @LeandroLP23, reviewed here at head b95b22cf162225e99d1cb88735e946c32757adc6. Its source extracts the existing Windows POSIX rename operation, checks error 87 in a synthetic filesystem probe, records the limitation, and conditionally omits affected mapped/retained-reader replacement subcases. This is partial subcase coverage, not a claim that SMB supports atomic replacement or that every assertion ran. The patch also corrects extended UNC test paths. We are tracking that contribution rather than implementing a duplicate.

The author's reported NTFS/loopback-SMB runs and GPU cache checks are in #11434; they are independent evidence, not runs performed by us. Our real-NAS reproduction below remains source-pinned historical evidence; we have not independently qualified this candidate on that NAS. Keep this issue open until the accepted change is merged and its remaining scope is clear. The unrelated long-path report #7452 has been closed after its own focused verification.

AI-assisted report maintenance: yes (Codex).

Previous evidence and source-pinned history

What happens

agc_shader_disk_cache fails with cannot replace cache entry with a retained reader when its temporary directory is on the tested Windows-mapped NAS share. The same executable passes when only TEMP/TMP are changed to local NTFS storage.

Title, test or build step

CPU-only CTest agc_shader_disk_cache, specifically verifyAtomicReplacement. No game dump or GPU is needed.

AnyPS5 commit

Executed integration: 29a63ec975692203def21882bfd3f279639bea16, based on main bd8e13428a10d9332c2911816ab672ea1b41418f, with our retained Sonic integration changes. This is not an execution of unchanged main.

The complete production ShaderCacheDirectory.hpp is byte-identical to checked main 390e44c7893c386cec76834152d54570c15df318 (Git blob 9b3893ce2a3d1c403550368f3ce132dfac0550c2). The verifyAtomicReplacement function also matches the integration's base main. A separate minimal program including the actual production header reproduces the difference with synthetic three-/four-byte entries; no AnyPS5 replacement runtime libraries are linked into that probe.

System

Windows 11 Enterprise, build 26200; WinLibs MinGW-w64 GCC 15.2.0/UCRT r7. One local NTFS directory and one writable NAS share mapped as P:. Exact server/filesystem feature support and the failing Windows API/error code have not been determined. GPU/driver: not exercised by this CPU-only check.

Steps to reproduce

Build the real agc_shader_disk_cache_tests target with testing enabled. Use existing writable short temporary directories on the two storage locations, and run from the same shell against the same build:

$env:TEMP = 'P:\tmp'
$env:TMP = $env:TEMP
ctest --test-dir <build> -R '^agc_shader_disk_cache$' -V --output-on-failure

$env:TEMP = 'C:\aps5-test-temp'
$env:TMP = $env:TEMP
ctest --test-dir <build> -R '^agc_shader_disk_cache$' -V --output-on-failure

The executable and build remain unchanged between runs. The failing case completes in 0.56 seconds, within the 30-second CTest timeout. This is the ordinary cache test, not its optional large-file case.

Log

Start 678: agc_shader_disk_cache
678: cannot replace cache entry with a retained reader
1/1 Test #678: agc_shader_disk_cache ............***Failed    0.56 sec
0% tests passed, 1 tests failed out of 1

What was checked

Check Local NTFS Tested mapped NAS share
Existing CTest, identical executable Pass Fail at retained-reader replacement
Direct production-header probe, fresh entries Replacement succeeds 3/3 Replacement returns false 3/3
Retained reader still sees original bytes 3/3 3/3
Published path has coherent contents Replacement bytes 3/3 Original bytes 3/3

The probe opens the retained reader with GENERIC_READ and FILE_SHARE_READ | FILE_SHARE_DELETE, matching the fixture, then calls WriteFileAtomically to replace the existing entry. It preserves the original reader and independently reads the published path. No corruption was observed.

CTest executable SHA-256 before/after the storage control: e637cddb5cabb3497e7e635c7b0fbed660698dbc6947de1f497fb940d59e5467.

Related merged #3660 introduced the retained-reader replacement behavior and explicitly did not test the unsupported-filesystem fallback. #5552 concerns delete sharing. Open #7452 concerns long paths; this report uses short paths and isolates replacement while a reader remains open. Searches for the exact error, WriteFileAtomically, FileRenameInfoEx, retained readers, NTFS/SMB and cache replacement found no matching open report.

This establishes a compatibility/test limitation on the tested share, not a general claim that every SMB server fails, a regression introduction, a Sonic startup blocker, or an FPS effect. A local NTFS temporary/cache directory passes this check. It remains to establish the underlying API failure and whether network-filesystem cache replacement should be supported or explicitly documented as unsupported; no non-atomic replacement or relaxed assertion is proposed.

AI-assisted: yes (Codex).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6020498079 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/10833). Originally posted by [Amoenus](https://github.com/Amoenus) on 2026-10-25T03:36:14Z. --- <!-- codex-resolved-main-20261027-10833 --> **Resolved on main via #11434**, merge [`a453b29ebe4b`](https://github.com/boykopovar/AnyPS5/commit/a453b29ebe4b4c6288b163311b436e51ae5df643). The selected contract is now in main: atomic production replacement semantics remain; affected retained-reader/mapped-replacement test subcases are omitted only when the filesystem POSIX-rename probe reports error87, and the SMB limitation is documented. This does not add atomic SMB replacement support. Our original real-NAS reproduction remains historical; we have not independently retested the merged change on that NAS. AI-assisted report maintenance: yes (Codex). <!-- /codex-resolved-main-20261027-10833 --> <!-- codex-sweep-20261026-10833 --> ## Maintainer decision and existing candidate — 26 October 2026 [MarcZX10 selected option 1](https://github.com/boykopovar/AnyPS5/issues/10833#issuecomment-6416074062): retain atomic production replacement semantics, document the SMB limitation, and omit only retained-reader replacement assertions when the POSIX rename probe specifically returns `ERROR_INVALID_PARAMETER` (87). Other replacement failures must remain failures. The rename-aside approach is not accepted because it introduces a missing-path window. **Existing candidate: #11434 by @LeandroLP23**, reviewed here at head `b95b22cf162225e99d1cb88735e946c32757adc6`. Its source extracts the existing Windows POSIX rename operation, checks error 87 in a synthetic filesystem probe, records the limitation, and conditionally omits affected mapped/retained-reader replacement subcases. This is partial subcase coverage, not a claim that SMB supports atomic replacement or that every assertion ran. The patch also corrects extended UNC test paths. We are tracking that contribution rather than implementing a duplicate. The author's reported NTFS/loopback-SMB runs and GPU cache checks are in #11434; they are independent evidence, not runs performed by us. Our real-NAS reproduction below remains source-pinned historical evidence; we have not independently qualified this candidate on that NAS. Keep this issue open until the accepted change is merged and its remaining scope is clear. The unrelated long-path report #7452 has been closed after its own focused verification. AI-assisted report maintenance: yes (Codex). <!-- /codex-sweep-20261026-10833 --> <details> <summary>Previous evidence and source-pinned history</summary> ### What happens `agc_shader_disk_cache` fails with `cannot replace cache entry with a retained reader` when its temporary directory is on the tested Windows-mapped NAS share. The **same executable** passes when only `TEMP`/`TMP` are changed to local NTFS storage. ### Title, test or build step CPU-only CTest `agc_shader_disk_cache`, specifically `verifyAtomicReplacement`. No game dump or GPU is needed. ### AnyPS5 commit Executed integration: [`29a63ec975692203def21882bfd3f279639bea16`](https://github.com/Amoenus/AnyPS5/commit/29a63ec975692203def21882bfd3f279639bea16), based on main `bd8e13428a10d9332c2911816ab672ea1b41418f`, with our retained Sonic integration changes. This is **not an execution of unchanged main**. The complete production `ShaderCacheDirectory.hpp` is byte-identical to checked main `390e44c7893c386cec76834152d54570c15df318` (Git blob `9b3893ce2a3d1c403550368f3ce132dfac0550c2`). The `verifyAtomicReplacement` function also matches the integration's base main. A separate minimal program including the actual production header reproduces the difference with synthetic three-/four-byte entries; no AnyPS5 replacement runtime libraries are linked into that probe. ### System Windows 11 Enterprise, build 26200; WinLibs MinGW-w64 GCC 15.2.0/UCRT r7. One local NTFS directory and one writable NAS share mapped as `P:`. Exact server/filesystem feature support and the failing Windows API/error code have **not** been determined. GPU/driver: not exercised by this CPU-only check. ### Steps to reproduce Build the real `agc_shader_disk_cache_tests` target with testing enabled. Use existing writable short temporary directories on the two storage locations, and run from the same shell against the same build: ```powershell $env:TEMP = 'P:\tmp' $env:TMP = $env:TEMP ctest --test-dir <build> -R '^agc_shader_disk_cache$' -V --output-on-failure $env:TEMP = 'C:\aps5-test-temp' $env:TMP = $env:TEMP ctest --test-dir <build> -R '^agc_shader_disk_cache$' -V --output-on-failure ``` The executable and build remain unchanged between runs. The failing case completes in 0.56 seconds, within the 30-second CTest timeout. This is the ordinary cache test, not its optional large-file case. ### Log ```text Start 678: agc_shader_disk_cache 678: cannot replace cache entry with a retained reader 1/1 Test #678: agc_shader_disk_cache ............***Failed 0.56 sec 0% tests passed, 1 tests failed out of 1 ``` ### What was checked | Check | Local NTFS | Tested mapped NAS share | |---|---|---| | Existing CTest, identical executable | Pass | Fail at retained-reader replacement | | Direct production-header probe, fresh entries | Replacement succeeds 3/3 | Replacement returns false 3/3 | | Retained reader still sees original bytes | 3/3 | 3/3 | | Published path has coherent contents | Replacement bytes 3/3 | Original bytes 3/3 | The probe opens the retained reader with `GENERIC_READ` and `FILE_SHARE_READ | FILE_SHARE_DELETE`, matching the fixture, then calls `WriteFileAtomically` to replace the existing entry. It preserves the original reader and independently reads the published path. No corruption was observed. CTest executable SHA-256 before/after the storage control: `e637cddb5cabb3497e7e635c7b0fbed660698dbc6947de1f497fb940d59e5467`. Related merged #3660 introduced the retained-reader replacement behavior and explicitly did not test the unsupported-filesystem fallback. #5552 concerns delete sharing. Open #7452 concerns long paths; this report uses short paths and isolates replacement while a reader remains open. Searches for the exact error, `WriteFileAtomically`, `FileRenameInfoEx`, retained readers, NTFS/SMB and cache replacement found no matching open report. This establishes a compatibility/test limitation on the tested share, not a general claim that every SMB server fails, a regression introduction, a Sonic startup blocker, or an FPS effect. A local NTFS temporary/cache directory passes this check. It remains to establish the underlying API failure and whether network-filesystem cache replacement should be supported or explicitly documented as unsupported; no non-atomic replacement or relaxed assertion is proposed. AI-assisted: yes (Codex). </details>
Sign in to join this conversation.
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
boykopovar/AnyPS5#10833
No description provided.