diff options
| author | mariuslozo-boop <254631011+mariuslozo-boop@users.noreply.github.com> | 2026-11-23 01:38:18 +0100 |
|---|---|---|
| committer | mariuslozo-boop <254631011+mariuslozo-boop@users.noreply.github.com> | 2026-11-23 01:38:19 +0100 |
| commit | 9366e54f9744bbcd7df428c602ce1e775a9b9001 (patch) | |
| tree | 6dd85e4d83055e78f4691db08e9d9bed832fcb8e /runtime/src/main.cpp | |
| parent | a2542ccd6f394ab418daa39074f3d394b3daf6e7 (diff) | |
Loader: delete helper clones at exit again; a throwing reservation fails cleanly
From the second review of 89cec3b8:
- The first load_tls_host_clone call is now the home clone, from .CRT$XCT,
and it registered cleanup_tls_clones_at_exit with atexit before
g_tls_clones was dynamically initialized in .CRT$XCU. The vector's
destructor then ran first and the cleanup walked a destroyed vector, so
--dry-run, --init and every return-1 path left the slot clones'
leonida_tls_host_<pid>_<slot>.dll files in %TEMP%. g_tls_clones is now
allocated with the first record and never destroyed, and the atexit
handler is registered there. The home clone cannot be deleted while it is
mapped (DeleteFileW and a POSIX-semantics delete both fail with
ERROR_ACCESS_DENIED), so it is left for the next run's sweep, as the
README says.
- process_alive() took an ended process as alive while another process
still held a handle to it (CMake's execute_process does), so the next
run's sweep skipped its files; it now reads the exit code.
- reserve_tls_index0 catches what reserve_index0 throws (for example
std::filesystem::temp_directory_path) and stores it as the reason, so the
reservation fails before main with a message instead of ending gta6rt.
The owner's file name is taken before the move, so nothing can throw
between the move and recording it.
- Tests: run_tiny_tls_clone_cleanup runs gta6rt --dry-run, --init and
--dry-run on tiny_tls_clones.exe (three TLS modules, so one slot clone)
and checks that each run's PID leaves no clone file but its home clone and
that the next run deletes that one; it fails with the old cleanup.
run_tiny_tls_ga also runs with TMP and TEMP naming a missing folder: the
reservation fails, --run and --init refuse the image with the reason and
run none of it, --dry-run maps it with the note.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src/main.cpp')
0 files changed, 0 insertions, 0 deletions