runtime: hand the executable a storage root that ends in a separator and is not cut off #1447
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1454"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-24T11:50:39Z.
Change
Two faults in how
X2W_STORAGE_PATHreaches a console executable as its persistent-local-storage root (storage_path()insrc/startup_stubs/runtime_proxy.cpp).No trailing separator. The executable appends names to the root as it is. The default
S:\ends in a separator, but a value such asD:\saves, which is whatrun.ps1 -StoragePath D:\savessets, was passed on unchanged. The executable then createdD:\savessettings\,D:\savescloudpers\andD:\savescloudcache\beside the folder it was given, and wrote its settings file there.64-byte buffer. The value was read with
GetEnvironmentVariableAintochar path[64]. For a longer value that call returns the size it needs and fills nothing, so the buffer stayed empty, the default was not applied either (the call's result is not zero), and the executable was handed an empty root.Now (
src/startup_stubs/storage_root.h):\or/gets a trailing\;S:\is used, instead of a cut-off or empty root;InitOnceExecuteOnce.The game-save stand-in builds its own path with
std::filesystemfrom the same root and is not affected by the added separator.What was measured
One console executable under the startup debugger, clang-cl build under Wine 11.0 with vkd3d-proton,
mainate84829de. Paths below are shortened to their last components.X2W_STORAGE_PATHmain...\storage(no separator)...\storagesettings\,...\storagecloudpers\,...\storagecloudcache\; settings file written to...\storagesettings\settings.xml\; the three folders are created inside the given folderThe 22 s runs with this PR do not reach the point where the settings file is written; only the folder creations were observed for it.
Tests
tests/startup_storage_root_check.cpp, without a process or a device:startup_storage_root_separator_controlruns the old rule (the value as it is) and must fail (WILL_FAIL).docs_links_check.pypasses.docs/startup-runtime.mdand therun.ps1parameter comment now state the rule.Not verified
S:\instorage_path()were not exercised in a run.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T12:06:48Z.
Review: COMMENTED
Dual-platform peer review at commit
daf09b2af2d5a935869b08d25e7452b886f0ad0b.Audit
src/startup_stubs/storage_root.h&src/startup_stubs/runtime_proxy.cpp:storage_root()handlesnullptr/empty input without modifyingout, preserves existing trailing\or/, appends\when missing, and rejects inputs whose length with separator reachesstorage_root_capacity(260), leavingoutuntouched.storage_path()usesInitOnceExecuteOncewith a261-byte stack buffer forGetEnvironmentVariableA, distinguishinglength >= sizeof(value)(logs character count vs258limit) fromlength && !storage_root(...)(e.g., 259-char value without trailing separator or 260-char value) and falling back to"S:\\".tests/startup_storage_root_check.cpprelies on<cstring>transitively viastorage_root.h, andstorage_path()'selse iflog message says "does not fit with its trailing separator" even if a 260-char value already has a trailing separator (accurate enough for diagnostics).git diff --check origin/main..HEAD: clean.python3 tests/docs_links_check.py: passed (16 Markdown files, 325 links).python3 tests/bidi_controls_check.py: passed.Verification on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)
--preset dev):cmake --build --preset dev --target startup_storage_root_check -- -j 6):3.44sctest --preset dev -R '^startup_storage_root' --parallel 4 --no-tests=error --output-on-failure): 2/2 passed (startup_storage_root0.02s,startup_storage_root_separator_control0.01s)/O2(--preset release):cmake --build --preset release --target startup_storage_root_check -- -j 6):0.79sctest --preset release -R '^startup_storage_root' --parallel 4 --no-tests=error --output-on-failure): 2/2 passed (startup_storage_root0.01s,startup_storage_root_separator_control0.01s)