Repository navigation
Conversation
|
Tested dded50c merged onto main f875cda, on Windows 11 (build 26300), NVIDIA GeForce RTX 5060 Ti (driver 32.0.16.2124), MSVC 14.44 RelWithDebInfo, my own Xbox Series copy:
The D3D12Core exception may be one the runtime catches internally; I haven't confirmed whether it turns into a failed HRESULT the title then ignores. AI-assisted. |
slot 25 (
|
|
Measured in a local integration on main 9f53c50: as a fast-forward this bundle runs with zero conflicts and reaches the descriptor heap (1.24 M descriptors), slot 70 SRV, slot 133 placed resource and slot 25 - further than any stack built only from the focused PRs. That is real value; the issue is only that most of it now has an owner elsewhere. Already covered: #6919/#6935 (xmem), #6964 (slot 26), #6954 (slot 48), #7021 (descriptor heap), #7218 (slot 133), #6582 (XErrorReport), #4348 (DirectStorage). Unique to this bundle: the TLS mirror, the offline XError exports plus ws2/dstorage stubs, and its slot 14/133/70 prototypes. Suggest splitting those into focused PRs (TLS mirror first) so the rest can land without re-verifying the whole tree. |
|
Thanks @Ryx69, @bobczan, @Silliana, and @dandasma for testing and the feedback! Follow-up fixes for slot 25 ( We'd prefer to keep this PR as-is for now rather than splitting it, but if maintainers find smaller focused PRs (e.g., starting with the TLS slot-0 mirror) easier to review and merge, just let us know and I'll be happy to split it up. |
|
Follow-up: with #7110 (which carries #6973 and #7078) merged on top, conflicts resolved locally (keeping this PR's slot 26/70/133 code and #7110's slot 25/56 entries), the AI-assisted (Claude Code). |
|
Heads-up: rebasing |
dded50c to
3138433
Compare
|
Tested
No game files. AI-assisted (Claude Code). |
|
✅ Automated security review: CLEAN (commit
Scope: static analysis of added diff lines only; no code was executed. Please review findings manually. |
|
Second independent check of PR merged onto Code read of checked: #75033138433 | with: Windows runtime build (clang-cl 23.1.6 + lld-link, xwin MSVC CRT 14.44 + Windows SDK 10.0.26100, AI-assisted (Claude Code). No game files. |
LaugeM
left a comment
There was a problem hiding this comment.
Read against main 5d74c27, which has b7a3fed (the /GA TLS rewrite) and 6312c05 (the XErrorReport export). I read the TLS part closely and the rest only for overlap.
Does not build on main
The text merges cleanly, so GitHub shows MERGEABLE. In the merge result, though, runtime/shims/xgameruntime.cpp defines XErrorReport twice: main's HRESULT WINAPI XErrorReport at line 262 and this PR's HRESULT __stdcall XErrorReport at line 271. It also lists XGR(XErrorReport) twice, at 1347 and 1353. That is a redefinition error. Drop this PR's copy and keep XErrorSetCallback and XErrorSetOptions if they are still wanted.
TLS part
main already fixes the fault this targets (b7a3fed). With this PR the executable gets index 0, so main's rewrite is skipped (index != 0 at main pe_loader.cpp:1512) and this mechanism takes over. It has these problems:
- Only the loading thread keeps gta6rt's TLS.
redirect_host_exe_tls_once(runtime/src/pe_loader.cpp:345-394) copiesslots[0]into the self clone's block on the calling thread only (:390), then points gta6rt's_tls_indexat the clone. Every other thread, whether already running or started later, finds the clone's template at that index: the anchor byte and the 4 KiB of0x80000000(runtime/src/tls_host.cpp:15-23), not gta6rt.exe's template. So gta6rt'sthread_locals start as that pattern instead of their initializers. The PR moves the ones insrc/andshims/toTlsAlloc, butthird_party/xtaskqueue/Source/Task/WaitTimer_win32.cpp:24-25, which is linked into gta6rt, still has twothread_localpointers initialised tonullptr. The CRT's own TLS (_Init_thread_epoch, the dynamic-TLS guard) reads correctly only where its offset happens to land on a pad word, which the code does not check. #8379 avoids all of this by giving the clone a copy of gta6rt.exe's template at process start. - Running threads lose their live block. For the executable in pool slot 0,
install_on_existing_threads(:678) writes its block into slot 0 of every other running thread. That slot held gta6rt's live TLS for those threads, and their gta6rt code now reads the pad at the new index. The move is also lazy, at the firstload(). #4313's description shows why that is unsafe: MSVC keeps&ThreadLocalStoragePointer[_tls_index]in a frame across calls (zlib_inflate). - The clone that now holds gta6rt's TLS is freed at exit.
ensure_tls_host(kSelfTlsHostSlot)records it ing_tls_clones(:337).cleanup_tls_clones(), whichmain.cpp:255calls right beforeExitProcessandatexitruns otherwise, then callsFreeLibraryon it. #8379 measured that this frees every thread's block at that index (its README), so gta6rt code that runs after cleanup reads freed TLS. This is plausible from that measurement, not run here. - Index 0 is given only when the executable lands in pool slot 0 (
:1515). Otherwise it gets a helper index, its/GAreads go to gta6rt's slot 0, and nothing is logged. Under--runthe executable is the first TLS module, so this holds there, but any other order fails silently. The primary helper's index then goes unused. if (g_exe_tls_slot0_anchor == 0xFF) return;(:1473) reads a gta6rtthread_localafter the redirect, which is a pad byte on most threads. If that byte ever read0xFF, TLS setup would be skipped without a message. gta6rt.exe already has a TLS directory, so the anchor (:176) is not needed.
I'd drop the TLS part: the pe_loader.cpp redirect, tls_host.cpp, and the TlsAlloc conversions in queue_holds.h, startup_trace.h and xgameruntime*.cpp. If index 0 for the executable is wanted on top of main's rewrite, #8379 is the version with tests.
Other overlap
Besides what @Silliana listed, the ws2_32 shim overlaps #6943, and the slot-70 buffer views overlap #9068 and #8304. That is another reason to split this PR as suggested.
DirectStorage part
The dstorage_stub factory in runtime/shims/d3d12_xs.cpp (lines 225-304 on 3138433a2) and its xcrdapi.dll classify() line in registry.cpp should come out of this PR. #8461 serves the real factory under the same names.
- Confirmed (code): it collides with #8461. Both register
XCRDAPI.dll!DStorageGetFactory,dstorage.dllanddstorage_xs.dll, and the two branches merge with no textual conflict, so nothing flags it.Table::Table(runtime/shims/registry.cpp:479on main) lowercases the module name and overwrites the entry withtable()[key] = fn, so the table that registers last wins. That is decided by static-initialisation order betweend3d12_xs.cppanddstorage.cpp, so which factory the title gets depends on link order, and nothing logs the clash (#9279 would). - Confirmed (code): the stub is not safe on its own. Every slot returns
S_OK, andqiand slots 3-5 hand out the factory itself, so the title uses it as its queue, file and status array too. On a queue, slot 3 isEnqueueRequest(request), butmethod_stub<3>(lines 253-255) writes a pointer througha3, which is whatever the title left inr9, whenever that is a writable address. On a status array, slot 3 isIsComplete, which returnsS_OK(0) read asbool, so it is false forever. No request ever runs, so the title's buffers stay as they were. The stop this was written for is the null factory, and #8461 clears it with real reads (the retail runs on #8461).
The rest of this PR is outside the DirectStorage cluster and I did not review it.
AI-assisted review (Opus 5.5). Read the diff against main; TLS part not built, DirectStorage part checked with dstorage_test (MSVC, CPU only) on #8461 and git merge-tree.
Summary
Implements multiple runtime and shim fixes observed while stepping through early retail Xbox Series boot initialization on Windows PC (with zero game assets or executable bytes/addresses committed):
PE loader & host /GA TLS slot-0 arbitration (
untime/src/pe_loader.cpp,
untime/src/tls_host.cpp,
untime/src/queue_holds.h,
untime/shims/startup_trace.h,
untime/shims/xgameruntime.cpp,
untime/shims/xgameruntime_gamesave.cpp):
ax–
15,
sp) to startup trace exception JSON events for easier diagnostics.
Offline shims for Winsock2, XError, and DirectStorage/XCRDAPI* (
untime/shims/winhttp_offline.cpp,
untime/shims/xgameruntime.cpp,
untime/shims/d3d12_xs.cpp,
untime/shims/registry.cpp):
t::ws2 / SHIM_TABLE(ws2_offline)) covering Winsock ordinal imports Add pytest regression tests for the RDNA2 -> SPIR-V translator, plus a Linux CI job #1–tools, tests: add stdlib paths for tex_headers and rtti_scan and un-skip CI tests #151, getaddrinfo/reeaddrinfo, GetAddrInfoW/FreeAddrInfoW, and WSASocketA/W (failing cleanly offline with WSAENETDOWN/WSAHOST_NOT_FOUND).
XMem placeholder commit fallback (
untime/shims/xmem.cpp):
Xbox D3D12_xs device & console command-list proxy extensions (
untime/shims/d3d12_xs_device.cpp):
Verification