Skip to content

Linux: fix a crash when a page write waits on another thread (#883) - #885

Merged
peiikai merged 2 commits into
release/0.6from
fix/883-house-crash
Nov 25, 2026
Merged

peiikai merged 2 commits into
release/0.6from
fix/883-house-crash

Conversation

@peiikai

@peiikai peiikai commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Fixes #883.

What happened

The crash line (signal 11 accessing 0x7281e27900, host pc in f_7001077a30) is a game thread writing per-draw data into a mapped buffer (v1.0.1: the store right after the buffer map call at main+0x1077cc8). The address is inside the guest heap, which on RADV (the Steam Deck) is driver memory, so page write tracking is the soft one: queries protect pages read-only and the first CPU write faults, and the fault handler opens the page again.

soft_release had a race. When two threads fault on the same page, the second waits while the first opens it. If the second thread is descheduled meanwhile, the render thread's next query can arm (and protect) the page again before the second thread sees it open. The handler then took the armed page for "not ours" and reported a crash, on a write the game was allowed to make. Linux only (the soft tracking is in linux.c); macOS and Windows use other tracking.

Change

  • soft_release: after waiting for the other thread, look at the page again; if it is armed, open it here.
  • The soft tracking code moves from runtime/platform/linux.c into runtime/platform/soft_tracking.h (unchanged apart from the fix above), so a test can include it.
  • tools/test_soft_tracking.c (run in the Linux x86-64 and aarch64 CI jobs, listed in CONTRIBUTING "Tests"):
    1. the Game crashed at animal village #883 sequence step by step: a write waits on a page another thread is opening, which gets armed again before it looks;
    2. 8 writer threads and a querying thread for 2 s.

Testing

  • macOS (Apple Silicon) with -arch x86_64 under Rosetta for 4K pages: both cases pass with the fix (5 runs). With the old soft_release, case 1 fails, and case 2 alone fails on every run (3 of 3).
  • Not seen in game: this code only runs on Linux with the heap as driver memory (RADV), and no such machine was available. The Linux build is checked by CI.
  • The other logs from the same player: the freeze in ..._35361667.log (Field, t=1992) has no crash or hang lines, so this change can't be tied to it. Crash in the telephone house #370 was a different crash (an uncaught exception in the game, TelephoneBox01_Ukuku1), unrelated.

🤖 Generated with Claude Code

… page is armed again (#883)

With the guest heap as driver memory (RADV: the Steam Deck), page write tracking is mprotect + SIGSEGV. When
two game threads fault on the same page, the second waits while the first opens it. If the second is
descheduled meanwhile, the render thread's next query can arm (and protect) the page again before the
second thread sees it open. The handler then took the armed page for "not ours" and reported a crash, on
a write the game was allowed to make (#883: f_7001077a30 writing per-draw data into a mapped buffer).

Now the waiting thread looks again and opens the page itself when it finds it armed.

The soft tracking moves into runtime/platform/soft_tracking.h, unchanged otherwise, so
tools/test_soft_tracking.c can run it: the #883 sequence step by step, and writer threads with a querying
thread for 2 s. Both fail with the old code (the second every run on an 8-core Mac under Rosetta).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@peiikai
peiikai merged commit dff8adb into release/0.6 Nov 25, 2026
8 checks passed
@peiikai
peiikai deleted the fix/883-house-crash branch November 25, 2026 02:04
peiikai added a commit that referenced this pull request Nov 25, 2026
NevesHenry pushed a commit to NevesHenry/LASRecomp that referenced this pull request Nov 26, 2026
…peiikai#889)

- peiikai#884, peiikai#888: 130 shader variants from the peiikai#883 logs (2049 records).
- peiikai#885: Linux soft page write tracking race (peiikai#883 crash), moved to
  runtime/platform/soft_tracking.h, with tools/test_soft_tracking.c in CI.
- peiikai#889: tools/rando/dungeon_gen.py stays deleted on develop; the same
  03G notch landing fix is in C++ via peiikai#890.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant