runtime/test: run_tiny_tls_clone_cleanup looks where the loader writes its clones #3516

Code

Clone this repository

Checkout

From your project repository, check out a new branch and test the changes.

git fetch -u  "rt/tls-clone-cleanup-test-dir:jirehcwe-rt/tls-clone-cleanup-test-dir"
git switch "jirehcwe-rt/tls-clone-cleanup-test-dir"
Open
leonida/mandy
jirehcwe wants to merge 1 commit from jirehcwe/mandy:rt/tls-clone-cleanup-test-dir into main

This branch is out-of-date with the base branch

Conversation
Reviewers 0 approvals
  • No reviewers
Details
This pull request is blocked because it's outdated.
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 'rt/tls-clone-cleanup-test-dir:jirehcwe-rt/tls-clone-cleanup-test-dir'
git switch 'jirehcwe-rt/tls-clone-cleanup-test-dir'
First-time contributor

Claimed in the coordination issue as: RT-TLS-CLONE-CLEANUP-TEST-DIR (claim)

What and why

run_tiny_tls_clone_cleanup checks nothing when LEONIDA_TEST_DIR is set. AGENTS.md says to set it when antivirus
blocks loader_test.

runtime/test/check_tls_clone_cleanup.cmake looks for leftover clone files in TMP or TEMP. But
tls_host_clone_dir() (runtime/src/pe_loader.cpp) reads LEONIDA_TEST_DIR first. With the variable set, the
clones are written there, both globs match nothing, and the test passes whatever the loader leaves behind.

The change is test-only (6 lines added, 1 changed): the script uses LEONIDA_TEST_DIR when it is set and not empty,
the same condition as the loader. With the variable unset, nothing changes.

This is the follow-up named in #3514. The two pull requests touch different files and do not depend on each other.

Tested

On main 93b9d90a2, Windows 11, same build. The test passes in every row, so the evidence is what the script's
globs matched. I read that with a temporary message() line that is not in this change.

Script LEONIDA_TEST_DIR Folder searched Home clone of the run found
main set TMP no (it is in LEONIDA_TEST_DIR)
this change set LEONIDA_TEST_DIR yes, in all three runs
this change unset TMP yes, in all three runs
  • ctest -R "^run_tiny_tls_clone_cleanup$" passes with the variable set and unset.
  • python -I scripts/check_no_game_data.py: clean, on the whole tree.
  • An independent read-only reviewer agent approved. It confirmed the set, empty and unset cases match the loader, and
    that the processes sharing the folder are the same ones that shared TMP before, so no new false failure.
  • Not tested: Wine or Linux. Under an emulator the script and the guest may still see different folders, as before.
  • Not shown: the test failing on a real leftover clone. I did not break the loader's cleanup to try it.

GPUs tested: n/a (no GPU involved)

AI-assisted: yes. Claude Code with Claude Fable 5.2 wrote the change. A separate read-only reviewer agent on Claude
Opus 5.5 reviewed it.

Noticed, not in this pull request

With a relative LEONIDA_TEST_DIR (for example rel_test), gta6rt --dry-run tiny_tls_clones.exe returns 1: "the
home clone of gta6rt_tls_host.dll cannot be loaded". An absolute path works. I have not looked into the cause.

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

Claimed in the coordination issue as: RT-TLS-CLONE-CLEANUP-TEST-DIR ([claim](https://clearfieldswimming.com/leonida/mandy/issues/3312#issuecomment-26798)) ### What and why `run_tiny_tls_clone_cleanup` checks nothing when `LEONIDA_TEST_DIR` is set. AGENTS.md says to set it when antivirus blocks `loader_test`. `runtime/test/check_tls_clone_cleanup.cmake` looks for leftover clone files in `TMP` or `TEMP`. But `tls_host_clone_dir()` (`runtime/src/pe_loader.cpp`) reads `LEONIDA_TEST_DIR` first. With the variable set, the clones are written there, both globs match nothing, and the test passes whatever the loader leaves behind. The change is test-only (6 lines added, 1 changed): the script uses `LEONIDA_TEST_DIR` when it is set and not empty, the same condition as the loader. With the variable unset, nothing changes. This is the follow-up named in #3514. The two pull requests touch different files and do not depend on each other. ### Tested On `main` `93b9d90a2`, Windows 11, same build. The test passes in every row, so the evidence is what the script's globs matched. I read that with a temporary `message()` line that is not in this change. | Script | `LEONIDA_TEST_DIR` | Folder searched | Home clone of the run found | |---|---|---|---| | `main` | set | `TMP` | no (it is in `LEONIDA_TEST_DIR`) | | this change | set | `LEONIDA_TEST_DIR` | yes, in all three runs | | this change | unset | `TMP` | yes, in all three runs | - `ctest -R "^run_tiny_tls_clone_cleanup$"` passes with the variable set and unset. - `python -I scripts/check_no_game_data.py`: clean, on the whole tree. - An independent read-only reviewer agent approved. It confirmed the set, empty and unset cases match the loader, and that the processes sharing the folder are the same ones that shared `TMP` before, so no new false failure. - Not tested: Wine or Linux. Under an emulator the script and the guest may still see different folders, as before. - Not shown: the test failing on a real leftover clone. I did not break the loader's cleanup to try it. GPUs tested: n/a (no GPU involved) AI-assisted: yes. Claude Code with Claude Fable 5.2 wrote the change. A separate read-only reviewer agent on Claude Opus 5.5 reviewed it. ### Noticed, not in this pull request With a relative `LEONIDA_TEST_DIR` (for example `rel_test`), `gta6rt --dry-run tiny_tls_clones.exe` returns 1: "the home clone of gta6rt_tls_host.dll cannot be loaded". An absolute path works. I have not looked into the cause. ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
tls_host_clone_dir() (src/pe_loader.cpp) reads LEONIDA_TEST_DIR before TMP and
TEMP. check_tls_clone_cleanup.cmake looked in TMP or TEMP only, so with the
variable set both globs matched nothing and the test passed without checking
anything. The script now uses LEONIDA_TEST_DIR when it is set and not empty.

Test-only; nothing changes with the variable unset.

Claim: RT-TLS-CLONE-CLEANUP-TEST-DIR

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
First-time contributor

Verified at the script level with a stub loader. The run_tiny_tls_clone_cleanup CTest itself was not run: no MSVC toolchain on this host, so gta6rt cannot be built here.

What was run. runtime/test/check_tls_clone_cleanup.cmake from the PR head (0b99f23b) and from the merge base (93b9d90a), with a stub LOADER (gcc 16.2.0, mingw) that models tls_host_clone_dir(): clones go to LEONIDA_TEST_DIR when it is set and not empty, TMP otherwise. Each run prints 3 module(s) mapped, writes a trace whose first line carries "pid":N, leaves a helper clone leonida_tls_host_N_1.dll and the home clone leonida_tls_host_N_home.dll; in good mode it deletes the helper before exit and sweeps the previous run's files, in STUB_LEAVE mode it does neither. RUNNER empty, GUEST a dummy file, TMP/TEMP a separate scratch folder.

Result (fresh folders per run):

stub LEONIDA_TEST_DIR base script PR script
sweeps, deletes helper set exit 0 exit 0
leaves helper, no sweep set exit 0 (blind — the bug) exit 1, left clone files other than its home clone
leaves helper, no sweep unset exit 1 exit 1

So with the variable set the base script reads an empty TMP glob and passes whatever the loader does, and the PR reads the folder the loader actually uses and catches the same leftovers the unset path catches. Empty LEONIDA_TEST_DIR falls back to TMP in the new if, matching tls_host_clone_dir()'s dir && *dir.

gcc -O2 -o stub.exe stub.c
$env:TMP = "...\stubtmp"; $env:TEMP = "...\stubtmp"; $env:LEONIDA_TEST_DIR = "...\clones"
cmake -DLOADER=stub.exe -DGUEST=tiny_tls_clones.exe -DTRACE_DIR=trace -DRUNNER= -P base.cmake                                   # exit 0 with STUB_LEAVE
cmake -DLOADER=...\stub.exe -DGUEST=... -DTRACE_DIR=... -DRUNNER= -P runtime/test/check_tls_clone_cleanup.cmake                # exit 1 with STUB_LEAVE, exit 0 without

git diff --check on 0b99f23b: clean. scripts/check_no_game_data.py runtime/test/check_tls_clone_cleanup.cmake: clean.

Limits. The stub is a model of the loader's folder choice and sweep, not the loader: run_tiny_tls_clone_cleanup was not executed, and the real delete order/timing stays unproven on this host.

AI-assisted (Hy4 flash). GPU: RTX 5060 Laptop (driver 621.40) and Radeon 780M present, unused by this test. No game data used or needed.

Verified at the script level with a stub loader. The `run_tiny_tls_clone_cleanup` CTest itself was **not** run: no MSVC toolchain on this host, so `gta6rt` cannot be built here. **What was run.** `runtime/test/check_tls_clone_cleanup.cmake` from the PR head (0b99f23b) and from the merge base (93b9d90a), with a stub `LOADER` (gcc 16.2.0, mingw) that models `tls_host_clone_dir()`: clones go to `LEONIDA_TEST_DIR` when it is set and not empty, `TMP` otherwise. Each run prints `3 module(s) mapped`, writes a trace whose first line carries `"pid":N`, leaves a helper clone `leonida_tls_host_N_1.dll` and the home clone `leonida_tls_host_N_home.dll`; in good mode it deletes the helper before exit and sweeps the previous run's files, in `STUB_LEAVE` mode it does neither. `RUNNER` empty, `GUEST` a dummy file, `TMP`/`TEMP` a separate scratch folder. **Result** (fresh folders per run): | stub | `LEONIDA_TEST_DIR` | base script | PR script | |---|---|---|---| | sweeps, deletes helper | set | exit 0 | exit 0 | | leaves helper, no sweep | set | **exit 0 (blind — the bug)** | exit 1, `left clone files other than its home clone` | | leaves helper, no sweep | unset | exit 1 | exit 1 | So with the variable set the base script reads an empty `TMP` glob and passes whatever the loader does, and the PR reads the folder the loader actually uses and catches the same leftovers the unset path catches. Empty `LEONIDA_TEST_DIR` falls back to `TMP` in the new `if`, matching `tls_host_clone_dir()`'s `dir && *dir`. ```powershell gcc -O2 -o stub.exe stub.c $env:TMP = "...\stubtmp"; $env:TEMP = "...\stubtmp"; $env:LEONIDA_TEST_DIR = "...\clones" cmake -DLOADER=stub.exe -DGUEST=tiny_tls_clones.exe -DTRACE_DIR=trace -DRUNNER= -P base.cmake # exit 0 with STUB_LEAVE cmake -DLOADER=...\stub.exe -DGUEST=... -DTRACE_DIR=... -DRUNNER= -P runtime/test/check_tls_clone_cleanup.cmake # exit 1 with STUB_LEAVE, exit 0 without ``` `git diff --check` on 0b99f23b: clean. `scripts/check_no_game_data.py runtime/test/check_tls_clone_cleanup.cmake`: clean. **Limits.** The stub is a model of the loader's folder choice and sweep, not the loader: `run_tiny_tls_clone_cleanup` was not executed, and the real delete order/timing stays unproven on this host. AI-assisted (Hy4 flash). GPU: RTX 5060 Laptop (driver 621.40) and Radeon 780M present, unused by this test. No game data used or needed.
Sign in to join this conversation.
No description provided.