cpu: compare startup TLS values inside callbacks #426

Manually merged
github merged 1 commit from gh-pr/426/head into gh-pr/426/base 2026-11-26 21:51:02 +00:00
Owner

@⁠Jess-Doit on GitHub · 2026-11-22 01:36 UTC · original
Jess-Doit:cpu/startup-tls-observations → main · +146 −32 · 5 files · 1 commits · merged 2026-11-22 07:47 UTC

Change

Refs #165. Extend the three-image startup fixture from #262 to record the TLS value and actual thread ID inside the dependency DLL's callback. Compare those events by thread role under the Windows loader and pe_map.

Callback TLS value under both loaders
Main thread, process attach 1
Each worker, thread attach 0
Workers 1 and 2, thread detach 2 and 3

The fixture preserves the startup log, exit codes, and dependency and worker failure controls.

Verification

Commit 824e47c on Windows 10 22H2 build 19045.6456, x64 MSVC 19.44.35230.0, Windows SDK 10.0.26100.0. Both builds passed all four selected CTest cases.

ctest --test-dir out/build/pr-debug --no-tests=error -R '^cpu_native_(startup|tls|exe_chain|exe_termination)$' --timeout 70 -V
ctest --test-dir out/build/pr-release --no-tests=error -R '^cpu_native_(startup|tls|exe_chain|exe_termination)$' --timeout 70 -V

For the negative control, I temporarily forced worker-detach observations to 0 and rebuilt cpu_startup_a. The command below detected both wrong values. After restoring the source and rebuilding the DLL, it passed.

ctest --test-dir out/build/pr-debug --no-tests=error -R '^cpu_native_startup$' --timeout 70 -V

Evidence and follow-up

The existing MIT-licensed, source-built startup fixtures use an explicit TlsAlloc slot and empty static TLS data templates. The EXE retains the worker handles through the trace snapshot so their IDs stay valid. The accompanying docs/experiments.md update records the observation and reproduction command.

Checklist

  • One reviewable behavior
  • Exact test commands and results
  • A checked negative control
  • Updated experiment documentation
  • Diff limited to original fixture source and documentation

AI-assisted with Codex.

**@⁠Jess-Doit** on GitHub · 2026-11-22 01:36 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/426) `Jess-Doit:cpu/startup-tls-observations` → `main` · +146 −32 · 5 files · 1 commits · merged 2026-11-22 07:47 UTC ## Change Refs #165. Extend the three-image startup fixture from #262 to record the TLS value and actual thread ID inside the dependency DLL's callback. Compare those events by thread role under the Windows loader and `pe_map`. | Callback | TLS value under both loaders | | --- | --- | | Main thread, process attach | `1` | | Each worker, thread attach | `0` | | Workers 1 and 2, thread detach | `2` and `3` | The fixture preserves the startup log, exit codes, and dependency and worker failure controls. ## Verification Commit `824e47c` on Windows 10 22H2 build `19045.6456`, x64 MSVC `19.44.35230.0`, Windows SDK `10.0.26100.0`. Both builds passed all four selected CTest cases. ```powershell ctest --test-dir out/build/pr-debug --no-tests=error -R '^cpu_native_(startup|tls|exe_chain|exe_termination)$' --timeout 70 -V ctest --test-dir out/build/pr-release --no-tests=error -R '^cpu_native_(startup|tls|exe_chain|exe_termination)$' --timeout 70 -V ``` For the negative control, I temporarily forced worker-detach observations to `0` and rebuilt `cpu_startup_a`. The command below detected both wrong values. After restoring the source and rebuilding the DLL, it passed. ```powershell ctest --test-dir out/build/pr-debug --no-tests=error -R '^cpu_native_startup$' --timeout 70 -V ``` ## Evidence and follow-up The existing MIT-licensed, source-built startup fixtures use an explicit `TlsAlloc` slot and empty static TLS data templates. The EXE retains the worker handles through the trace snapshot so their IDs stay valid. The accompanying `docs/experiments.md` update records the observation and reproduction command. ## Checklist - [x] One reviewable behavior - [x] Exact test commands and results - [x] A checked negative control - [x] Updated experiment documentation - [x] Diff limited to original fixture source and documentation AI-assisted with Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:51:00 +00:00
github manually merged commit 824e47c66f into gh-pr/426/base 2026-11-26 21:51:02 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-22 03:16 UTC · original

@⁠yummancito, would you be willing to take this review through the next revision if one is needed? Jess-Doit is extending the three-image startup fixture you contributed in #262. Could you check how the test matches TLS callbacks to the main thread and each worker across Windows and pe_map, especially whether swapping the two workers' detach values would be caught? Please leave your verdict here and, if you request changes, take another look after the author updates the PR. Thanks!

**@⁠R0Y00** on GitHub · 2026-11-22 03:16 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/426#issuecomment-7073430810) @⁠yummancito, would you be willing to take this review through the next revision if one is needed? Jess-Doit is extending the three-image startup fixture you contributed in #262. Could you check how the test matches TLS callbacks to the main thread and each worker across Windows and pe_map, especially whether swapping the two workers' detach values would be caught? Please leave your verdict here and, if you request changes, take another look after the author updates the PR. Thanks!
Author
Owner

@⁠Jess-Doit on GitHub · 2026-11-22 04:25 UTC · original

I ran the exact swap control at 824e47c on Windows 10 22H2 build 19045.6456 with MSVC 19.44.35230. In a separate build of cpu_startup_a.dll, I exchanged only the reported TLS values 2 and 3 during DLL_THREAD_DETACH.

I ran the original and swapped DLL three times each in Debug and Release under both Windows and pe_map. All 12 originals passed. All 12 swapped runs kept the startup log and exit code 0x0103020e, and check_tls rejected them on the callback comparison. Worker 1 reported 3 and worker 2 reported 2, with the attach values intact.

AI-assisted.

**@⁠Jess-Doit** on GitHub · 2026-11-22 04:25 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/426#issuecomment-7074166140) I ran the exact swap control at 824e47c on Windows 10 22H2 build 19045.6456 with MSVC 19.44.35230. In a separate build of cpu_startup_a.dll, I exchanged only the reported TLS values 2 and 3 during DLL_THREAD_DETACH. I ran the original and swapped DLL three times each in Debug and Release under both Windows and pe_map. All 12 originals passed. All 12 swapped runs kept the startup log and exit code 0x0103020e, and check_tls rejected them on the callback comparison. Worker 1 reported 3 and worker 2 reported 2, with the attach values intact. AI-assisted.
This discussion has been locked. Commenting is limited to contributors.
No description provided.