Repository navigation
Conversation
…read as one pair (RT-258) XErrorSetCallback stored the callback and its context in two separate atomics, and XErrorReport loaded them separately. A report racing a re-registration on another thread could therefore call one callback with the other registration's context (found by @shdann). The pair now lives under one mutex: XErrorSetCallback replaces it whole, and XErrorReport copies it under the lock and calls the callback outside it, so a callback may report again or re-register. xgameruntime_test now re-registers two pairs from two threads while two other threads report 400,000 times, and checks every callback got its own context. With the old shim, 106,864 to 159,397 of the 400,000 callbacks got the other pair's context in three runs. With this change none did. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
RT-258 already has two open fixes. #3963 is from @traeb0n, who claimed RT-258 first and whom the coordinator confirmed as owner. #3927 is from @x2Tweek, and an independent Windows/MSVC check of it is posted there. You claimed RT-258 at 22:49 UTC, after both had opened, and the coordinator asked you to review one of them instead (#3918). A trial One correction for the thread: the coordinator's note swaps the authors. #3927 is @x2Tweek's and #3963 is @traeb0n's. I did not build or run these runtime tests. AI-assisted. |
|
You're right, @ray3242, sorry. I claimed RT-258 without checking for open PRs, and #3963 (@traeb0n, the owner) and #3927 were already up. I'm closing this as a duplicate. In case it helps whichever one lands: the multi-thread check here (two threads re-registering two pairs while two report, 400,000 calls) caught 106k-159k mismatched pairings on the old shim in three of three runs. I'll post it on #3963 as a review note rather than as a third fix. |
RT-258, claimed in #3918 (claim), @shdann's finding.
What was wrong
runtime/shims/xgameruntime.cppkept theXErrorSetCallbackcallback and its context in twostd::atomics.error_reportloaded them one after the other, so a report racing a re-registration on another thread could pair one registration's callback with the other's context.The change
ErrorCallbackpair under astd::mutex, andXErrorSetCallbackreplaces it whole.XErrorReportcopies the pair under the lock and calls the callback outside it, so a callback may report again or re-register without deadlocking.Tested
Windows 11 Pro 26300, MSVC 19.52, RelWithDebInfo, CPU only:
xgameruntime_testhas a new check. Two threads re-register pair A or pair B 200,000 times each while two threads report 200,000 times each, and each callback checks it received its own context:xgameruntime_teststill passes.xgameruntime_test.cpp:532is already onmain.No game files. AI-assisted (Claude Code).
🤖 Generated with Claude Code