cpu: compare implicit TLS values on main and worker threads #517

Merged
yummancito merged 2 commits from upstream-pr/523 into main 2026-11-22 09:53:07 +00:00
yummancito commented 2026-11-22 09:00:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by yummancito on 2026-11-22T09:00:42Z.


Differential regression test for #165: a TLS callback reading a thread-local value on the main thread and on a worker, with observed thread identities and values under both loaders.

This is the remaining comparison requested after #296: native LoadLibraryW vs pe_map on a source-built DLL with one __declspec(thread) value (7), a .CRT$XLB TLS callback, and a DllMain. The harness runs each loader in a fresh child process, reads the value on the main thread, runs one worker thread whose start routine returns its own TLS value (10 s join limit), and compares sink events with raw OS thread IDs translated to semantic identities (main/worker).

Measured behavior ( documents the gap, changes no loader code ):

  • Native: TLS callback observes 7 on both main and worker threads.
  • Mapped: pe_map rejects the image with MAP_UNSUPPORTED / TLS data; no callback events — recorded as the expected verifiable condition, not a CTest failure. Any other mapping failure, worker timeout, missing callback, or unexpected value fails the test.

Controls: the empty-template cpu_tls_original fixture must load under both loaders.

Files: tests/cpu/tls_value.cpp, tests/cpu/native_tls_value_check.py, CMakeLists.txt (new cpu_tls_value lib + cpu_native_tls_value test), docs/experiments.md.

CI (fork, Windows 2025, commit e746767): https://github.com/yummancito/Xbox2Windows/actions/runs/45004809320 — 100% tests passed, 194/194, in both Development and Release (/O2) jobs; cpu_native_tls_value passed in both (0.49 s / 0.71 s). No other code touched.

This PR adds regression coverage only; it does not implement implicit-TLS support in pe_map.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6540555995 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/523). Originally posted by [yummancito](https://github.com/yummancito) on 2026-11-22T09:00:42Z. --- Differential regression test for #165: a TLS callback reading a thread-local value on the main thread and on a worker, with observed thread identities and values under both loaders. This is the remaining comparison requested after #296: native `LoadLibraryW` vs `pe_map` on a source-built DLL with one `__declspec(thread)` value (`7`), a `.CRT$XLB` TLS callback, and a `DllMain`. The harness runs each loader in a fresh child process, reads the value on the main thread, runs one worker thread whose start routine returns its own TLS value (10 s join limit), and compares sink events with raw OS thread IDs translated to semantic identities (`main`/`worker`). Measured behavior ( documents the gap, changes no loader code ): - Native: TLS callback observes `7` on both main and worker threads. - Mapped: `pe_map` rejects the image with `MAP_UNSUPPORTED / TLS data`; no callback events — recorded as the expected verifiable condition, not a CTest failure. Any other mapping failure, worker timeout, missing callback, or unexpected value fails the test. Controls: the empty-template `cpu_tls_original` fixture must load under both loaders. Files: `tests/cpu/tls_value.cpp`, `tests/cpu/native_tls_value_check.py`, `CMakeLists.txt` (new `cpu_tls_value` lib + `cpu_native_tls_value` test), `docs/experiments.md`. CI (fork, Windows 2025, commit e746767): https://github.com/yummancito/Xbox2Windows/actions/runs/45004809320 — 100% tests passed, 194/194, in both Development and Release (/O2) jobs; `cpu_native_tls_value` passed in both (0.49 s / 0.71 s). No other code touched. This PR adds regression coverage only; it does not implement implicit-TLS support in `pe_map`.
upstream-sync closed this pull request 2026-11-24 06:43:30 +00:00
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!517
No description provided.