Repository navigation
Open
Description
Summary
Verified several PE loader, static TLS, exception-handling, and host-platform edge cases during an audit of crates/xcl/src/ (on main 60599a9) that warrant focused follow-up PRs:
1. Static TLS edge cases (crates/xcl/src/tls.rs, crates/xcl/src/main.rs, crates/xcl/src/loader.rs)
on_thread_attach()IMAGES.try_read()contention: If a game DLL with static TLS is being installed (IMAGES.write()), concurrently attaching OS/game threads hitWouldBlockand silently skip copying all mapped TLS templates, leavingthread_localvariables zeroed..CRT$XLYordering aftertake_slot_zero:XCL_TLS_CALLBACKis placed in.CRT$XLY, which runs after Ruststd's.CRT$XLBcallback. Oncetake_slot_zerorewritesxcl.exe's_tls_indextok, any.CRT$XLB...CRT$XLXcallback on a new thread reads slotk(the title's carrier block) beforeexchange_for_new_threadswaps slots0andk.take_slot_zeroThreadLocalStoragePointerUAF window &MOVEDstale TEBs: Rawarr = *(teb + 0x58)pointers are held acrossSleep(20)without suspending threads (vulnerable if a thread loads a TLS DLL and reallocates its TLS pointer array), andTerminateThreadleaves stale TEBs inMOVED.- Ignored
IMAGE_TLS_DIRECTORY64.Characteristicsalignment & uncheckedAddressOfIndex == 0:tls.rshardcodesCharacteristics = 0in the carrier DLL (dropping 32B/64B alignment required by AVX2/cache-linethread_locals), and callback-only TLS directories withaddress_of_index == 0dereferenceadj(0).
2. Exception-handling & diagnostic safety (crates/xcl/src/eh.rs)
dump_threads()deadlock: Allocates (Vec/format!) and callsRtlLookupFunctionEntry,GetModuleHandleExW(Loader Lock), andGetThreadDescription/LocalFree(Process Heap lock) while holding another thread suspended viaSuspendThread. CapturingCONTEXTon the stack and callingResumeThreadimmediately before symbolizing/formatting avoids deadlocking if the target held the heap or loader lock.cpp_exception_loggerVEH crash risk: Performs unboundedCStr::from_ptrafter checking onlyreadable(s, 1)(and assumes[object + 8]isstd::exception::whatfor every thrown C++ object), which can fault inside the VEH near a guard/unmapped page and turn a caught C++ exception fatal; also lacks null checks oninfo/ExceptionRecord/ContextRecord.watch_writes/start_probes: Missingsnap != INVALID_HANDLE_VALUEandSuspendThread(h) != u32::MAXguards.
3. PE loader bounds & failure cleanup (crates/xcl/src/pe.rs, crates/xcl/src/loader.rs)
pe.rs::relocations(andthunks/imports/delay_imports/exports) use uncheckedu32addition without verifyingblock <= d.size - pos(panic in debug / potential infinite loop in release on malformed reloc blocks).loader.rsregisters mapped modules beforepe.imports()/tls_install()without unregistering (or freeing on TLS error) on failure, and caches DLLs whoseDllMain(PROCESS_ATTACH)returnedFALSEinMAPPEDso a secondload_game_dllreturnsOk(m).
4. FFI -unwind boundaries, startup CPUID check, and PC-sized platform values
- Guest callbacks across non-
-unwindextern "system"/extern "C"boundaries:XMemAlloc/XMemFreeguest hooks (hle/kernelx.rs),console_wndproc(hle/user.rs),DllMain/TlsCallback(loader.rs), and blockingGameInput::RegisterDeviceCallback(hle/gameinput.rs) cross non--unwindRust frames; C++/SEH exceptions unwinding across them abort or skipDropguards. - Startup AVX2 / Zen 2 CPUID check (
host.rs/launcher.rs): Retail Xbox Series X|S binaries assume Zen 2 (AVX2/FMA/F16C/BMI1/BMI2/POPCNT/SSE4.2/LZCNT); detecting missing ISA features at startup and printing a clear error avoids opaque0xC000001Dcrashes on unsupported CPUs. - Hybrid CPU affinity masks & core counts (
hle/kernelx.rs):SetThreadAffinityMask/SetThreadGroupAffinity/GetSystemInfo/GlobalMemoryStatusExcurrently fall through unshimmed to Windows, which can fail on <7-core CPUs, pin console 7-core masks onto E-cores on hybrid Intel CPUs, or report PC-sized logical CPU counts / RAM. S:\PLS disk space quota (vfs_hooks.rs):GetDiskFreeSpaceExW/Areports the full host NVMe volume instead of clampingS:\toconfig.pls_mb.- Minor:
Config::load_or_create(config.rs) overwritesxcl.tomlon any read error (not justErrorKind::NotFound), andConfig::resolvematches"auto"/"advanced"case-sensitively;report::write_final(report.rs) can dropcrashifWRITE_LOCK.try_lock()fails concurrently;RegisterClassExA(hle/user.rs) omitscbSizevalidation andconsole_windowpassesSWP_NOSIZEafter subclassingWM_GETMINMAXINFO.
Metadata
Metadata
Assignees
Labels
No labels
Activity
Fixes from the audits in #103 / #106: PresentX on another queue, fram…
ivall commentedon Nov 23, 2026
Thanks. Triage against current
main:Config::load_or_createoverwritingxcl.tomlon any read error – confirmed, fixed in ea4bd62 (only a missing file gets the defaults; an unreadable one is an error).S:\free space – true that it reports the host volume; titles compare it against what they need, so a larger answer is harmless. Low priority.Command queue ivall#18 before the layout is known writes 8 bytes; a C…
Frame clock: each frame its own origin, ancillary handles outlive the…
PE: malformed import and relocation directories are errors, not panic…
HANDOFF: session 6 (the audits ivall#103–ivall#106, ivall#111, CI), n…
Runtime: CPU check at start, bounded reads in the exception logger, t…
TLS: an image without an index variable gets its slot without a write…
Loader: a game DLL that failed to load is not left registered (#106)
Report: a crash reported while the report is being written is kept (#106
Config: title_memory is read in any case (#106)
TLS: preserve Characteristics alignment and fix on_thread_attach cont…
ivall commentedon Nov 23, 2026
Progress: #141 (a DLL that failed to load is not left registered), #148 (title_memory in any case), #183 (TLS without an index variable) and #147 (crash report below a module's base) are merged; #196 (TLS Characteristics alignment / attach contention) and #197 (system-unwind across guest re-entry) are open.
yous0serious commentedon Nov 23, 2026
The hybrid CPU affinity item: #221 clamps
SetThreadAffinityMask/SetThreadGroupAffinitymasks that name processors outside the process's affinity (the case triaged above as worth clamping). Masks made from the PC's processors pass unchanged, so the title still sees the PC's processors.Measured on an i7-13700KF: Windows fails such a mask with
ERROR_INVALID_PARAMETERwhen none of its processors exists (0xFF000000on 24 processors), or when any is outside a limited process mask (0x7F/0x3F/0x40understart /affinity F). The E-core concern above does not hold there: Windows numbers the P-core threads first (0–15), so console masks (bits 0–13) land on P-cores.The other items of this issue are not touched by #221.
Thread affinity: console masks with processors the PC lacks are fitte…
fix(ffi): use extern "system-unwind" across guest-reentry FFI boundar…
Respect the PLS quota in GetDiskFreeSpaceEx
mariuslozo-boop commentedon Nov 23, 2026
A crash in
eh::dump_threads(XCL_THREAD_DUMP_AT), adding to the dump_threads item here.On main
d4f17cawithXCL_THREAD_DUMP_AT=90,180,270and a retail title running (RTX 5070 Ti, Windows 11 26300), the dumps at 90 s and 180 s were fine. At 270.052 s, the dump thread itself crashed and took the process down:ntdll+0x1ff2ais insideRtlVirtualUnwind2:mov rcx, qword ptr [r8]withr8 = 0xf8. While walking a suspended thread's stack, the unwinder dereferences a near-null context pointer.eh::unwindstarts from a context it should not trust, or a frame without a valid function entry. The read happens insideRtlVirtualUnwind, so no check inunwindafter the call can catch it.AI-assisted (Claude Code). No game files attached.
fix(ffi): use extern "system-unwind" across guest-reentry FFI boundar…
xcl run: thread dumps unwind a copy of each stopped thread's stack
PE loader: relocation targets outside the image fail the load (xcl-de…
xcl run: thread dumps unwind a copy of each stopped thread's stack
xcl run: thread dumps unwind a copy of each stopped thread's stack
notquiteog commentedon Nov 24, 2026
A field occurrence that fits the
dump_threads()deadlock in section 2, onmain9e3831e(release,cargo build --release --workspace), Windows 11 26100, RTX 5060 Ti,XCL_NETWORK=0, retail title 1.0.2.1.The title takes its usual watchdog exit (
+0x23cf683, #846) at 104.8 s.xcl.logends on that line:Nothing follows it: no
on the stack:list, noprocess ends with status …line, no thread dump, and no crash-reporter lines. The process stayed alive for another 8+ minutes until my harness killed it at its 10-minute cap.For comparison, on the same machine and title the same exit was handled normally three times: twice on
077ce40and once on the theaustinayers fork at76d3b9f. Each time the log has the stack, a full per-thread dump andprocess ends with status 0xc0000005within about 1 s, and the process exits. So it's intermittent, as a lock held by a suspended thread would be.eh.rsdid not change between077ce40and9e3831e.I don't have a dump of the hung process, so this is consistent with the suspended-thread heap/loader-lock deadlock described above rather than proof of it. One practical effect: a run that should end in ~1 s after the title's fatal exit instead hangs indefinitely, so unattended test runs need their own timeout.
PE loader: skip export ordinals past u32::MAX (xcl-dev#691)
user: validate RegisterClassExA size against WNDCLASSEXA and enforce …