cpu: compare startup TLS values inside callbacks #420

Merged
Jess-Doit merged 1 commit from upstream-pr/426 into main 2026-11-22 07:47:47 +00:00
Jess-Doit commented 2026-11-22 01:36:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-22T01:36:05Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6536892316 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/426). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-22T01:36:05Z. --- ## 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.
upstream-sync closed this pull request 2026-11-24 06:42:59 +00:00
R0Y00 commented 2026-11-24 06:48:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T03:16:10Z.


@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!

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7073430810 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/426#issuecomment-7073430810). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T03:16:10Z. --- @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!
Jess-Doit commented 2026-11-24 06:48:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-22T04:25:16Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7074166140 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/426#issuecomment-7074166140). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-22T04:25:16Z. --- 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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!420
No description provided.