fix(libkernel): change the protection of guest thread stack pages #2982

Merged
TheAggie merged 3 commits from upstream-pr/2982 into main 2026-10-11 07:52:04 +00:00
TheAggie commented 2026-10-10 19:29:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-10T19:29:44Z.


What

On Windows a guest thread runs on its host thread's stack. That stack isn't a registered guest allocation, so mprotect on any of its pages failed with EINVAL. On the PS5 the stack is ordinary guest memory, and the protection change succeeds.

RetroArch's Dolphin core (PPSA99169) hits this at startup:

  • Its JIT read-protects 64 KiB at the bottom of its CPU thread's stack to catch stack overflows: protect 0x00000000e4f50000+0x10000 prot=0x0 with APS5_TRACE_MEMORY=1.
  • It gets EINVAL back and logs Warning - ReadProtectMemory failed! / mprotect: Invalid argument.

DoMprotect now uses the existing GuestThreadStack lookup, the one sceKernelIsStack uses:

  • Inside a stack: a range that lies within a live guest thread stack, with no GPU access requested, takes the native protection directly and is recorded as before.
  • Crossing a stack boundary: still rejected.
  • Anything else: unchanged.

Tested

  • New test: guest_kernel_stack_protect (core/libs/tests/GuestKernelStackProtect.cpp). A guest thread, through mprotect:

    • read-protects 64 KiB at the bottom of its own stack, and on Windows checks with VirtualQuery that the pages are PAGE_NOACCESS;
    • restores read/write and writes to both ends of the range;
    • checks that a range crossing below the stack still fails.

    With the DirectMemory.cpp change reverted, the test fails.

  • Suite: guest|kernel|memory|pthread|thread|stack|mmap|protect: 243 passed, 1 skipped, 1 failed. The failure is guest_memory, which fails the same way on main here (CheckGuestModuleImageProtection's dlopen).

  • RetroArch: with the Dolphin core and the GameCube 240p Test Suite, the warning is gone and the frame rate is unchanged.

    • Caveat: RetroArch can't run the Dolphin core on main alone yet. This run is from my integration branch: a main from 2026-10-07 plus my open PRs and others, with this commit cherry-picked unchanged.
  • Setup: Windows 11, MinGW-w64 GCC 15.2.0. Not run on Linux.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4813863643 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2982). Originally posted by [TheAggie](https://github.com/TheAggie) on 2026-10-10T19:29:44Z. --- ### What On Windows a guest thread runs on its host thread's stack. That stack isn't a registered guest allocation, so `mprotect` on any of its pages failed with `EINVAL`. On the PS5 the stack is ordinary guest memory, and the protection change succeeds. RetroArch's Dolphin core (PPSA99169) hits this at startup: - Its JIT read-protects 64 KiB at the bottom of its CPU thread's stack to catch stack overflows: `protect 0x00000000e4f50000+0x10000 prot=0x0` with `APS5_TRACE_MEMORY=1`. - It gets `EINVAL` back and logs `Warning - ReadProtectMemory failed!` / `mprotect: Invalid argument`. `DoMprotect` now uses the existing `GuestThreadStack` lookup, the one `sceKernelIsStack` uses: - **Inside a stack:** a range that lies within a live guest thread stack, with no GPU access requested, takes the native protection directly and is recorded as before. - **Crossing a stack boundary:** still rejected. - **Anything else:** unchanged. ### Tested - **New test:** `guest_kernel_stack_protect` (`core/libs/tests/GuestKernelStackProtect.cpp`). A guest thread, through `mprotect`: - read-protects 64 KiB at the bottom of its own stack, and on Windows checks with `VirtualQuery` that the pages are `PAGE_NOACCESS`; - restores read/write and writes to both ends of the range; - checks that a range crossing below the stack still fails. With the `DirectMemory.cpp` change reverted, the test fails. - **Suite:** `guest|kernel|memory|pthread|thread|stack|mmap|protect`: 243 passed, 1 skipped, 1 failed. The failure is `guest_memory`, which fails the same way on `main` here (`CheckGuestModuleImageProtection`'s `dlopen`). - **RetroArch:** with the Dolphin core and the GameCube 240p Test Suite, the warning is gone and the frame rate is unchanged. - Caveat: RetroArch can't run the Dolphin core on `main` alone yet. This run is from my integration branch: a `main` from 2026-10-07 plus my open PRs and others, with this commit cherry-picked unchanged. - **Setup:** Windows 11, MinGW-w64 GCC 15.2.0. Not run on Linux. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fma-rc commented 2026-10-10 22:00:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-10T22:00:26Z.


Built 934b986b on main 262c0316 on Linux (Arch, GCC 16.2.1, glibc); guest_kernel_stack_protect passes. Two things showed up when I changed the test:

The stack base that sceKernelIsStack returns is not page aligned here (start & 0x3fff is 0x3028). mprotect(start, 0x10000, 0) still returns -1 with this change, because the range gets rounded down below the stack and misses the new path. The test rounds low up, so it doesn't see that.

If a thread protects 64 KiB at the bottom of its stack with prot 0 and exits without restoring it, the next thread created gets the same stack range (glibc reuses it) and segfaults on a write to those pages. I ran two threads one after the other, the first only doing the mprotect, the second writing to the same address after checking it is inside its own sceKernelIsStack range.

Not checked on Windows.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6102629144 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2982#issuecomment-6102629144). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-10T22:00:26Z. --- Built 934b986b on main 262c0316 on Linux (Arch, GCC 16.2.1, glibc); `guest_kernel_stack_protect` passes. Two things showed up when I changed the test: The stack base that `sceKernelIsStack` returns is not page aligned here (`start & 0x3fff` is 0x3028). `mprotect(start, 0x10000, 0)` still returns -1 with this change, because the range gets rounded down below the stack and misses the new path. The test rounds `low` up, so it doesn't see that. If a thread protects 64 KiB at the bottom of its stack with prot 0 and exits without restoring it, the next thread created gets the same stack range (glibc reuses it) and segfaults on a write to those pages. I ran two threads one after the other, the first only doing the `mprotect`, the second writing to the same address after checking it is inside its own `sceKernelIsStack` range. Not checked on Windows.
adriadam10 commented 2026-10-10 23:41:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T23:41:57Z.

Review: CHANGES_REQUESTED


Thanks. The approach (reusing GuestThreadStack) is reasonable, but @fma-rc's Linux findings are real and still open:

  • DirectMemory.cpp:864: sceKernelIsStack can return a start that isn't page aligned (start & 0x3fff = 0x3028 on Linux). first is rounded down below stackStart, so mprotect(start, 0x10000, 0) still fails and never reaches the new path. Please decide how a range that touches the partial first page is handled (clamp to the page-aligned interior, or compare after aligning the stack bounds), and make the test call mprotect with the unrounded start instead of rounding low up (GuestKernelStackProtect.cpp:31).
  • A thread that exits with its stack pages left at prot=0 leaves them protected for the next thread that reuses the same stack (glibc does), which then segfaults on write. The protection needs to be undone when the thread's stack is released (or the call refused where the stack is host-owned), with a test that runs two threads in sequence, the first leaving the range protected.

Also please say in the description which of these paths were exercised on Linux, since the change applies there too and the test only had a Windows run.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5481215218 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2982#pullrequestreview-5481215218). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T23:41:57Z. **Review:** CHANGES_REQUESTED --- Thanks. The approach (reusing `GuestThreadStack`) is reasonable, but @fma-rc's Linux findings are real and still open: - `DirectMemory.cpp:864`: `sceKernelIsStack` can return a start that isn't page aligned (`start & 0x3fff` = 0x3028 on Linux). `first` is rounded down below `stackStart`, so `mprotect(start, 0x10000, 0)` still fails and never reaches the new path. Please decide how a range that touches the partial first page is handled (clamp to the page-aligned interior, or compare after aligning the stack bounds), and make the test call `mprotect` with the unrounded `start` instead of rounding `low` up (`GuestKernelStackProtect.cpp:31`). - A thread that exits with its stack pages left at `prot=0` leaves them protected for the next thread that reuses the same stack (glibc does), which then segfaults on write. The protection needs to be undone when the thread's stack is released (or the call refused where the stack is host-owned), with a test that runs two threads in sequence, the first leaving the range protected. Also please say in the description which of these paths were exercised on Linux, since the change applies there too and the test only had a Windows run.
TheAggie commented 2026-10-11 00:18:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-11T00:18:43Z.


Thanks @fma-rc, both are real. Fixed in 2ec306de:

  1. Unaligned stack base: DoMprotect now checks the range the guest asked for against GuestThreadStack, not the range after rounding down. It then protects the rounded pages, as FreeBSD rounds the address down. So mprotect(start, 0x10000, 0) with start & 0x3fff == 0x3028 takes the stack path.
  2. Guard left on exit: the stack path records protected stack pages, and a later read/write mprotect of the same pages clears the record. When a thread's stack is unregistered at exit, every recorded range that overlaps it is made readable and writable again. So a reused stack starts clean.

guest_kernel_stack_protect now also protects from the unaligned sceKernelIsStack start, and runs your two-thread case: one thread leaves its guard in place and exits, and a second thread writes to that address if its own stack covers it.

Both cases only show up on Linux. On Windows here the stack base is page-aligned and a new thread never reuses a dead one's stack, so the new checks pass there but can't fail. Could you rerun your two cases on Linux?

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6103683449 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2982#issuecomment-6103683449). Originally posted by [TheAggie](https://github.com/TheAggie) on 2026-10-11T00:18:43Z. --- Thanks @fma-rc, both are real. Fixed in 2ec306de: 1. **Unaligned stack base:** `DoMprotect` now checks the range the guest asked for against `GuestThreadStack`, not the range after rounding down. It then protects the rounded pages, as FreeBSD rounds the address down. So `mprotect(start, 0x10000, 0)` with `start & 0x3fff == 0x3028` takes the stack path. 2. **Guard left on exit:** the stack path records protected stack pages, and a later read/write `mprotect` of the same pages clears the record. When a thread's stack is unregistered at exit, every recorded range that overlaps it is made readable and writable again. So a reused stack starts clean. `guest_kernel_stack_protect` now also protects from the unaligned `sceKernelIsStack` start, and runs your two-thread case: one thread leaves its guard in place and exits, and a second thread writes to that address if its own stack covers it. Both cases only show up on Linux. On Windows here the stack base is page-aligned and a new thread never reuses a dead one's stack, so the new checks pass there but can't fail. Could you rerun your two cases on Linux? AI-assisted (Claude Code).
adriadam10 commented 2026-10-11 07:05:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T07:05:46Z.

Review: CHANGES_REQUESTED


Thanks, the two Linux cases from @fma-rc are covered now. Checked on Linux (PR merged onto main): guest_kernel_stack_protect passes and fails with the non-test changes reverted. Remaining points:

  • DirectMemory.cpp:864-867: the range is checked against the stack unrounded, but first/bytes are rounded down, so the partial page below stackStart (not part of the stack; start & 0x3fff == 0x3028 on Linux) gets prot=0 and is recorded. UnregisterStack (Thread.cpp:150-153) then makes it RW at thread exit, which can drop a guard page or the permissions of whatever neighbours the stack. Please clamp the native mprotect and the recorded range to the part inside [stackStart, stackEnd) rounded inwards (or only record/restore pages fully inside the stack), and add a test that the page just below start keeps its protection.
  • Thread.cpp:152: RestoreStackPages can throw while stackLock is held, from the thread-exit path. Failing to restore at exit shouldn't unwind there; ignore/log the error and keep going so the lock is released and the entry removed.
  • Please keep the Linux-only reuse check deterministic if you can (it only exercises the restore when the allocator hands the same stack to the second thread; the test passes either way).
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5482274580 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2982#pullrequestreview-5482274580). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T07:05:46Z. **Review:** CHANGES_REQUESTED --- Thanks, the two Linux cases from @fma-rc are covered now. Checked on Linux (PR merged onto main): `guest_kernel_stack_protect` passes and fails with the non-test changes reverted. Remaining points: - `DirectMemory.cpp:864-867`: the range is checked against the stack unrounded, but `first`/`bytes` are rounded down, so the partial page below `stackStart` (not part of the stack; `start & 0x3fff == 0x3028` on Linux) gets `prot=0` and is recorded. `UnregisterStack` (`Thread.cpp:150-153`) then makes it RW at thread exit, which can drop a guard page or the permissions of whatever neighbours the stack. Please clamp the native `mprotect` and the recorded range to the part inside `[stackStart, stackEnd)` rounded inwards (or only record/restore pages fully inside the stack), and add a test that the page just below `start` keeps its protection. - `Thread.cpp:152`: `RestoreStackPages` can throw while `stackLock` is held, from the thread-exit path. Failing to restore at exit shouldn't unwind there; ignore/log the error and keep going so the lock is released and the entry removed. - Please keep the Linux-only reuse check deterministic if you can (it only exercises the restore when the allocator hands the same stack to the second thread; the test passes either way).
TheAggie commented 2026-10-11 07:36:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-11T07:36:29Z.


Thanks @adriadam10. All three are in f38408ef, on top of a rebase onto main 5c7ceb07:

  1. Partial page below the stack: the stack path now only touches host pages that lie fully inside [stackStart, stackEnd). The start is rounded up and the end rounded down to 4 KiB, and both the native mprotect and the recorded range use that. If nothing is left, the call returns 0 without changing anything. So the page that holds stackStart - 1 is never protected, recorded or restored.
  2. Restore at exit: RestoreStackPages is noexcept now. If the host call fails it prints one line to stderr and the loop carries on, so stackLock is released and the entry is removed either way.
  3. Reuse check: thread stacks here are the host's, so I can't make the second thread land on the first one's stack. Instead the test now checks the left guard directly after the first thread is joined: each of its pages is either no longer mapped or writable again (/proc/self/maps on Linux, VirtualQuery on Windows). That doesn't depend on the allocator. The second-thread write is still there as well.

The test also reads the protection of the byte at start - 1 before and after mprotect(start, 0x10000, 0) and after setting it back, and requires it unchanged.

On Windows the stack base is page-aligned, so the start - 1 check passes with or without the clamp here; it can only fail on Linux. guest_kernel_stack_protect and the guest_pthread*, guest_thread* and guest_signal tests pass on Windows 11. Could you rerun it on Linux, with the clamp reverted too?

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6106739436 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2982#issuecomment-6106739436). Originally posted by [TheAggie](https://github.com/TheAggie) on 2026-10-11T07:36:29Z. --- Thanks @adriadam10. All three are in f38408ef, on top of a rebase onto `main` 5c7ceb07: 1. **Partial page below the stack:** the stack path now only touches host pages that lie fully inside `[stackStart, stackEnd)`. The start is rounded up and the end rounded down to 4 KiB, and both the native `mprotect` and the recorded range use that. If nothing is left, the call returns 0 without changing anything. So the page that holds `stackStart - 1` is never protected, recorded or restored. 2. **Restore at exit:** `RestoreStackPages` is `noexcept` now. If the host call fails it prints one line to stderr and the loop carries on, so `stackLock` is released and the entry is removed either way. 3. **Reuse check:** thread stacks here are the host's, so I can't make the second thread land on the first one's stack. Instead the test now checks the left guard directly after the first thread is joined: each of its pages is either no longer mapped or writable again (`/proc/self/maps` on Linux, `VirtualQuery` on Windows). That doesn't depend on the allocator. The second-thread write is still there as well. The test also reads the protection of the byte at `start - 1` before and after `mprotect(start, 0x10000, 0)` and after setting it back, and requires it unchanged. On Windows the stack base is page-aligned, so the `start - 1` check passes with or without the clamp here; it can only fail on Linux. `guest_kernel_stack_protect` and the `guest_pthread*`, `guest_thread*` and `guest_signal` tests pass on Windows 11. Could you rerun it on Linux, with the clamp reverted too? AI-assisted (Claude Code).
fma-rc commented 2026-10-11 07:39:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-11T07:39:05Z.


Reran on Linux (Arch, GCC 16.2.1, glibc) at f38408ef, built on its own base: guest_kernel_stack_protect passes 10 of 10 repeats, and it aborts when I put DirectMemory.cpp, Pthread.hpp and Thread.cpp back to the merge base.

With a temporary print in the test, five runs: start & 0x3fff is 0x2c28 and mprotect(start, 0x10000, 0) returns 0. In every run the second thread got the first one's stack range (same sceKernelIsStack start), its stack covered the guard address and the write happened, so the reuse case is really exercised here.

One thing about the test: WriteLeftGuard only writes when the stack covers the address and nothing checks that it did, so on a host that does not reuse the range that part passes without testing anything.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6106758650 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2982#issuecomment-6106758650). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-11T07:39:05Z. --- Reran on Linux (Arch, GCC 16.2.1, glibc) at f38408ef, built on its own base: `guest_kernel_stack_protect` passes 10 of 10 repeats, and it aborts when I put `DirectMemory.cpp`, `Pthread.hpp` and `Thread.cpp` back to the merge base. With a temporary print in the test, five runs: `start & 0x3fff` is 0x2c28 and `mprotect(start, 0x10000, 0)` returns 0. In every run the second thread got the first one's stack range (same `sceKernelIsStack` start), its stack covered the guard address and the write happened, so the reuse case is really exercised here. One thing about the test: `WriteLeftGuard` only writes when the stack covers the address and nothing checks that it did, so on a host that does not reuse the range that part passes without testing anything.
adriadam10 commented 2026-10-11 07:52:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T07:52:01Z.

Review: APPROVED


Checked on Linux (PR merged onto main): guest_kernel_stack_protect passes 10/10 and fails with the non-test changes reverted. Confirmed by @fma-rc on Arch/glibc, including the stack-reuse case. The partial page below the stack and the restore at thread exit are both handled now; merging.

Non-blocking: WriteLeftGuard doesn't assert that its stack covered the guard address, so on a host that doesn't reuse the range that part tests nothing. Windows behaviour (VirtualQuery/VirtualProtect) is taken from the author's run.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5482437017 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2982#pullrequestreview-5482437017). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T07:52:01Z. **Review:** APPROVED --- Checked on Linux (PR merged onto main): `guest_kernel_stack_protect` passes 10/10 and fails with the non-test changes reverted. Confirmed by @fma-rc on Arch/glibc, including the stack-reuse case. The partial page below the stack and the restore at thread exit are both handled now; merging. Non-blocking: `WriteLeftGuard` doesn't assert that its stack covered the guard address, so on a host that doesn't reuse the range that part tests nothing. Windows behaviour (`VirtualQuery`/`VirtualProtect`) is taken from the author's run.
orishamir commented 2026-10-11 09:55:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by orishamir on 2026-10-11T09:55:14Z.


guest_kernel_stack_protect aborts in CI's linux job in every completed run since this merged (38124809181 at 08:26Z through 38128072167 at 09:21Z; the 06:09Z run predates the merge), as Subprocess aborted right after the worker thread starts. It reproduces in a replica of the job (ubuntu 24.04, GCC 13.3, glibc 2.39; main a73a1af9 and ccf9ff90), 4/4, and it does not depend on #1423 (not in the first failing run) or #3227 (already in the base @fma-rc's Arch run passed on).

Under gdb the abort comes from libc's own unwinder resuming the exception the test expects:

#2  abort ()
#3  _Unwind_Resume_nid_postfix ()                          libc.prx   (LibcUnwind::Step returned false)
#4  GuestAllocations::(anonymous namespace)::replaceRange(...) [clone .cold] + 154   libc.prx
#5  GuestAllocationsProtect_nid_postfix + 116               libc.prx
#6  DoMprotect(void const*, unsigned long, int)             libkernel.prx
#7  mprotect_nid_postfix                                    libkernel.prx
#8  Worker(void*)                                           guest_kernel_stack_protect_tests

So the throw from replaceRange reaches its cleanup landing pad in the GCC 13 cold partition (.text 0x21eee..0x220d6 in libc.prx, which has its own FDE with a plain def_cfa_offset 224 and six callee-saved offsets) and _Unwind_Resume cannot step from there to GuestAllocationsProtect. With GCC 16 on Arch the test passes 10/10 per the comment above, so it is the unwinder against GCC 13's code for this function, not the stack logic; rebuilding only GuestAllocations.cpp with -fno-reorder-blocks-and-partition did not change the result in my replica, so I have no fix to suggest, only the stop and the frames.

AI-assisted: yes (Claude Code Fable 5.1 xhigh)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6107787843 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2982#issuecomment-6107787843). Originally posted by [orishamir](https://github.com/orishamir) on 2026-10-11T09:55:14Z. --- `guest_kernel_stack_protect` aborts in CI's `linux` job in every completed run since this merged ([38124809181](https://github.com/boykopovar/AnyPS5/actions/runs/38124809181) at 08:26Z through [38128072167](https://github.com/boykopovar/AnyPS5/actions/runs/38128072167) at 09:21Z; the 06:09Z run predates the merge), as `Subprocess aborted` right after the worker thread starts. It reproduces in a replica of the job (ubuntu 24.04, GCC 13.3, glibc 2.39; `main` a73a1af9 and ccf9ff90), 4/4, and it does not depend on #1423 (not in the first failing run) or #3227 (already in the base @fma-rc's Arch run passed on). Under gdb the abort comes from libc's own unwinder resuming the exception the test expects: ``` #2 abort () #3 _Unwind_Resume_nid_postfix () libc.prx (LibcUnwind::Step returned false) #4 GuestAllocations::(anonymous namespace)::replaceRange(...) [clone .cold] + 154 libc.prx #5 GuestAllocationsProtect_nid_postfix + 116 libc.prx #6 DoMprotect(void const*, unsigned long, int) libkernel.prx #7 mprotect_nid_postfix libkernel.prx #8 Worker(void*) guest_kernel_stack_protect_tests ``` So the throw from `replaceRange` reaches its cleanup landing pad in the GCC 13 cold partition (`.text` 0x21eee..0x220d6 in `libc.prx`, which has its own FDE with a plain `def_cfa_offset 224` and six callee-saved offsets) and `_Unwind_Resume` cannot step from there to `GuestAllocationsProtect`. With GCC 16 on Arch the test passes 10/10 per the comment above, so it is the unwinder against GCC 13's code for this function, not the stack logic; rebuilding only `GuestAllocations.cpp` with `-fno-reorder-blocks-and-partition` did not change the result in my replica, so I have no fix to suggest, only the stop and the frames. AI-assisted: yes (Claude Code Fable 5.1 xhigh)
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!2982
No description provided.