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

Manually merged
github merged 2 commits from gh-pr/523/head into gh-pr/523/base 2026-11-26 21:58:45 +00:00
Owner

@⁠yummancito on GitHub · 2026-11-22 09:00 UTC · original
yummancito:test/tls-thread-value → main · +323 −0 · 4 files · 2 commits · merged 2026-11-22 09:53 UTC

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.

**@⁠yummancito** on GitHub · 2026-11-22 09:00 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/523) `yummancito:test/tls-thread-value` → `main` · +323 −0 · 4 files · 2 commits · merged 2026-11-22 09:53 UTC 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`.
Add cpu_tls_value, a source-built DLL with one __declspec(thread) value
reported in the sink reserved slot by its TLS callback and entry point,
and cpu_native_tls_value, which loads it natively and under pe_map in
fresh child processes, reads the value on the main thread, runs one
worker probe with a timeout, and compares semantic thread identities
instead of raw OS thread IDs. The empty-template tls_route fixture is
the control. Windows is expected to observe 7 on both threads; pe_map
is expected to reject the image as unsupported TLS data with no
notifications. Documents the missing TLS-data mechanism.

Refs #165
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:58:44 +00:00
github manually merged commit 32eec5b11f into gh-pr/523/base 2026-11-26 21:58:45 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.