fix(libkernel): bound the raise wait on host code to 50 ms #8512

Merged
oneandonlydean merged 1 commit from upstream-pr/8512 into main 2026-10-20 18:00:13 +00:00
oneandonlydean commented 2026-10-20 14:22:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T14:22:52Z.


Follow-up to #7652.

What

A raise on a thread that is running host code waited up to the 1 s RetryLimit for the thread to reach guest code before falling back. Windows guest_raise_exception raises against targets that loop in HLE libraries, the CRT and kernelbase about 110 times since #8390 halved its rounds (about 220 before), so the lane takes 18-20 s on current main against about 7.5 s for the same rounds before #7652, and it timed out at 30 s before #8390 (6 of 10 runs on bases containing 437de6392f).

Host code now has its own HostCodeLimit of 50 ms. The raise breaks out and redirects in place once the target has been seen in host code past that deadline. The 1 s RetryLimit is unchanged for a target inside NtContinue or winpthreads (the throw). The #7652 fix stays: a guest window comes around far more often than every 50 ms in guest_raise_in_host_code, and a short host call such as the stderr write is the case the 50 ms covers.

Linux is unaffected: the change is inside #ifdef _WIN32.

Tested

No Windows host here, so this is not measured locally. Needed from CI (3 full runs): Windows guest_raise_exception at about 8-13 s (about 7.5 s plus at most 110 × 50 ms of host-code waits) with every run under 20 s and no timeout; guest_raise_in_host_code, guest_raise_nested_sleep and guest_mutex_raise_exception Passed.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: Windows CI guest_raise_exception on main
  • GPUs tested: none (no GPU code touched)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4937193529 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8512). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T14:22:52Z. --- Follow-up to #7652. ### What A raise on a thread that is running host code waited up to the 1 s `RetryLimit` for the thread to reach guest code before falling back. Windows `guest_raise_exception` raises against targets that loop in HLE libraries, the CRT and kernelbase about 110 times since #8390 halved its rounds (about 220 before), so the lane takes 18-20 s on current `main` against about 7.5 s for the same rounds before #7652, and it timed out at 30 s before #8390 (6 of 10 runs on bases containing 437de6392f). Host code now has its own `HostCodeLimit` of 50 ms. The raise breaks out and redirects in place once the target has been seen in host code past that deadline. The 1 s `RetryLimit` is unchanged for a target inside NtContinue or winpthreads (the throw). The #7652 fix stays: a guest window comes around far more often than every 50 ms in `guest_raise_in_host_code`, and a short host call such as the stderr write is the case the 50 ms covers. Linux is unaffected: the change is inside `#ifdef _WIN32`. ### Tested No Windows host here, so this is not measured locally. Needed from CI (3 full runs): Windows `guest_raise_exception` at about 8-13 s (about 7.5 s plus at most 110 × 50 ms of host-code waits) with every run under 20 s and no timeout; `guest_raise_in_host_code`, `guest_raise_nested_sleep` and `guest_mutex_raise_exception` Passed. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: Windows CI `guest_raise_exception` on main - [x] GPUs tested: none (no GPU code touched) - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-20 14:32:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T14:32:48Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 7192 core/libs/prx/libkernel/System/src/Exception.cpp L394-396
PR 8539 core/libs/prx/libkernel/System/src/Exception.cpp L194, L396, L426

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 4630 core/libs/prx/libkernel/System/src/Exception.cpp
PR 5021 core/libs/prx/libkernel/System/src/Exception.cpp
PR 7201 core/libs/prx/libkernel/System/src/Exception.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6293323247 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8512#issuecomment-6293323247). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-20T14:32:48Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 7192](https://www.github.com/boykopovar/AnyPS5/pull/7192) | `core/libs/prx/libkernel/System/src/Exception.cpp` [L394-396](https://github.com/boykopovar/AnyPS5/blob/1a48337f138657fb349c6e7994735a22c2da93ab/core/libs/prx/libkernel/System/src/Exception.cpp#L394-L396) | | | | [PR 8539](https://www.github.com/boykopovar/AnyPS5/pull/8539) | `core/libs/prx/libkernel/System/src/Exception.cpp` [L194](https://github.com/boykopovar/AnyPS5/blob/1a48337f138657fb349c6e7994735a22c2da93ab/core/libs/prx/libkernel/System/src/Exception.cpp#L194), [L396](https://github.com/boykopovar/AnyPS5/blob/1a48337f138657fb349c6e7994735a22c2da93ab/core/libs/prx/libkernel/System/src/Exception.cpp#L396), [L426](https://github.com/boykopovar/AnyPS5/blob/1a48337f138657fb349c6e7994735a22c2da93ab/core/libs/prx/libkernel/System/src/Exception.cpp#L426) | | | Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 4630](https://www.github.com/boykopovar/AnyPS5/pull/4630) | `core/libs/prx/libkernel/System/src/Exception.cpp` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libkernel/System/src/Exception.cpp` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libkernel/System/src/Exception.cpp` |
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
boykopovar/AnyPS5!8512
No description provided.