Skip to content

Loader: preserve files with malformed TLS clone names (RT-854) - #8792

Draft
AndresGroselj wants to merge 1 commit into
ItsNotRexed:mainfrom
AndresGroselj:codex/tls-clone-name-validation
Draft

AndresGroselj wants to merge 1 commit into
ItsNotRexed:mainfrom
AndresGroselj:codex/tls-clone-name-validation

Conversation

@AndresGroselj

Copy link
Copy Markdown

The startup sweep matched leonida_tls_host_*.dll and could delete files whose names were not loader clones. It also accumulated PIDs in a 32-bit Windows unsigned long, so checking overflow after multiplication did not work.

Validate the complete filename, require a nonzero DWORD PID, check numeric overflow before multiplication, and skip unrecognized names. Numeric helper slots and the home tag remain supported. The end-to-end regression creates ten malformed sentinel names, verifies their contents survive, and retains checks for stale, live-process and held-open clones.

Coordination: RT-854, claim.

This branch is based directly on upstream main (867d922f), with only the filename-validation change and its regression test. It contains none of #8379's TLS-index-0 implementation. A separate local integration with #8379 was used for compatibility and retail smoke testing.

Validation:

  • Before the fix, the regression failed because nine malformed sentinel files were deleted.
  • All configured Windows runtime targets build. On the main-based PR branch, all 13 selected loader/startup tests pass; loader_tls passes 106 checks, including all ten malformed sentinels unchanged.
  • Local integration with Loader: the mapped game executable owns module TLS index 0 (RT-259, takeover of #4313) #8379: all six loader/TLS tests pass, including clone cleanup.
  • Full translator suite: 447 files / 5,957 tests; two files fail (test_image_atomics_guard, test_image_store_d16). Both failures reproduce unchanged on clean main at 867d922f (47 and 1 failing subcases respectively).
  • Python compileall, build CLI help, whitespace and no-game-data checks pass.
  • Retail smoke test, network namespace isolated and package mounted read-only: same result before/after this change — five modules mapped, four successful DllMain calls, two TLS callbacks, then breakpoint exception 0x80000003 before D3D12. The private runtime diagnostic names the missing dynamic XErrorReport export, matching Loader: the mapped game executable owns module TLS index 0 (RT-259, takeover of #4313) #8379's reported stop. No traces or game content are included.

Environment: Nobara Linux 44, Wine 11.17 Staging, Fedora clang-cl/lld 22.1.8, Windows SDK 10.0.26100. Available GPU: RX 7900 XT, RADV Mesa 26.2.5; the retail run did not reach D3D12. Clang's synthetic tests do not validate MSVC's /GA instruction shape.

AI-assisted with Codex. Unrecognized files are conservatively left untouched; this does not change the separate clone-staging race concern.

@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 0d76d415f on Windows 11 with MSVC. All 106 checks in loader_tls pass.

The startup sweep preserves all ten files with malformed clone names. Each file keeps its original bytes. The sweep removes the stale numeric clone and the stale home clone. It preserves the clone of a live process and the clone held open by another handle.

I built loader_tls_test with --config RelWithDebInfo. I ran ctest -C RelWithDebInfo -R "^loader_tls$" -V with a separate temporary directory for each revision. With the same test source on parent 867d922f0, all ten malformed files disappear. The parent reports 10 failures in 96 checks because it skips the content check for each missing file.

AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants