Isolate the game-save and Bink test scratch directories #1952

Open
github-bot wants to merge 2 commits from github-bot/gh-1952 into main AGit
Owner

@⁠lgr123 on GitHub · 2026-11-25 16:34 UTC · original
lgr123:runtime-scratch-isolation → main · +56 −20 · 7 files · 2 commits · open

Claimed as RT-ISOLATE-GAMESAVE-AND-BINK-SCRATCH in #1608, following the report's three residual sites.

Four concurrent game-save test processes sharing one temporary base exposed the race on Windows x64. Over three batches, public main failed 12 of 12 runs. This patch passed 12 of 12, with 76 checks per run and no leftover game-save scratch directories.

Two invocations using the same temporary base can delete or overwrite one another’s files. Game-save now uses the existing per-process RAII scratch directory, including on early returns. Bink audio and decode use per-process paths and clean them up on normal or handled-failure exit. Set LEONIDA_KEEP_BINK_OUTPUT=1 to retain diagnostics and print their folder. This patch stays scoped to the three remaining fixed names.

Reviewer check

Build the xgameruntime_gamesave_test CMake target, then start four copies at once with TEMP and TMP pointing to the same disposable folder. Let each process use an independent output log. Repeat on main and this branch. This test uses synthetic saves and needs no retail files.

Independent Windows verification passed 12 of 12 concurrent runs alongside #1579 after resolving the three overlapping lines. It also identified that Bink diagnostic folders would accumulate. The follow-up addresses retention with scoped cleanup and an explicit opt-in.

Tested

  • Windows x64, MSVC, public main 9e7720c. Built the actual synthetic game-save executable. Ran three batches of four simultaneously active processes sharing one disposable temporary base.
  • Public main failed 12 of 12 processes. The patched test passed 12 of 12, with 76 checks and zero failures in every process and no remaining scratch directories.
  • Both Bink test translation units compiled. Movie-dependent test paths were not run. Both Bink test files compiled again after the retention change. Synthetic cleanup and opt-in retention passed with default temp, an explicit LEONIDA_TEST_DIR, and cwd fallback with #1579's temp helper.
  • git diff --check and the source-only check passed. No game files were used.

GPUs tested: n/a.

AI-assisted: yes.

**@⁠lgr123** on GitHub · 2026-11-25 16:34 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1952) `lgr123:runtime-scratch-isolation` → `main` · +56 −20 · 7 files · 2 commits · open Claimed as `RT-ISOLATE-GAMESAVE-AND-BINK-SCRATCH` in [#1608](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608), following the report's [three residual sites](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608). Four concurrent game-save test processes sharing one temporary base exposed the race on Windows x64. Over three batches, public main failed **12 of 12** runs. This patch passed **12 of 12**, with 76 checks per run and no leftover game-save scratch directories. Two invocations using the same temporary base can delete or overwrite one another’s files. Game-save now uses the existing per-process RAII scratch directory, including on early returns. Bink audio and decode use per-process paths and clean them up on normal or handled-failure exit. Set `LEONIDA_KEEP_BINK_OUTPUT=1` to retain diagnostics and print their folder. This patch stays scoped to the three remaining fixed names. ### Reviewer check Build the `xgameruntime_gamesave_test` CMake target, then start four copies at once with `TEMP` and `TMP` pointing to the same disposable folder. Let each process use an independent output log. Repeat on main and this branch. This test uses synthetic saves and needs no retail files. [Independent Windows verification](https://git.gtahub.st/github/ubiquitarianism--leonida/pulls/1952) passed 12 of 12 concurrent runs alongside #1579 after resolving the three overlapping lines. It also identified that Bink diagnostic folders would accumulate. The follow-up addresses retention with scoped cleanup and an explicit opt-in. ### Tested - Windows x64, MSVC, public main `9e7720c`. Built the actual synthetic game-save executable. Ran three batches of four simultaneously active processes sharing one disposable temporary base. - Public main failed 12 of 12 processes. The patched test passed 12 of 12, with 76 checks and zero failures in every process and no remaining scratch directories. - Both Bink test translation units compiled. Movie-dependent test paths were not run. Both Bink test files compiled again after the retention change. Synthetic cleanup and opt-in retention passed with default temp, an explicit LEONIDA_TEST_DIR, and cwd fallback with #1579's temp helper. - `git diff --check` and the source-only check passed. No game files were used. GPUs tested: n/a. AI-assisted: yes.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:12:33 +00:00
Author
Owner

@⁠MSedgeMC on GitHub · 2026-11-25 17:10 UTC · original · approved these changes

Verified: runtime/test/test_temp_dir.h exists on main and defines process_temp_dir(name) as temp_directory_path()/(name_pid); it is already used by d3d12_subgroup_test.cpp. Replacing the fixed shared temp paths in the bink and gamesave tests with process_temp_dir prevents parallel test runs from clobbering each other's scratch files. Consistent with the existing helper, minimal, no game data.

**@⁠MSedgeMC** on GitHub · 2026-11-25 17:10 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1952#pullrequestreview-6061816627) · **approved these changes** Verified: runtime/test/test_temp_dir.h exists on main and defines process_temp_dir(name) as temp_directory_path()/(name_pid); it is already used by d3d12_subgroup_test.cpp. Replacing the fixed shared temp paths in the bink and gamesave tests with process_temp_dir prevents parallel test runs from clobbering each other's scratch files. Consistent with the existing helper, minimal, no game data.
Author
Owner

@⁠Diegobecker07 on GitHub · 2026-11-25 17:47 UTC · original

I tested this together with #1579, which changes the same three lines (to testfiles::writable_temp_dir() / "<fixed name>"). The two conflict in all three files, whichever lands second. Resolving each conflict with this PR's line works. #1579's process_temp_dir builds on writable_temp_dir(), so its fix for a stripped environment carries over.

Setup: main 863c1616a + #1579 + this PR, conflicts resolved that way, on Windows 11 Pro 26300 with MSVC 19.44.

  • xgameruntime_gamesave_test, normal runs: 3 of 3 pass with 76 checks and 0 failures.
  • Stripped environment: with TMP, TEMP, USERPROFILE and TMPDIR removed, 3 of 3 pass and nothing is left in the build folder.
  • Four copies at once, one shared TEMP/TMP folder, three batches: 0 of 12 fail and no folders are left. For comparison, on this machine two copies at once failed 10 of 10 on main and on #1579 alone (comment on #1579).
  • Bink tests: bink_audio_test and bink_decode_test build but were not run, because they need a movie.

One trade-off: each Bink test now writes to a new <name>_<pid> folder on every run, and nothing removes it. On main, each run overwrote one folder. bink_decode_test writes frames 0 and 1 (plus the LEONIDA_GOTO frame when set) as raw BGRA and PPM, about 7 bytes per pixel per frame. bink_audio_test writes a PCM and a WAV per track. The decoded output therefore builds up in %TEMP%, one folder per run. If the files are meant to stay for inspection, one option is ScratchDir by default, keeping the folder only when an environment variable asks for it.

AI-assisted.

**@⁠Diegobecker07** on GitHub · 2026-11-25 17:47 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1952#issuecomment-7169998697) I tested this together with #1579, which changes the same three lines (to `testfiles::writable_temp_dir() / "<fixed name>"`). The two conflict in all three files, whichever lands second. Resolving each conflict with this PR's line works. #1579's `process_temp_dir` builds on `writable_temp_dir()`, so its fix for a stripped environment carries over. Setup: main 863c1616a + #1579 + this PR, conflicts resolved that way, on Windows 11 Pro 26300 with MSVC 19.44. - **`xgameruntime_gamesave_test`, normal runs:** 3 of 3 pass with 76 checks and 0 failures. - **Stripped environment:** with TMP, TEMP, USERPROFILE and TMPDIR removed, 3 of 3 pass and nothing is left in the build folder. - **Four copies at once, one shared TEMP/TMP folder, three batches:** 0 of 12 fail and no folders are left. For comparison, on this machine two copies at once failed 10 of 10 on main and on #1579 alone ([comment on #1579](https://git.gtahub.st/github/ubiquitarianism--leonida/pulls/1579)). - **Bink tests:** `bink_audio_test` and `bink_decode_test` build but were not run, because they need a movie. One trade-off: each Bink test now writes to a new `<name>_<pid>` folder on every run, and nothing removes it. On main, each run overwrote one folder. `bink_decode_test` writes frames 0 and 1 (plus the `LEONIDA_GOTO` frame when set) as raw BGRA and PPM, about 7 bytes per pixel per frame. `bink_audio_test` writes a PCM and a WAV per track. The decoded output therefore builds up in `%TEMP%`, one folder per run. If the files are meant to stay for inspection, one option is `ScratchDir` by default, keeping the folder only when an environment variable asks for it. AI-assisted.
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/1952/head:github-bot/gh-1952'
git switch 'github-bot/gh-1952'

Merge

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