[PR #638] [MERGED] OLD-7824: restore old upstream PR 7824 - startup_trace: LEONIDA_SKIP_INT3 works on title threads and with Wine's breakpoint address #678

Closed
opened 2026-11-26 20:18:41 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/638
Author: @aslan2142
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: skip-int3-wine


📝 Commits (4)

  • 60fce7a startup_trace: LEONIDA_SKIP_INT3 works on title threads and with Wine's breakpoint address
  • 83c1bf2 Merge commit 'refs/fix2/main' into fix2-638
  • 1d0bf24 startup_trace: take the int3 candidate ExceptionAddress names; drop the unused
  • 2a79af5 runtime/README: int3_skipped is per address until the 4096-slot table fills

📊 Changes

6 files changed (+283 additions, -54 deletions)

View changed files

📝 docs/boot.md (+2 -1)
📝 runtime/CMakeLists.txt (+1 -1)
📝 runtime/README.md (+1 -1)
📝 runtime/shims/startup_trace.h (+71 -21)
📝 runtime/shims/xgameruntime_offline.cpp (+15 -13)
📝 runtime/test/int3_skip_test.cpp (+193 -17)

📄 Description

Claimed in the coordination issue as: OLD-7824 https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7129021661

Restoration of my original pull request, old upstream PR 7824 in ItsNotRexed/Leonida, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Rebased onto main at 21625bca8; the code is unchanged, and the old #7599 references in the comments and the commit message now read "old upstream 7599" (old numbers link nowhere here), with the three comments that got longer rewrapped to 120 columns.

What and why

Spacecer2 measured under Wine 11.22 (old upstream 7599) that LEONIDA_SKIP_INT3 never took effect. The flag was a block-scope static first read on a title thread, and its MSVC thread-safe-static guard passed while the object was still zero. The handler's int3 set and the trace lock had the same shape. Two changes fix that:

  • What startup_trace's exception handler touches is no longer a block-scope static:
    • startup_trace::open() reads LEONIDA_SKIP_INT3, on the thread that opens the trace, into a constant-initialized atomic.
    • The trace lock is a constant-initialized SRW lock (no constructor, never destroyed).
    • The logged int3 sites are a constant-initialized open-addressing table of atomics.
  • The int3 is found at Rip (the Windows form) or at Rip - 1 (Spacecer2's Wine run). Either way, Rip ends one byte past the 0xCC.

Also:

  • skip_int3 returns false for a null EXCEPTION_POINTERS, record or context.
  • LEONIDA_LOG_GAME_EVENTS and LEONIDA_HDR are read on title threads, so xgameruntime_offline.cpp now caches them in namespace-scope atomics instead of block-scope statics.
  • docs/boot.md, runtime/README.md and the CMakeLists.txt comment now say that the variable is read when the trace opens.

int3_skip_test now runs each case in a child process with its own environment. The cases are real int3s, the Windows and the Wine breakpoint forms, the null pointers, the flag read at open(), and the flag off.

Tested

These runs were on Linux, with the Windows tests built with clang 23 for x86_64-w64-mingw32 and run under Wine 11.22 (Staging). The MSVC /W4 /permissive- build is left to CI.

  • int3_skip_test before, on main: the new test does not compile there, because it reads detail::skip_int3_on, which main does not have. With those two checks stubbed out:
    • real, windows and off pass;
    • wine fails 4 checks;
    • null crashes with an access violation;
    • init fails 1 check.
  • int3_skip_test after, on this branch: all 6 cases pass, 30 checks and 0 failures.
  • xgameruntime_offline_test: 58 checks and 0 failures both before and after, with and without LEONIDA_HDR=1.
  • Checks: git diff --check and python -I scripts/check_no_game_data.py on the changed files are both clean.

GPUs tested: n/a

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: no translator change)

AI-assisted (Claude Code, Claude Opus 5.5).


🔄 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/638 **Author:** [@aslan2142](https://github.com/aslan2142) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `skip-int3-wine` --- ### 📝 Commits (4) - [`60fce7a`](https://github.com/ubiquitarianism/leonida/commit/60fce7a747433733aab6eab183461be718341c41) startup_trace: LEONIDA_SKIP_INT3 works on title threads and with Wine's breakpoint address - [`83c1bf2`](https://github.com/ubiquitarianism/leonida/commit/83c1bf27916089ffc33c16378680bf747330a578) Merge commit 'refs/fix2/main' into fix2-638 - [`1d0bf24`](https://github.com/ubiquitarianism/leonida/commit/1d0bf24dc71f9ae811143e41f65a6c93f75250dd) startup_trace: take the int3 candidate ExceptionAddress names; drop the unused <set> - [`2a79af5`](https://github.com/ubiquitarianism/leonida/commit/2a79af5a81ac6a62bdee7711d0fe84a0d1ae5725) runtime/README: int3_skipped is per address until the 4096-slot table fills ### 📊 Changes **6 files changed** (+283 additions, -54 deletions) <details> <summary>View changed files</summary> 📝 `docs/boot.md` (+2 -1) 📝 `runtime/CMakeLists.txt` (+1 -1) 📝 `runtime/README.md` (+1 -1) 📝 `runtime/shims/startup_trace.h` (+71 -21) 📝 `runtime/shims/xgameruntime_offline.cpp` (+15 -13) 📝 `runtime/test/int3_skip_test.cpp` (+193 -17) </details> ### 📄 Description Claimed in the coordination issue as: OLD-7824 https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7129021661 Restoration of my original pull request, old upstream PR 7824 in `ItsNotRexed/Leonida`, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Rebased onto main at `21625bca8`; the code is unchanged, and the old `#7599` references in the comments and the commit message now read "old upstream 7599" (old numbers link nowhere here), with the three comments that got longer rewrapped to 120 columns. ### What and why Spacecer2 measured under Wine 11.22 (old upstream 7599) that `LEONIDA_SKIP_INT3` never took effect. The flag was a block-scope static first read on a title thread, and its MSVC thread-safe-static guard passed while the object was still zero. The handler's int3 set and the trace lock had the same shape. Two changes fix that: - What `startup_trace`'s exception handler touches is no longer a block-scope static: - `startup_trace::open()` reads `LEONIDA_SKIP_INT3`, on the thread that opens the trace, into a constant-initialized atomic. - The trace lock is a constant-initialized SRW lock (no constructor, never destroyed). - The logged int3 sites are a constant-initialized open-addressing table of atomics. - The int3 is found at `Rip` (the Windows form) or at `Rip - 1` (Spacecer2's Wine run). Either way, `Rip` ends one byte past the `0xCC`. Also: - `skip_int3` returns false for a null `EXCEPTION_POINTERS`, record or context. - `LEONIDA_LOG_GAME_EVENTS` and `LEONIDA_HDR` are read on title threads, so `xgameruntime_offline.cpp` now caches them in namespace-scope atomics instead of block-scope statics. - `docs/boot.md`, `runtime/README.md` and the `CMakeLists.txt` comment now say that the variable is read when the trace opens. `int3_skip_test` now runs each case in a child process with its own environment. The cases are real int3s, the Windows and the Wine breakpoint forms, the null pointers, the flag read at `open()`, and the flag off. ### Tested These runs were on Linux, with the Windows tests built with clang 23 for `x86_64-w64-mingw32` and run under Wine 11.22 (Staging). The MSVC `/W4 /permissive-` build is left to CI. - **`int3_skip_test` before, on `main`:** the new test does not compile there, because it reads `detail::skip_int3_on`, which `main` does not have. With those two checks stubbed out: - `real`, `windows` and `off` pass; - `wine` fails 4 checks; - `null` crashes with an access violation; - `init` fails 1 check. - **`int3_skip_test` after, on this branch:** all 6 cases pass, 30 checks and 0 failures. - **`xgameruntime_offline_test`:** 58 checks and 0 failures both before and after, with and without `LEONIDA_HDR=1`. - **Checks:** `git diff --check` and `python -I scripts/check_no_game_data.py` on the changed files are both clean. GPUs tested: n/a 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: no translator change) AI-assisted (Claude Code, Claude Opus 5.5). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:41 +01:00
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#678
No description provided.