mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:40:52 +01:00
[PR #156] fix(xgameruntime): release g_error_mutex before invoking XErrorCallback in XErrorReport #208
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#208
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/156
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:old-pr/9887📝 Commits (1)
52a8807fix(xgameruntime): release g_error_mutex before invoking XErrorCallback in XErrorReport📊 Changes
2 files changed (+49 additions, -2 deletions)
View changed files
📝
runtime/shims/xgameruntime.cpp(+8 -2)📝
runtime/test/xgameruntime_test.cpp(+41 -0)📄 Description
Original description (mentions and
#Nreferences are disabled; the numbers refer to the old repository):Summary
Fixes a re-entrancy deadlock / lock-order inversion in
error_report()(runtime/shims/xgameruntime.cpp:247-248):g_error_mutex(non-recursivestd::mutex) was held across the title'sXErrorCallbackinvocation. If the callback re-entrantly callsXErrorReportor callsXErrorSetCallback(e.g., to clear/swap its handler), or acquires a title lock that another thread holds aroundXErrorSetCallback, it immediately deadlocks (on MSVCstd::mutex, fast-failing withresource_deadlock_would_occur/0xc0000409).{g_error_callback, g_error_context}as one consistent pair underg_error_mutex, releases the lock, and then invokescb(hr, message, ctx).Testing
runtime/test/xgameruntime_test.cppwhere theXErrorCallbackcallsXErrorReportrecursively and clears itself viaXErrorSetCallback(nullptr, nullptr). Before the fix,xgameruntimecrashed immediately withExit code 0xc0000409(resource_deadlock_would_occur).Debug&RelWithDebInfo, MSVC/W4): 0 new warnings inxgameruntime.cppandxgameruntime_test.cpp.Debug&RelWithDebInfo):ctest -R '^xgameruntime$' --output-on-failure— 100% passed (0.23s RelWithDebInfo, 0.12s Debug).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.