loader(seh), hle(xasync): dispatch out-of-bounds/guard-page RSP faults on a TEB emergency stack and give XTaskQueue workers 8 MiB stacks #565

Open
opened 2026-11-28 04:54:54 +00:00 by github-bot · 2 comments
Owner

@⁠Sheffy007 on GitHub · 2026-11-28 04:50 UTC · original

Refs #395, #525.

  1. Silent SIGSEGV (exit code 139) inside seh::signal::on_signal when a title thread overflows its stack or faults with an out-of-bounds rsp:

    • on_signal (crates/victory-loader/src/native/seh/signal.rs:457-470) unconditionally writes Context and ExceptionRecord below the interrupted rsp.
    • If a title thread hits its stack guard page below TEB[OFF_STACK_LIMIT] or faults after rsp leaves [OFF_STACK_LIMIT, OFF_STACK_BASE), (ctx_at as *mut Context).write(ctx) triggers a nested SIGSEGV inside on_signal while SIGSEGV is masked by the kernel, terminating the process immediately with exit code 139 and no log output or unhandled-exception callback.
    • Allocating a per-TEB emergency dispatch stack and switching ctx_at / rec_at / entry_rsp onto it whenever rsp > stack_base || entry_rsp < stack_limit (while keeping the faulting rsp in Context and reporting EXCEPTION_STACK_OVERFLOW 0xC000_00FD for guard-zone faults below stack_limit) lets seh::dispatch log the fault and run vectored / unhandled exception handlers cleanly.
  2. 2 MiB stacks on XTaskQueue / XAsyncRun title callback workers and victory-pipelines workers:

    • CreateThread enforces MIN_STACK = 8 MiB (crates/victory-hle/src/host_posix.rs:64) because title code and native pipeline builds overflow smaller stacks, yet XTaskQueue (Port::Serialized, Pool, delayed Queue::submit) and XAsyncRun (crates/victory-hle/src/modules/xasync.rs) spawn plain 2 MiB std::thread::spawn threads to run title callbacks, and crates/victory-gpu/src/pipeline/make.rs spawns victory-pipelines workers with the default 2 MiB stack.
**@⁠Sheffy007** on GitHub · 2026-11-28 04:50 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/561) Refs #395, #525. 1. **Silent `SIGSEGV` (`exit code 139`) inside `seh::signal::on_signal` when a title thread overflows its stack or faults with an out-of-bounds `rsp`:** - `on_signal` (`crates/victory-loader/src/native/seh/signal.rs:457-470`) unconditionally writes `Context` and `ExceptionRecord` below the interrupted `rsp`. - If a title thread hits its stack guard page below `TEB[OFF_STACK_LIMIT]` or faults after `rsp` leaves `[OFF_STACK_LIMIT, OFF_STACK_BASE)`, `(ctx_at as *mut Context).write(ctx)` triggers a nested `SIGSEGV` inside `on_signal` while `SIGSEGV` is masked by the kernel, terminating the process immediately with `exit code 139` and no log output or unhandled-exception callback. - Allocating a per-TEB emergency dispatch stack and switching `ctx_at` / `rec_at` / `entry_rsp` onto it whenever `rsp > stack_base || entry_rsp < stack_limit` (while keeping the faulting `rsp` in `Context` and reporting `EXCEPTION_STACK_OVERFLOW` `0xC000_00FD` for guard-zone faults below `stack_limit`) lets `seh::dispatch` log the fault and run vectored / unhandled exception handlers cleanly. 2. **2 MiB stacks on `XTaskQueue` / `XAsyncRun` title callback workers and `victory-pipelines` workers:** - `CreateThread` enforces `MIN_STACK = 8 MiB` (`crates/victory-hle/src/host_posix.rs:64`) because title code and native pipeline builds overflow smaller stacks, yet `XTaskQueue` (`Port::Serialized`, `Pool`, delayed `Queue::submit`) and `XAsyncRun` (`crates/victory-hle/src/modules/xasync.rs`) spawn plain 2 MiB `std::thread::spawn` threads to run title callbacks, and `crates/victory-gpu/src/pipeline/make.rs` spawns `victory-pipelines` workers with the default 2 MiB stack.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 04:54:54 +00:00
Author
Owner

@⁠Sheffy007 on GitHub · 2026-11-28 04:50 UTC · original

/claim

**@⁠Sheffy007** on GitHub · 2026-11-28 04:50 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/561#issuecomment-7234294204) /claim
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-28 04:50 UTC · original

Claimed by @⁠Sheffy007. Open a draft pull request with Refs #561 in its description within 24 hours, or the claim expires.

**@⁠github-actions[bot]** on GitHub · 2026-11-28 04:50 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/561#issuecomment-7234295876) Claimed by @⁠Sheffy007. Open a draft pull request with `Refs #561` in its description within 24 hours, or the claim expires.
This discussion has been locked. Commenting is limited to contributors.
No description provided.