hle(dstorage): clean up WALLS_FILES on File drop and fix open_file checks #3145

Open
github-bot wants to merge 1 commit from github-bot/gh-3145 into main AGit
Owner

@⁠RanoGames on GitHub · 2026-11-29 20:17 UTC · original
RanoGames:fix/dstorage-walls-files-and-open-file → main · +38 −4 · 1 files · 1 commits · open

What it changes

Fixes three issues in open_file and File in crates/victory-hle/src/modules/dstorage.rs:

  • open_file previously pushed (file as usize, kept) into WALLS_FILES, while release::<File> never removed the entry when the File instance was dropped — causing unbounded growth and stale-address aliasing if a new File was later allocated at the same address. Added walls_key: usize and impl Drop for File to remove the entry from WALLS_FILES.
  • Added an early out.is_null() check in open_file before calling CreateFileW / allocating Instance<File> so E_INVALIDARG does not leak the handle or object.
  • Captured std::io::Error::last_os_error() immediately after CreateFileW before allocating name via String::from_utf16_lossy.
  • Added unit test modules::dstorage::tests::open_file_cleans_up_walls_files_on_release_and_rejects_null_out.

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): N/A (unit-tested DirectStorage HLE fix)
  • Before: releasing a File left its address in WALLS_FILES, out == NULL leaked an open File, and last_os_error() ran after String::from_utf16_lossy.
  • After: Drop for File removes the WALLS_FILES entry, out == NULL returns E_INVALIDARG upfront, and last_os_error() is captured immediately after CreateFileW.
  • For shader changes, the wave sizes tested (32 and/or 64 lanes): N/A
  • cargo test passed for the crates it touches: yes (cargo test --locked -p victory-hle --lib -- modules::dstorage::tests: 29 passed, 0 failed, 2 ignored; cargo xtask policy --staged passed)

Checked for overlap

  • I searched the open and closed pull requests for WALLS_FILES (0 PRs).
**@⁠RanoGames** on GitHub · 2026-11-29 20:17 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3145) `RanoGames:fix/dstorage-walls-files-and-open-file` → `main` · +38 −4 · 1 files · 1 commits · open ## What it changes Fixes three issues in `open_file` and `File` in `crates/victory-hle/src/modules/dstorage.rs`: - `open_file` previously pushed `(file as usize, kept)` into `WALLS_FILES`, while `release::<File>` never removed the entry when the `File` instance was dropped — causing unbounded growth and stale-address aliasing if a new `File` was later allocated at the same address. Added `walls_key: usize` and `impl Drop for File` to remove the entry from `WALLS_FILES`. - Added an early `out.is_null()` check in `open_file` before calling `CreateFileW` / allocating `Instance<File>` so `E_INVALIDARG` does not leak the handle or object. - Captured `std::io::Error::last_os_error()` immediately after `CreateFileW` before allocating `name` via `String::from_utf16_lossy`. - Added unit test `modules::dstorage::tests::open_file_cleans_up_walls_files_on_release_and_rejects_null_out`. ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): N/A (unit-tested DirectStorage HLE fix) - Before: releasing a `File` left its address in `WALLS_FILES`, `out == NULL` leaked an open `File`, and `last_os_error()` ran after `String::from_utf16_lossy`. - After: `Drop for File` removes the `WALLS_FILES` entry, `out == NULL` returns `E_INVALIDARG` upfront, and `last_os_error()` is captured immediately after `CreateFileW`. - For shader changes, the wave sizes tested (32 and/or 64 lanes): N/A - `cargo test` passed for the crates it touches: yes (`cargo test --locked -p victory-hle --lib -- modules::dstorage::tests`: 29 passed, 0 failed, 2 ignored; `cargo xtask policy --staged` passed) ## Checked for overlap - [x] I searched the open and closed pull requests for `WALLS_FILES` (0 PRs).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 20:18:31 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3145/head:github-bot/gh-3145'
git switch 'github-bot/gh-3145'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3145'
git switch 'github-bot/gh-3145'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3145'
git switch 'github-bot/gh-3145'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3145'
git switch 'main'
git merge --squash 'github-bot/gh-3145'
git switch 'main'
git merge --ff-only 'github-bot/gh-3145'
git switch 'main'
git merge 'github-bot/gh-3145'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!3145
No description provided.