DirectStorage: walls trace file list only with the trace on; compressed bytes freed once inflated #375

Open
github-bot wants to merge 1 commit from github-bot/gh-375 into a-publier AGit
Owner

@⁠Esteban-V on GitHub · 2026-11-26 22:50 UTC · original
Esteban-V:fix/dstorage-small-leaks → a-publier · +8 −2 · 1 files · 1 commits · open

Two small leaks in the DirectStorage module (crates/victory-hle/src/modules/dstorage.rs). open_file pushed every opened file into WALLS_FILES (dstorage.rs:157), but only the walls trace (VICTORY_WALLS_TRACE) reads that list, and nothing ever removed entries. In the zlib + BCPack path (dstorage.rs:1413), the compressed source buffer was shadowed rather than dropped, so it stayed allocated while BCPack unpacked. This fixes both.

  • WALLS_FILES is now filled only when the walls trace is on.
  • The lookup in walls_request searches from the back, so an object address reused by a later open names the newest file.
  • The compressed source buffer is dropped right after inflating.
  • No behaviour change. The payoff is small: a path per open, and one compressed buffer per in-flight request.

Already merged in DoubleGhosty/cool_fox (a96549d).

Testing

  • Windows CI (windows-latest): Clippy, default tests and diagnostics tests pass (run).
  • Type-checked and clippy-clean for x86_64-pc-windows-msvc on a macOS host (cargo clippy --workspace --all-targets -- -D warnings, default features and --all-features).
**@⁠Esteban-V** on GitHub · 2026-11-26 22:50 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/375) `Esteban-V:fix/dstorage-small-leaks` → `a-publier` · +8 −2 · 1 files · 1 commits · open Two small leaks in the DirectStorage module (`crates/victory-hle/src/modules/dstorage.rs`). `open_file` pushed every opened file into `WALLS_FILES` (`dstorage.rs:157`), but only the walls trace (`VICTORY_WALLS_TRACE`) reads that list, and nothing ever removed entries. In the zlib + BCPack path (`dstorage.rs:1413`), the compressed `source` buffer was shadowed rather than dropped, so it stayed allocated while BCPack unpacked. This fixes both. - `WALLS_FILES` is now filled only when the walls trace is on. - The lookup in `walls_request` searches from the back, so an object address reused by a later open names the newest file. - The compressed `source` buffer is dropped right after inflating. - No behaviour change. The payoff is small: a path per open, and one compressed buffer per in-flight request. Already merged in DoubleGhosty/cool_fox (a96549d). ## Testing - Windows CI (`windows-latest`): Clippy, default tests and diagnostics tests pass ([run](https://github.com/Esteban-V/VIctory-Belobug-AMD/actions/runs/45916906258)). - Type-checked and clippy-clean for `x86_64-pc-windows-msvc` on a macOS host (`cargo clippy --workspace --all-targets -- -D warnings`, default features and `--all-features`).
open_file added every file's path to WALLS_FILES, which only the walls
trace (VICTORY_WALLS_TRACE) reads, and nothing ever took them out. The
list is now filled only with the trace on, and the trace looks it up
from the back, so an object address used again names the file opened
last instead of the first one.

A request that is zlib then BCPack kept its compressed source alive
next to the inflated bytes until it was done; the source is now dropped
once inflated. Nothing the title sees changes.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:58:45 +00:00
Author
Owner

@⁠lvndrpup on GitHub · 2026-11-27 05:25 UTC · original · reviewed

A native Windows run, beside your CI run and the macOS check, at b1fb923 on Windows 11 build 26300, Rust 1.98.1, debug:

  • cargo test -p victory-hle: 165 passed, 0 failed (dstorage alone: 18 passed, 1 ignored).
  • cargo clippy -p victory-hle --all-targets -- -D warnings: clean, with and without --all-features.

I also checked the two points the change rests on:

  • walls_request returns at once when walls_trace() is 0 (dstorage.rs:672), and walls_trace() is read once per process (OnceLock). So leaving WALLS_FILES empty without the trace loses nothing.
  • source is the Cow<'static, [u8]> from read_source. For a file it is the owned read buffer, so the new drop frees it before BCPack runs; for a memory source it is borrowed and the drop does nothing.
**@⁠lvndrpup** on GitHub · 2026-11-27 05:25 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/375#pullrequestreview-6083848390) · **reviewed** A native Windows run, beside your CI run and the macOS check, at `b1fb923` on Windows 11 build 26300, Rust 1.98.1, debug: - `cargo test -p victory-hle`: 165 passed, 0 failed (`dstorage` alone: 18 passed, 1 ignored). - `cargo clippy -p victory-hle --all-targets -- -D warnings`: clean, with and without `--all-features`. I also checked the two points the change rests on: - `walls_request` returns at once when `walls_trace()` is 0 (`dstorage.rs:672`), and `walls_trace()` is read once per process (`OnceLock`). So leaving `WALLS_FILES` empty without the trace loses nothing. - `source` is the `Cow<'static, [u8]>` from `read_source`. For a file it is the owned read buffer, so the new `drop` frees it before BCPack runs; for a memory source it is borrowed and the drop does nothing.
Author
Owner

@⁠Esteban-V on GitHub · 2026-11-27 14:34 UTC · original

Thanks for running it natively, and for checking the OnceLock and the borrowed case. That's the part I most wanted another pair of eyes on.

**@⁠Esteban-V** on GitHub · 2026-11-27 14:34 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/375#issuecomment-7220951238) Thanks for running it natively, and for checking the `OnceLock` and the borrowed case. That's the part I most wanted another pair of eyes on.
This pull request can be merged automatically.
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/375/head:github-bot/gh-375'
git switch 'github-bot/gh-375'

Merge

Merge the changes and update on Forgejo.
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-375'
git switch 'github-bot/gh-375'
git rebase 'a-publier'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-375'
git switch 'github-bot/gh-375'
git rebase 'a-publier'
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-375'
git switch 'a-publier'
git merge --squash 'github-bot/gh-375'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-375'
git switch 'a-publier'
git merge 'github-bot/gh-375'
git push origin 'a-publier'
This discussion has been locked. Commenting is limited to contributors.
No description provided.