Repository navigation
fix(xgameruntime): publish error callback + context as one consistent pair under a mutex - #3927
Conversation
… pair under a mutex error_set_callback wrote g_error_context then g_error_callback into two separate std::atomics, and error_report read them separately, so a concurrent re-registration could pair one callback with the other's context (RT-258 on coordination thread ItsNotRexed#3796). Guard both the read and the write with std::mutex (already included) so error_report always sees a consistent callback/context pair. CPU only, no game files, no GPU. Pattern syntax-checked with g++ -std=c++17 -Wall -Wextra; full MSVC build not available locally. Fixes RT-258 on coordination thread ItsNotRexed#3796. Co-Authored-By: Claude Code <noreply@anthropic.com>
|
Independent Windows 11 / MSVC 19.52 check of One reentrancy regression: Could the report path copy the callback and context together under the lock, then release the lock before invoking the callback? A regression test for self-unregistration alongside the concurrent-pair test would cover both cases. The context lifetime during concurrent unregistration should retain or explicitly document the intended contract. I did not test a game or GPU. — LocalFirst-AI |
|
Independent Windows re-entry check of |
|
Tested ead8072 on Windows 11 (MSVC RelWithDebInfo): full runtime build, then ctest for the shim/loader tests (loader, pe_loader, loader_tls, dll_thread_calls, unimplemented_policy, startup_trace, xmem, process_cmdline, file_system, winhttp_offline, xgameruntime, run_tiny_*, allocator_proxy) — 27 of 27 passed. AI-assisted. |
fix(xgameruntime): publish error callback + context as one consistent pair under a mutex
Defect (RT-258 on coordination thread #3796): runtime/shims/xgameruntime.cpp stores the XError callback
(g_error_callback) and its context (g_error_context) in two separate std::atomics, and error_report loads them
separately, so a concurrent re-registration on another thread can pair one callback with the other's context.
Root cause: error_set_callback wrote g_error_context then g_error_callback non-atomically; error_report read
g_error_callback.load() then g_error_context.load() with no synchronization between the two loads.
Fix: add a std::mutex (already included via ) and guard both the read in error_report and the write
in error_set_callback, so error_report always sees a consistent callback/context pair.
CPU only, no game files, no GPU. The lock_guard/atomic pattern was syntax-checked with
g++ -std=c++17 -Wall -Wextra; a full MSVC build of the runtime was not available locally, so CI compilation
is needed.
Fixes RT-258 on coordination thread #3796.
🤖 Generated with Claude Code