[PR #1135] xgameruntime: release g_error_mutex before invoking XErrorCallback in XErrorReport (OLD-9887) #1168

Open
opened 2026-11-26 20:20:19 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1135
Author: @ambroseautomation
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: carry/old-9887-xerror-reentrancy


📝 Commits (1)

  • cab5c18 fix(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

Claimed in the coordination issue as: OLD-9887 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7141584617)

What and why

Carries forward old-pr/9887 (draft #156, original commit author totonii preserved; indexed in #17), rebased cleanly onto current main (6293c1c4f).

Fixes a re-entrancy deadlock in error_report (XErrorReport) in runtime/shims/xgameruntime.cpp:

  • Copies g_error_callback and g_error_context under g_error_mutex, then releases the lock before invoking the callback so a callback that calls XErrorReport or XErrorSetCallback re-entrantly does not deadlock.
  • Adds a multi-threaded re-entrancy regression test in runtime/test/xgameruntime_test.cpp that invokes both nested XErrorReport and XErrorSetCallback(nullptr, nullptr) from inside the callback with a 2-second deadlock timeout.

Tested

  • Compiled and ran xgameruntime_test.exe natively on Windows 11 with MSVC (/std:c++20 /EHsc /W4 /permissive- /utf-8 /O2): xgameruntime_test: OK (159 checks), including the new re-entrancy test.
  • python -I scripts/check_no_game_data.py runtime/shims/xgameruntime.cpp runtime/test/xgameruntime_test.cpp: exit 0 (no game data).

GPUs tested: n/a (CPU/OS runtime shim; built and tested on Windows 11 Pro 64-bit, MSVC VS 18)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a — xgameruntime shim)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1135 **Author:** [@ambroseautomation](https://github.com/ambroseautomation) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `carry/old-9887-xerror-reentrancy` --- ### 📝 Commits (1) - [`cab5c18`](https://github.com/ubiquitarianism/leonida/commit/cab5c184132760974308af472ab8d32bbe44e2b7) fix(xgameruntime): release g_error_mutex before invoking XErrorCallback in XErrorReport ### 📊 Changes **2 files changed** (+49 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `runtime/shims/xgameruntime.cpp` (+8 -2) 📝 `runtime/test/xgameruntime_test.cpp` (+41 -0) </details> ### 📄 Description Claimed in the coordination issue as: OLD-9887 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7141584617) ### What and why Carries forward `old-pr/9887` (draft #156, original commit author `totonii` preserved; indexed in #17), rebased cleanly onto current `main` (`6293c1c4f`). Fixes a re-entrancy deadlock in `error_report` (`XErrorReport`) in `runtime/shims/xgameruntime.cpp`: - Copies `g_error_callback` and `g_error_context` under `g_error_mutex`, then releases the lock before invoking the callback so a callback that calls `XErrorReport` or `XErrorSetCallback` re-entrantly does not deadlock. - Adds a multi-threaded re-entrancy regression test in `runtime/test/xgameruntime_test.cpp` that invokes both nested `XErrorReport` and `XErrorSetCallback(nullptr, nullptr)` from inside the callback with a 2-second deadlock timeout. ### Tested - Compiled and ran `xgameruntime_test.exe` natively on Windows 11 with MSVC (`/std:c++20 /EHsc /W4 /permissive- /utf-8 /O2`): `xgameruntime_test: OK (159 checks)`, including the new re-entrancy test. - `python -I scripts/check_no_game_data.py runtime/shims/xgameruntime.cpp runtime/test/xgameruntime_test.cpp`: exit 0 (no game data). GPUs tested: n/a (CPU/OS runtime shim; built and tested on Windows 11 Pro 64-bit, MSVC VS 18) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a — `xgameruntime` shim) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#1168
No description provided.