Repository navigation
Conversation
|
Checked head Merge order,
No defect. No game data. AI-assisted (Claude Code). |
|
Windows check of The new |
|
Tested 9640c84 merged with main 5d74c27 under Wine: On: Linux, Ubuntu 24.04, cross-built with clang-cl 19.1.1 + lld-link + xwin SDK (RelWithDebInfo), run through Wine 9.0; CPU only, no game files. What happens
Why
Fix tried here target_link_options(tiny_ga PRIVATE /OPT:NOREF /INCLUDE:_tls_used)
AI-assisted (Claude Code). |
…) TLS view The /GA rewrite (b7a3fed) points every mov r64, gs:[58h] at TEB->TlsSlots[slot], whose value in a thread is a view with that thread block at [0] and at [tls_index]. install_thread_block gives the loading thread and every thread started after load() one, but install_on_existing_threads() only wrote the module TLS array entry of a thread that already existed. Its TlsSlots entry stayed NULL, so the first /GA access on such a thread, e.g. a title callback on a process thread-pool worker, read through NULL (the retail boot fault class at +0x104075). Give those threads the same view and restore/free it with the block: remove_existing_block, forget_ended_thread_id (a thread terminated without a detach event) and the rollback path. Measured with loader_tls_test and a /GA fixture EXE: before, the pre-existing thread had no view (3 FAIL, exit 1); after, 95/95 checks pass, exit 0. loader, pe_loader, pe_loader_bounds and loader_tls all pass. Not run against the game copy; a local gta6rt --run is what confirms it there.
…s a check instead of faulting /GA reads gs:[58h] and references no _tls_index, so a clang-cl + lld-link build wrote no TLS directory: load() then had no module index for the fixture, skipped the index-0 patch, and module_tls_slots()[kNoTlsIndex] in the early thread faulted (0xC0000005) instead of failing a check. Pull the CRT's _tls_used into the link and read the slot only when load() set an index.
9640c84 to
47083e1
Compare
|
Thanks @GeremC — your Wine run is folded in as What changed
Run here (Windows 11, MSVC 14.44.35207, RelWithDebInfo + Ninja, CPU only, no game files; no clang-cl/lld-link on this machine so your configuration is the one that still needs a re-run)
The |
|
Tested
4/4 passed in 2.15 s. Worth noting this is the MSVC/link.exe build, not lld-link, so the TLS directory layout your description mentions is exercised through the other toolchain on this machine. AI-assisted. |
|
checked: #9410 | head 47083e1 merged onto main 5d74c27 (clean) | on: native Windows 11 26200, MSVC 14.44 RelWithDebInfo (Ninja), RX 9060 XT box | result: pass. AI-assisted (Claude Code), no game files. |
Claimed in the coordination issue as: EGEN-GA-TLS-EXISTING-THREADS (#9235 (comment))
Depends on: #8379, #7524 (they touch the same loader TLS area; this patch fixes the merged
/GArewrite instead of reserving index 0)What and why
The merged
/GATLS rewrite (b7a3fed28) rewrites eachmov r64, gs:[58h]in the mapped EXE to readTEB->TlsSlots[slot].install_thread_blockputs a view there ([0]and[tls_index]= that thread's block) for the loading thread and, through the helper DLL's thread event, for every thread started afterload().install_on_existing_threads()copied the block into a thread that already existed but never wrote itsTlsSlotsentry, so the first/GAaccess on such a thread dereferencedTEB->TlsSlots[slot]= NULL. That is the same fault the rewrite removes on the loading thread, on the process thread-pool workers wherethird_party/xtaskqueueruns a title's callbacks (the comment in that function says they predate most loads).The change gives those threads the same view and takes it out again (restoring what the slot held) with the block in
remove_existing_block, inforget_ended_thread_id(a thread that ended without a detach event) and in the rollback path where the view cannot be written.The
/GAfixture now also keeps its TLS directory when it is linked bylld-link(/INCLUDE:_tls_used): with/GAnothing references_tls_index, so a clang-cl + lld-link build wrote no TLS directory,load()had no module index to give the fixture and the test faulted onmodule_tls_slots()[kNoTlsIndex]instead of failing a check. Reported by @GeremC with a merged-main Wine run.Tested
Windows 11, MSVC 14.44.35207, RelWithDebInfo + Ninja, rebased on
5d74c2723, branch head47083e18e.New
/GAfixtureruntime/test/fixtures/tiny_ga.cpp(compiled/GA:__declspec(thread)plus a raw__readgsqword(0x58)export) and aloader_tls_testcase that starts a thread beforeload(), maps the EXE, and calls the exports on the loading thread, the pre-existing thread and a thread started afterwards:it also has the /GA view the patched reads need,its /GA view points at its own block,a /GA access on that thread reads its own block),loader_tls_test: FAILED (95 checks, 3 failures), exit 1. The loader's ownload() rewrites...check passes, so the fixture exercises the production rewrite.loader_tls_test: OK (95 checks), exit 0 (three runs in a row);ctest -R "loader_tls|^loader$|pe_loader": 4/4 pass.tiny_ga.exewithIMAGE_DIRECTORY_ENTRY_TLSzeroed, the state an lld-link build was in), sameloader_tls_test: the pre-fix binary exits-1073741819(0xC0000005) after 3/GAFAILs; the fixed binary reports the 8/GAFAILs that follow (a thread that existed before load() got a TLS block of its own,its /GA view points at its own block, ...), finishes all 95 checks and exits 1. So a missing directory is a failed check now, not a fault.tiny_ga.exestill has its TLS directory (rva0x82a0, size0x28) under link.exe, i.e./INCLUDE:_tls_usedchanges nothing there.Not run here: the clang-cl + lld-link build under Wine (no clang-cl or lld-link on this machine) — re-running GeremC's configuration is what closes that half. Not run against the game copy (
F:\CLGameis read-only here): a localgta6rt --run <game exe>is what confirms the thread-side fault is gone there.AI-assisted: yes (Cline).
Checklist
docs/design.md, with how it was confirmed.Tag: SHAYDERRR