linux CI: guest_kernel_stack_protect aborts on main since #2982 (libc unwinder, GCC 13 only) #3459

Closed
opened 2026-10-11 10:59:09 +00:00 by orishamir · 4 comments
orishamir commented 2026-10-11 10:59:09 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by orishamir on 2026-10-11T10:59:09Z.


guest_kernel_stack_protect (added by #2982, merged 07:52Z Oct 11) aborts in CI's linux job in every completed run on main since, from 38123701690 (08:07Z, f60923bf) to 38131389299 (10:16Z, e7827eb4), and in contributors' fork CI runs (#3394 and #3451-#3453 list it as a failure from main):

guest_kernel_stack_protect ....Subprocess aborted***Exception:   0.00 sec

It fails the same way in a container that mirrors the job (ubuntu 24.04, GCC 13.3, glibc 2.39) on main 74981fab, in 6 of 6 full-suite runs. It passes on Arch with GCC 16.2.1 (@fma-rc's run on #2982), so it depends on the toolchain.

The abort is libc's own unwinder: _Unwind_Resume in libc.prx cannot step (LibcUnwind::Step returns false) out of the GCC 13 cold partition of GuestAllocations::replaceRange while resuming the exception that mprotect from the test's worker thread is expected to report. The frames and the FDE are in my comment on #2982. I have not found the cause in the unwinder and have no fix.

@TheAggie, since the test is yours.

AI-assisted: yes (Claude Code Opus 5.5 xhigh)

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5800433135 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3459). Originally posted by [orishamir](https://github.com/orishamir) on 2026-10-11T10:59:09Z. --- `guest_kernel_stack_protect` (added by #2982, merged 07:52Z Oct 11) aborts in CI's `linux` job in every completed run on `main` since, from [38123701690](https://github.com/boykopovar/AnyPS5/actions/runs/38123701690) (08:07Z, f60923bf) to [38131389299](https://github.com/boykopovar/AnyPS5/actions/runs/38131389299) (10:16Z, e7827eb4), and in contributors' fork CI runs (#3394 and #3451-#3453 list it as a failure from `main`): ``` guest_kernel_stack_protect ....Subprocess aborted***Exception: 0.00 sec ``` It fails the same way in a container that mirrors the job (ubuntu 24.04, GCC 13.3, glibc 2.39) on `main` 74981fab, in 6 of 6 full-suite runs. It passes on Arch with GCC 16.2.1 (@fma-rc's run on #2982), so it depends on the toolchain. The abort is libc's own unwinder: `_Unwind_Resume` in `libc.prx` cannot step (`LibcUnwind::Step` returns false) out of the GCC 13 cold partition of `GuestAllocations::replaceRange` while resuming the exception that `mprotect` from the test's worker thread is expected to report. The frames and the FDE are in [my comment on #2982](https://github.com/boykopovar/AnyPS5/pull/2982#issuecomment-6107787843). I have not found the cause in the unwinder and have no fix. @TheAggie, since the test is yours. AI-assisted: yes (Claude Code Opus 5.5 xhigh)
LeandroSSB commented 2026-10-11 13:33:23 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by LeandroSSB on 2026-10-11T13:33:23Z.


The root cause is not the cold partition's FDE — it is mixed host/guest unwinding — and a fix is on my fork: LeandroSSB/AnyPS5:fix/libc-unwind-cold-partition (one commit, d8b0e3410, cherry-picked clean onto current main a11c8f7f7).

What actually fails. Non-Apple executables link -static -static-libgcc -static-libstdc++ (CMakeLists.txt:36-38), and the ones that link libkernel.prx end up defining the host exception runtime in the executable: the link map shows eh_ptr.o pulled for libkernel.prx, so the exe exports __cxa_throw/__gxx_personality_v0. A throw from inside libc.prx (replaceRange) therefore raises a GNUC++-class exception through the host runtime (LD_DEBUG=bindings: libc.prx → exe for __cxa_throw), while the landing pad's _Unwind_Resume still binds to libc's own export (→ libc.prx). libc's personality cannot type-match the foreign class at the typed handler in GuestAllocationsProtect → _URC_FATAL_PHASE2_ERROR → abort. I traced the cold FDE first: it is found via eh_frame_hdr and stepped correctly, so the issue's FDE premise was a red herring — which also explains why -fno-reorder-blocks-and-partition changed nothing, and why the frame shows the cold partition at all (host phase 2 parked the cleanup there). The GCC 16/Arch pass is the same coin: which static libstdc++ members the linker pulls differs by toolchain — merely adding a try/catch to a test TU flips the bindings (recorded in TechnicalDebt; don't "fix" such tests by editing them).

Fix. _Unwind_Resume_nid_postfix delegates only the host GNUC++ class pair (0x474e5543432b2b00 and its dependent) to the host unwinder that follows libc in the link map (dlsym(RTLD_NEXT, ...), native fallback when there is none); every other class resumes natively as before, so class-0 forced unwinds stay on libc's stop protocol. _Unwind_RaiseException and _Unwind_Resume_or_Rethrow never delegate — the host unwinder would call the personality recorded in the CIE with a host _Unwind_Context whose layout libc's personality does not share (verified by experiment). Two lines plus two helpers; ExceptionPersonality pins the class predicate; the constraints and the residual guest-rethrow-of-host-class gap are in TechnicalDebt.

Tested in a container mirroring the CI job (ubuntu 24.04, GCC 13.3, glibc 2.39): guest_kernel_stack_protect aborts on pure main a11c8f7f7 and passes with the commit; the exception/cancel set (exception_personality, exception_runtime, c_cleanup, guest_pthread_cancel*, kernel_errors) passes 8/8; the full suite's failure set is identical before and after on a pristine rebuild (import_audit plus the environment's agc lavapipe flakes; guest_truncate also aborts on pristine main in this container, in an in-exe std::filesystem .cold — unwinder-unrelated, may deserve its own look).

Not opened as a PR because of the intake pause; a maintainer is welcome to carry the commit.

AI-assisted (Claude Code); I reviewed the change and ran everything above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6109568995 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3459#issuecomment-6109568995). Originally posted by [LeandroSSB](https://github.com/LeandroSSB) on 2026-10-11T13:33:23Z. --- The root cause is not the cold partition's FDE — it is mixed host/guest unwinding — and a fix is on my fork: [`LeandroSSB/AnyPS5:fix/libc-unwind-cold-partition`](https://github.com/LeandroSSB/AnyPS5/tree/fix/libc-unwind-cold-partition) (one commit, `d8b0e3410`, cherry-picked clean onto current `main` `a11c8f7f7`). **What actually fails.** Non-Apple executables link `-static -static-libgcc -static-libstdc++` (CMakeLists.txt:36-38), and the ones that link `libkernel.prx` end up defining the host exception runtime in the executable: the link map shows `eh_ptr.o` pulled for `libkernel.prx`, so the exe exports `__cxa_throw`/`__gxx_personality_v0`. A throw from inside `libc.prx` (`replaceRange`) therefore raises a `GNUC++`-class exception through the **host** runtime (`LD_DEBUG=bindings`: `libc.prx → exe` for `__cxa_throw`), while the landing pad's `_Unwind_Resume` still binds to **libc's own export** (`→ libc.prx`). libc's personality cannot type-match the foreign class at the typed handler in `GuestAllocationsProtect` → `_URC_FATAL_PHASE2_ERROR` → abort. I traced the cold FDE first: it is found via `eh_frame_hdr` and stepped correctly, so the issue's FDE premise was a red herring — which also explains why `-fno-reorder-blocks-and-partition` changed nothing, and why the frame shows the cold partition at all (host phase 2 parked the cleanup there). The GCC 16/Arch pass is the same coin: which static libstdc++ members the linker pulls differs by toolchain — merely adding a try/catch to a test TU flips the bindings (recorded in TechnicalDebt; don't "fix" such tests by editing them). **Fix.** `_Unwind_Resume_nid_postfix` delegates only the host `GNUC++` class pair (`0x474e5543432b2b00` and its dependent) to the host unwinder that follows libc in the link map (`dlsym(RTLD_NEXT, ...)`, native fallback when there is none); every other class resumes natively as before, so class-0 forced unwinds stay on libc's stop protocol. `_Unwind_RaiseException` and `_Unwind_Resume_or_Rethrow` never delegate — the host unwinder would call the personality recorded in the CIE with a host `_Unwind_Context` whose layout libc's personality does not share (verified by experiment). Two lines plus two helpers; `ExceptionPersonality` pins the class predicate; the constraints and the residual guest-rethrow-of-host-class gap are in TechnicalDebt. **Tested** in a container mirroring the CI job (ubuntu 24.04, GCC 13.3, glibc 2.39): `guest_kernel_stack_protect` aborts on pure `main` `a11c8f7f7` and passes with the commit; the exception/cancel set (`exception_personality`, `exception_runtime`, `c_cleanup`, `guest_pthread_cancel*`, `kernel_errors`) passes 8/8; the full suite's failure set is identical before and after on a pristine rebuild (`import_audit` plus the environment's agc lavapipe flakes; `guest_truncate` also aborts on pristine main in this container, in an in-exe `std::filesystem` `.cold` — unwinder-unrelated, may deserve its own look). Not opened as a PR because of the intake pause; a maintainer is welcome to carry the commit. AI-assisted (Claude Code); I reviewed the change and ran everything above on my machine.
LeandroSSB commented 2026-10-11 15:19:09 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by LeandroSSB on 2026-10-11T15:19:09Z.


Small nudge in case this slipped past: the commit above is cherry-pick-clean onto current main and turns the last unaddressed red of the Linux CI job green — verified in a CI-mirror container (ubuntu 24.04, GCC 13.3, lavapipe): pure main a11c8f7f7 aborts guest_kernel_stack_protect, main + d8b0e3410 passes it and the exception/cancel set 8/8, with the full-suite failure set otherwise identical. The other two current reds are covered by open PRs (#3526 → #3532, #3630 → #3418), so this one is what is missing for main to go green again. If a collaborator wants to carry it (intake is paused for me), the branch is one commit on top of current main.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110511953 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3459#issuecomment-6110511953). Originally posted by [LeandroSSB](https://github.com/LeandroSSB) on 2026-10-11T15:19:09Z. --- Small nudge in case this slipped past: the commit above is cherry-pick-clean onto current `main` and turns the last unaddressed red of the Linux CI job green — verified in a CI-mirror container (ubuntu 24.04, GCC 13.3, lavapipe): pure `main` `a11c8f7f7` aborts `guest_kernel_stack_protect`, `main` + `d8b0e3410` passes it and the exception/cancel set 8/8, with the full-suite failure set otherwise identical. The other two current reds are covered by open PRs (#3526 → #3532, #3630 → #3418), so this one is what is missing for main to go green again. If a collaborator wants to carry it (intake is paused for me), the branch is one commit on top of current main.
Silverash-i8 commented 2026-10-11 18:01:13 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Silverash-i8 on 2026-10-11T18:01:13Z.


@LeandroSSB I checked d8b0e3410 on top of main a11c8f7f on both platforms.

Linux (WSL2 Ubuntu 22.04, glibc 2.35, GCC 13.4.0 from the toolchain PPA, Release, BUILD_TESTING=ON), so a different GCC 13 build and glibc from your CI-mirror container:

  • main: guest_kernel_stack_protect aborts (Subprocess aborted), as in your run.
  • With the commit: it passes 5 of 5 (--repeat until-fail:5), and exception_runtime, exception_personality, exception_c_cleanup, the three guest_pthread_cancel* tests and guest_kernel_errors pass 7 of 7.
  • All tests except agc_driver*: 533 of 535. The two failures come from this environment and don't reach AnyPS5 code: pr_overlap_encoding uses subprocess._text_encoding, which Python 3.10 doesn't have, and linux_executable_exports stops compiling its own C probe (RTLD_DEFAULT undeclared).

Windows (11 Home 26200, WinLibs GCC 15.2.0 r7, Release): HostUnwindEntry returns null there, so _Unwind_Resume keeps its native path, and the results match main. All tests except agc_driver*: 537 of 540, failing only windows_exceptions (#3411), guest_filesystem (#3518) and guest_kernel_sys (#3510), as on main. guest_kernel_stack_protect, the guest_pthread_cancel* tests and guest_kernel_errors pass. The three exception_* tests above aren't registered on Windows.

I can't carry it either (intake), but from both runs it does what you describe, with no change on Windows.

AI-assisted (Claude Code); I ran the above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6112003331 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3459#issuecomment-6112003331). Originally posted by [Silverash-i8](https://github.com/Silverash-i8) on 2026-10-11T18:01:13Z. --- @LeandroSSB I checked `d8b0e3410` on top of `main` `a11c8f7f` on both platforms. **Linux** (WSL2 Ubuntu 22.04, glibc 2.35, GCC 13.4.0 from the toolchain PPA, Release, `BUILD_TESTING=ON`), so a different GCC 13 build and glibc from your CI-mirror container: - `main`: `guest_kernel_stack_protect` aborts (`Subprocess aborted`), as in your run. - With the commit: it passes 5 of 5 (`--repeat until-fail:5`), and `exception_runtime`, `exception_personality`, `exception_c_cleanup`, the three `guest_pthread_cancel*` tests and `guest_kernel_errors` pass 7 of 7. - All tests except `agc_driver*`: 533 of 535. The two failures come from this environment and don't reach AnyPS5 code: `pr_overlap_encoding` uses `subprocess._text_encoding`, which Python 3.10 doesn't have, and `linux_executable_exports` stops compiling its own C probe (`RTLD_DEFAULT` undeclared). **Windows** (11 Home 26200, WinLibs GCC 15.2.0 r7, Release): `HostUnwindEntry` returns null there, so `_Unwind_Resume` keeps its native path, and the results match `main`. All tests except `agc_driver*`: 537 of 540, failing only `windows_exceptions` (#3411), `guest_filesystem` (#3518) and `guest_kernel_sys` (#3510), as on `main`. `guest_kernel_stack_protect`, the `guest_pthread_cancel*` tests and `guest_kernel_errors` pass. The three `exception_*` tests above aren't registered on Windows. I can't carry it either (intake), but from both runs it does what you describe, with no change on Windows. AI-assisted (Claude Code); I ran the above on my machine.
LeandroSSB commented 2026-10-11 18:09:11 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by LeandroSSB on 2026-10-11T18:09:11Z.


Thanks for the cross-check — and the Windows half settles a designed-in assumption: the TechnicalDebt entry's fallback ("with no host unwinder after libc it also falls back to the native path") was reasoning, and your run measures it — HostUnwindEntry null → native resume → results byte-identical to main, so the commit is a strict Linux-only behavior change by construction, not just by observation. With your GCC 13.4 build and my CI-mirror 13.3 both red→green and Windows unchanged, the commit is carry-ready as it stands (d8b0e3410, cherry-pick-clean on a11c8f7f).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6112077675 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3459#issuecomment-6112077675). Originally posted by [LeandroSSB](https://github.com/LeandroSSB) on 2026-10-11T18:09:11Z. --- Thanks for the cross-check — and the Windows half settles a designed-in assumption: the TechnicalDebt entry's fallback ("with no host unwinder after libc it also falls back to the native path") was reasoning, and your run measures it — `HostUnwindEntry` null → native resume → results byte-identical to `main`, so the commit is a strict Linux-only behavior change by construction, not just by observation. With your GCC 13.4 build and my CI-mirror 13.3 both red→green and Windows unchanged, the commit is carry-ready as it stands (`d8b0e3410`, cherry-pick-clean on `a11c8f7f`).
Sign in to join this conversation.
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#3459
No description provided.