SIGSEGV in Wine's syscall dispatcher: vkback's live guards make Wine thread stacks at 0x1_0000_0000 read-only #139

Closed
opened 2026-12-01 20:58:04 +00:00 by github-bot · 2 comments
Owner

@⁠firefloc on GitHub · 2026-12-01 20:54 UTC · original

Seen on: 5930321 (main), plus local fork commits that touch none of crates/victory-gpu/src/watch*, vkback's texture watch/refresh/fill, victory-hle xmem/umem or greenfield/umem.
Machine: RX 7900 XTX (RADV, Mesa 26.3.1), Ryzen 7 7800X3D, GE-Proton 11-14, Series X mode, VICTORY_VIEW_GUARD=0.

Symptom

The whole process dies with SIGSEGV a few minutes into the world (seen from the cell save and from a blank save), with no PE-side context in the log. Reproduced on three cores with the same signature:

  • first fault on a title thread: SEGV_ACCERR at 0x1_001f_e3f0 in ntdll.so!__wine_syscall_dispatcher+9 (pop 0x70(%rcx), writing the syscall frame), called from WaitOnAddress -> RtlWaitOnAddress -> NtWaitForAlertByThreadId; the thread's TLS (fs_base) is 0x1_001f_f6c0;
  • Wine's segv_handler then dies with SI_KERNEL, which is what ends the process;
  • the core's mapping [0x1_0000_0000, 0x1_0020_0000) is anonymous and read-only.

Cause (captured)

[0x1_0000_0000, 0x1_0020_0000) holds two Wine thread stacks of 1 MiB: the main thread's (__wine_main -> virtual_alloc_thread_stack) and one NtCreateThreadEx makes at process start. The faulting thread owns the upper one. This is also where xmem's address_range starts the title window (1 << 32); the first umem mapping sits 2 MiB above it.

A GDB probe on mprotect/pkey_mprotect/mmap/munmap/mremap over that range caught 32 calls mprotect(block, 0x10000, PROT_READ), one per 64 KiB block from 0x1_0000_0000 to 0x1_001f_0000, coming from NtProtectVirtualMemory called by kernelbase's VirtualProtect on two PE threads. /proc/<pid>/maps showed both stacks turn r--p in the same second, and the process died right after the last block, the one holding the syscall frame and the TLS.

That is the shape of watch::live::live_protect: vkback asks to guard every texture filled from title memory (watch_texture -> OP_LIVE_GUARDS -> live_guard), including textures whose memory umem does not back, and the title names a texture at 0x1_0000_0000 (the same run logs buffer view over memory umem does not back (CPU memory, null): SRV 0x100000000). live_protect tries the whole run of blocks in one VirtualProtect, which Wine refuses across the two stacks' views. Its block-by-block retry then makes every block read-only without asking what lies there. guard asks is_view first; the live path never does.

Fix

PR #141: live_protect guards only the blocks is_view accepts, as guard does; the others stay writable, are counted and the first 16 are logged. With it, the same scenario from a blank save passes the point: the refusals are logged from 0x1_0000_0000 on, both stacks stay rw-p, and there is no core.

The underlying overlap (Wine's stacks inside the title window, and the title naming addresses there) is a separate finding: #140.

**@⁠firefloc** on GitHub · 2026-12-01 20:54 UTC · [original](https://github.com/vktory6/VKtory/issues/139) Seen on: 5930321 (main), plus local fork commits that touch none of `crates/victory-gpu/src/watch*`, vkback's texture watch/refresh/fill, victory-hle `xmem`/`umem` or `greenfield/umem`. Machine: RX 7900 XTX (RADV, Mesa 26.3.1), Ryzen 7 7800X3D, GE-Proton 11-14, Series X mode, `VICTORY_VIEW_GUARD=0`. ## Symptom The whole process dies with SIGSEGV a few minutes into the world (seen from the cell save and from a blank save), with no PE-side context in the log. Reproduced on three cores with the same signature: - first fault on a title thread: `SEGV_ACCERR` at `0x1_001f_e3f0` in `ntdll.so!__wine_syscall_dispatcher+9` (`pop 0x70(%rcx)`, writing the syscall frame), called from `WaitOnAddress` -> `RtlWaitOnAddress` -> `NtWaitForAlertByThreadId`; the thread's TLS (`fs_base`) is `0x1_001f_f6c0`; - Wine's `segv_handler` then dies with `SI_KERNEL`, which is what ends the process; - the core's mapping `[0x1_0000_0000, 0x1_0020_0000)` is anonymous and read-only. ## Cause (captured) `[0x1_0000_0000, 0x1_0020_0000)` holds two Wine thread stacks of 1 MiB: the main thread's (`__wine_main` -> `virtual_alloc_thread_stack`) and one `NtCreateThreadEx` makes at process start. The faulting thread owns the upper one. This is also where xmem's `address_range` starts the title window (`1 << 32`); the first umem mapping sits 2 MiB above it. A GDB probe on `mprotect`/`pkey_mprotect`/`mmap`/`munmap`/`mremap` over that range caught 32 calls `mprotect(block, 0x10000, PROT_READ)`, one per 64 KiB block from `0x1_0000_0000` to `0x1_001f_0000`, coming from `NtProtectVirtualMemory` called by kernelbase's `VirtualProtect` on two PE threads. `/proc/<pid>/maps` showed both stacks turn `r--p` in the same second, and the process died right after the last block, the one holding the syscall frame and the TLS. That is the shape of `watch::live::live_protect`: vkback asks to guard every texture filled from title memory (`watch_texture` -> `OP_LIVE_GUARDS` -> `live_guard`), including textures whose memory umem does not back, and the title names a texture at `0x1_0000_0000` (the same run logs `buffer view over memory umem does not back (CPU memory, null): SRV 0x100000000`). `live_protect` tries the whole run of blocks in one `VirtualProtect`, which Wine refuses across the two stacks' views. Its block-by-block retry then makes every block read-only without asking what lies there. `guard` asks `is_view` first; the live path never does. ## Fix PR #141: `live_protect` guards only the blocks `is_view` accepts, as `guard` does; the others stay writable, are counted and the first 16 are logged. With it, the same scenario from a blank save passes the point: the refusals are logged from `0x1_0000_0000` on, both stacks stay `rw-p`, and there is no core. The underlying overlap (Wine's stacks inside the title window, and the title naming addresses there) is a separate finding: #140.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 20:58:05 +00:00
Author
Owner

@⁠vktory6 on GitHub · 2026-12-01 21:05 UTC · original

Thanks for the thorough capture. The diagnosis matches the code: guard asks is_view, the live path did not. PR #141 is in our checks now (build and tests pass; the validation run is queued). I'll close this when it merges. The underlying overlap is tracked as a task from #140.

**@⁠vktory6** on GitHub · 2026-12-01 21:05 UTC · [original](https://github.com/vktory6/VKtory/issues/139#issuecomment-7325737544) Thanks for the thorough capture. The diagnosis matches the code: `guard` asks `is_view`, the live path did not. PR #141 is in our checks now (build and tests pass; the validation run is queued). I'll close this when it merges. The underlying overlap is tracked as a task from #140.
Author
Owner

@⁠vktory6 on GitHub · 2026-12-01 21:15 UTC · original

Fixed by #141, merged as github.com/vktory6/VKtory@77a61b9. The title window overlap stays open in #140 and its task. Closing.

**@⁠vktory6** on GitHub · 2026-12-01 21:15 UTC · [original](https://github.com/vktory6/VKtory/issues/139#issuecomment-7325977858) Fixed by #141, merged as https://github.com/vktory6/VKtory/commit/77a61b9. The title window overlap stays open in #140 and its task. Closing.
This discussion has been locked. Commenting is limited to contributors.
No milestone
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
github/vktory6--VKtory#139
No description provided.