Skip to content

[RT-170] Deliver thread notifications to mapped DLLs - #2573

Closed
Capi360 wants to merge 6 commits into
ItsNotRexed:mainfrom
Capi360:codex/rt-170-thread-notifications
Closed

Capi360 wants to merge 6 commits into
ItsNotRexed:mainfrom
Capi360:codex/rt-170-thread-notifications

Conversation

@Capi360

@Capi360 Capi360 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

RT-170, claimed in #2516, from @Sc4ros's finding.

Depends on: #2070
Depends on: #2383

What changes

  • The TLS host forwards thread notifications to initialized mapped DLLs, including DLLs with no static TLS. Attach follows dependency order and detach reverses it. TLS callbacks precede the corresponding DLL entry point, and TLS blocks stay live through detach.
  • DisableThreadLibraryCalls suppresses DLL thread notifications for DLLs without static TLS. The native Windows 11 fixture with static TLS returned success and retained its notifications, so the shim preserves both behaviors. Host handles still go to Windows.

Verification

Windows 11 build 26200, MSVC 19.44 x64, Windows SDK 10.0.28000.0, RelWithDebInfo. CPU-only tests and locally built fixtures. No game data.

  • 12/12 focused loader, TLS, PE, asynchronous, and synthetic guest tests passed. loader_tls and dll_thread_calls each passed 20 consecutive runs.
  • The CRT-free fixture failed its attach and detach assertions on the dependency stack before RT-170. The patched loader matched the fixtures loaded by Windows, including opting out during thread attach.
  • Documentation links, CTest registration, Python compilation, CLI help, and git diff --check passed.

AI-assisted with Codex.

jaybeebabageyus and others added 6 commits November 22, 2026 17:51
The real DisableThreadLibraryCalls only accepts a module the Windows loader
mapped, so for a manually mapped image it returned FALSE. A DllMain that
returns its result (the MSVC runtime's msvcp140_1, msvcp140_2,
msvcp140_atomic_wait and msvcp140_codecvt_ids DLLs do) then made
Loader::initialise() throw "DllMain returned FALSE".

shims/library_loader.cpp serves the call next to FreeLibrary: TRUE for a
module the shims own or the loader mapped, the real function for any other
handle. New dll_thread_calls_test (CRT-free fixture DLL) fails on main and
passes with this change; docs/runtime_imports.md counts follow.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…995b2632d83480d8bb37965426958b4e47b9' into codex/rt-170-thread-notifications
- the DisableThreadLibraryCalls table entry gets its own continued line (it
  shared FreeLibrary's, 231 columns wide), and its comment is wrapped to 120;
- dll_thread_calls_test also calls the shim with a shim pseudo-handle (the
  handle GetModuleHandleA("xmem.dll") returns), which the Windows function
  would refuse: removing the pseudo(module) branch now fails the test.
  xmem.cpp is linked into the test only to give the shims a module to own.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…-170-thread-notifications

# Conflicts:
#	runtime/CMakeLists.txt
#	runtime/shims/library_loader.cpp
@Capi360

Capi360 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by @Sc4ros’s #2669. They had first refusal and have now opened their RT-170 implementation. I’m closing this duplicate draft so the tracker and review stay with #2669. This branch and the Windows fixture work remain available if useful.

@Capi360 Capi360 closed this Nov 22, 2026
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.

3 participants