test(libc): keep Windows exception cleanup coverage on guest frames #3415

Merged
MarcZX10 merged 1 commit from upstream-pr/3415 into main 2026-10-11 19:59:34 +00:00
MarcZX10 commented 2026-10-11 09:53:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T09:53:33Z.


What

The Windows windows_exceptions test used std::call_once to make an exception cross WinLibs runtime DLL frames. On the reported WinLibs GCC 15.2 toolchain, libstdc++-6.dll and libwinpthread-1.dll have empty .eh_frame sections and carry SEH unwind metadata in .pdata/.xdata; AnyPS5's Itanium unwinder reads .ehmeta and .ehfram, so it cannot unwind those frames. The prior VirtualQuery image lookup change did not solve that gap and has been removed.

The test now throws through recursive guest frames with supported unwind tables and checks that all 65 stack guards are destroyed at depths 0, 1, 7 and 64. TechnicalDebt records that stepping through SEH-only runtime frames and their cleanup handlers remains unimplemented. This change corrects the regression test; it does not claim SEH unwinder support. Refs #3411; #3411 stays open. Exceptions still cannot cross the reported SEH-only runtime frames, and this test no longer covers that path.

Tested

  • python3 tools/check_conventions.py --base upstream/main passed.
  • git diff --check upstream/main...HEAD passed.
  • The Windows-only windows_exceptions executable could not be run locally because this workspace has no MinGW toolchain or Windows runtime. A manual full Build run on this PR is pending.

Checklist

  • One topic per PR
  • No comments in code except technical debt
  • No investigation notes, reports, screenshots or logs added to the repository
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4818188991 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3415). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T09:53:33Z. --- ### What The Windows `windows_exceptions` test used `std::call_once` to make an exception cross WinLibs runtime DLL frames. On the reported WinLibs GCC 15.2 toolchain, `libstdc++-6.dll` and `libwinpthread-1.dll` have empty `.eh_frame` sections and carry SEH unwind metadata in `.pdata`/`.xdata`; AnyPS5's Itanium unwinder reads `.ehmeta` and `.ehfram`, so it cannot unwind those frames. The prior `VirtualQuery` image lookup change did not solve that gap and has been removed. The test now throws through recursive guest frames with supported unwind tables and checks that all 65 stack guards are destroyed at depths 0, 1, 7 and 64. TechnicalDebt records that stepping through SEH-only runtime frames and their cleanup handlers remains unimplemented. This change corrects the regression test; it does not claim SEH unwinder support. **Refs #3411; #3411 stays open.** Exceptions still cannot cross the reported SEH-only runtime frames, and this test no longer covers that path. ### Tested - `python3 tools/check_conventions.py --base upstream/main` passed. - `git diff --check upstream/main...HEAD` passed. - The Windows-only `windows_exceptions` executable could not be run locally because this workspace has no MinGW toolchain or Windows runtime. A manual full Build run on this PR is pending. ### Checklist - [x] One topic per PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] No investigation notes, reports, screenshots or logs added to the repository - [x] Depends on: none - [x] AI-assisted: yes
adriadam10 commented 2026-10-11 10:12:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T10:12:18Z.

Review: CHANGES_REQUESTED


Thanks for looking at #3411. A few things before this can go in:

  • The VirtualQuery fallback is what @oneandonlydean asked to drop in #1423 ("fallbacks aren't allowed here. Which images does the loader not know?"). This brings it back without saying which images RtlPcToFileHeader misses.
  • The diagnosis in #3411 (@AchrafReyani, bisected, objdump -h) points elsewhere: the WinLibs libstdc++-6.dll / libwinpthread-1.dll only carry SEH data (.pdata/.xdata) and an empty 4-byte .eh_frame, while DecodeFrame only reads .ehmeta and .ehfram. Even with image resolved by VirtualQuery, the section loop in Unwind.cpp finds no FDE for those frames, so the walk still stops. Nothing here shows the test passing with this change.
  • The PR body says the Windows test wasn't run. Please run windows_exceptions with the change (or have one of the reporters do it) and post the output, plus the result of the RtlPcToFileHeader failing/succeeding for the pthread_once frame (e.g. a log of which images hit the fallback).

If the cause is the missing DWARF data, the fix is in the unwinder (e.g. stepping over SEH-only frames with RtlLookupFunctionEntry + RtlVirtualUnwind) or in the test, not in the image lookup. Happy to re-review once there is evidence for one of them.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5482887256 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3415#pullrequestreview-5482887256). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T10:12:18Z. **Review:** CHANGES_REQUESTED --- Thanks for looking at #3411. A few things before this can go in: - The `VirtualQuery` fallback is what @oneandonlydean asked to drop in #1423 ("fallbacks aren't allowed here. Which images does the loader not know?"). This brings it back without saying which images `RtlPcToFileHeader` misses. - The diagnosis in #3411 (@AchrafReyani, bisected, `objdump -h`) points elsewhere: the WinLibs `libstdc++-6.dll` / `libwinpthread-1.dll` only carry SEH data (`.pdata`/`.xdata`) and an empty 4-byte `.eh_frame`, while `DecodeFrame` only reads `.ehmeta` and `.ehfram`. Even with `image` resolved by `VirtualQuery`, the section loop in `Unwind.cpp` finds no FDE for those frames, so the walk still stops. Nothing here shows the test passing with this change. - The PR body says the Windows test wasn't run. Please run `windows_exceptions` with the change (or have one of the reporters do it) and post the output, plus the result of the `RtlPcToFileHeader` failing/succeeding for the `pthread_once` frame (e.g. a log of which images hit the fallback). If the cause is the missing DWARF data, the fix is in the unwinder (e.g. stepping over SEH-only frames with `RtlLookupFunctionEntry` + `RtlVirtualUnwind`) or in the test, not in the image lookup. Happy to re-review once there is evidence for one of them.
Zurisen commented 2026-10-11 10:19:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Zurisen on 2026-10-11T10:19:41Z.


Ran this on native Windows, since the description says it could not be: 5f4d0a7d merged into main f0c6cf27 (clean), Windows 11 Home (26200), WinLibs GCC 15.2.0 r7 (15.2.0posix-14.0.0-ucrt-r7), Release, full build. windows_exceptions loads the rebuilt build/core/libs/libs/unpatched/libc.prx (its PATH prepend).

windows_exceptions still fails 5/5 with this change, with the same stop as on main:

what():  through runtime frames
    #0 libc.prx+0xa0a7
    #1 libc.prx+0x9a469

So the VirtualQuery fallback does not get the exception through the std::call_once frames here. That fits @AchrafReyani's note on #3411 that libstdc++-6.dll and libwinpthread-1.dll carry a 4-byte .eh_frame and only .pdata/.xdata unwind data, so finding their image does not give the DWARF unwinder anything to walk.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108009394 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3415#issuecomment-6108009394). Originally posted by [Zurisen](https://github.com/Zurisen) on 2026-10-11T10:19:41Z. --- Ran this on native Windows, since the description says it could not be: `5f4d0a7d` merged into `main` `f0c6cf27` (clean), Windows 11 Home (26200), WinLibs GCC 15.2.0 r7 (`15.2.0posix-14.0.0-ucrt-r7`), Release, full build. `windows_exceptions` loads the rebuilt `build/core/libs/libs/unpatched/libc.prx` (its `PATH` prepend). **`windows_exceptions` still fails 5/5 with this change**, with the same stop as on `main`: ``` what(): through runtime frames #0 libc.prx+0xa0a7 #1 libc.prx+0x9a469 ``` So the `VirtualQuery` fallback does not get the exception through the `std::call_once` frames here. That fits @AchrafReyani's note on #3411 that `libstdc++-6.dll` and `libwinpthread-1.dll` carry a 4-byte `.eh_frame` and only `.pdata`/`.xdata` unwind data, so finding their image does not give the DWARF unwinder anything to walk.
MarcZX10 commented 2026-10-11 11:02:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T11:02:22Z.


You and Zurisen are right: the VirtualQuery fallback does not fix the runtime-frame unwind and should not be presented as a fix. I updated the PR description to state that clearly and to restore the required What/Depends on fields. I have not pushed another code change; a real fix still needs SEH-only frame support or a test change with equivalent cleanup coverage.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108336637 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3415#issuecomment-6108336637). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T11:02:22Z. --- You and Zurisen are right: the `VirtualQuery` fallback does not fix the runtime-frame unwind and should not be presented as a fix. I updated the PR description to state that clearly and to restore the required What/Depends on fields. I have not pushed another code change; a real fix still needs SEH-only frame support or a test change with equivalent cleanup coverage.
MarcZX10 commented 2026-10-11 14:59:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T14:59:17Z.


I replaced the std::call_once reproducer with a regression that throws through 0, 1, 7 and 64 recursive guest frames and verifies every guard destructor. This retains cleanup coverage for frames carrying the unwind tables this library reads while removing the unsupported assumption that an Itanium exception can cross the WinLibs libwinpthread/libstdc++ SEH-only frames.

The ineffective VirtualQuery fallback is gone, and the remaining SEH-only limitation is recorded in TechnicalDebt. This does not implement SEH unwinding. The changed regression is Windows-only and I do not have a Windows/MinGW runtime here; conventions and diff checks pass. Could you review whether this is the equivalent cleanup coverage you had in mind?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110330883 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3415#issuecomment-6110330883). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T14:59:17Z. --- I replaced the `std::call_once` reproducer with a regression that throws through 0, 1, 7 and 64 recursive guest frames and verifies every guard destructor. This retains cleanup coverage for frames carrying the unwind tables this library reads while removing the unsupported assumption that an Itanium exception can cross the WinLibs `libwinpthread`/`libstdc++` SEH-only frames. The ineffective `VirtualQuery` fallback is gone, and the remaining SEH-only limitation is recorded in TechnicalDebt. This does not implement SEH unwinding. The changed regression is Windows-only and I do not have a Windows/MinGW runtime here; conventions and diff checks pass. Could you review whether this is the equivalent cleanup coverage you had in mind?
adriadam10 commented 2026-10-11 15:03:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T15:03:44Z.

Review: DISMISSED


Thanks for reworking this. The diagnosis now matches #3411 and @Zurisen's run, and the TechnicalDebt line is accurate. Two things before merging:

  • The new testUnwindThroughGuestFrames is Windows-only and hasn't been run anywhere (PR CI skips Windows). Could someone with the WinLibs setup (@Zurisen ran the previous head) confirm that windows_exceptions passes with this head? A Windows run (build.yml with pr=3415) also works.
  • Please say in the description that this does not fix #3411 (e.g. "Refs #3411, stays open"): the exception crossing libstdc++-6.dll/libwinpthread-1.dll frames is still unsupported and, with the call_once reproducer gone, no longer covered by any test.

Once the Windows run is green this is fine to merge.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5483773369 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3415#pullrequestreview-5483773369). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T15:03:44Z. **Review:** DISMISSED --- Thanks for reworking this. The diagnosis now matches #3411 and @Zurisen's run, and the TechnicalDebt line is accurate. Two things before merging: - The new `testUnwindThroughGuestFrames` is Windows-only and hasn't been run anywhere (PR CI skips Windows). Could someone with the WinLibs setup (@Zurisen ran the previous head) confirm that `windows_exceptions` passes with this head? A Windows run (`build.yml` with `pr=3415`) also works. - Please say in the description that this does not fix #3411 (e.g. "Refs #3411, stays open"): the exception crossing `libstdc++-6.dll`/`libwinpthread-1.dll` frames is still unsupported and, with the `call_once` reproducer gone, no longer covered by any test. Once the Windows run is green this is fine to merge.
MarcZX10 commented 2026-10-11 15:06:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T15:06:59Z.


I added the requested wording: Refs #3411; #3411 stays open, and the description now says the runtime-DLL exception path is not covered by this test change.

I tried the documented manual workflow dispatch for PR #3415 (gh workflow run build.yml --ref main --field pr=3415), but GitHub rejected it with HTTP 403: “Must have admin rights to Repository.” The automatic PR workflow has passed its applicable checks, but it skips the full Windows build, so windows_exceptions has not run on this head.

@Zurisen, could you or another Windows runner with the required workflow permission run the updated PR, or confirm windows_exceptions on this head? I’ll keep the PR marked pending until that Windows result is available.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110400797 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3415#issuecomment-6110400797). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T15:06:59Z. --- I added the requested wording: **Refs #3411; #3411 stays open**, and the description now says the runtime-DLL exception path is not covered by this test change. I tried the documented manual workflow dispatch for PR #3415 (`gh workflow run build.yml --ref main --field pr=3415`), but GitHub rejected it with HTTP 403: **“Must have admin rights to Repository.”** The automatic PR workflow has passed its applicable checks, but it skips the full Windows build, so `windows_exceptions` has not run on this head. @Zurisen, could you or another Windows runner with the required workflow permission run the updated PR, or confirm `windows_exceptions` on this head? I’ll keep the PR marked pending until that Windows result is available.
Zurisen commented 2026-10-11 15:09:29 +00:00 (Migrated from github.com)

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


@adriadam10 Ran this head on Windows: f942de36 merged into main a11c8f7f (clean), Windows 11 Home (26200), WinLibs GCC 15.2.0 r7 (15.2.0posix-14.0.0-ucrt-r7), Release, full build. windows_exceptions passes 5/5:

Own Windows exceptions: typed catch, base catch, catch-all, rethrow, destructors, cross DLL passed
1/1 Test #105: windows_exceptions ...............   Passed    0.01 sec

testUnwindThroughGuestFrames() runs before that line, so all four depths (0, 1, 7, 64) caught the exception and ran every guard destructor. On main the same test fails 5/5 here (through runtime frames).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110423364 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3415#issuecomment-6110423364). Originally posted by [Zurisen](https://github.com/Zurisen) on 2026-10-11T15:09:29Z. --- @adriadam10 Ran this head on Windows: `f942de36` merged into `main` `a11c8f7f` (clean), Windows 11 Home (26200), WinLibs GCC 15.2.0 r7 (`15.2.0posix-14.0.0-ucrt-r7`), Release, full build. `windows_exceptions` passes 5/5: ``` Own Windows exceptions: typed catch, base catch, catch-all, rethrow, destructors, cross DLL passed 1/1 Test #105: windows_exceptions ............... Passed 0.01 sec ``` `testUnwindThroughGuestFrames()` runs before that line, so all four depths (0, 1, 7, 64) caught the exception and ran every guard destructor. On `main` the same test fails 5/5 here (`through runtime frames`).
screamm commented 2026-10-11 15:24:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-11T15:24:43Z.


Windows validation of f942de36 merged onto main a11c8f7f (Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, BUILD_TESTING=ON, Developer Mode on, full build including libs): windows_exceptions passes 3/3 with --repeat until-fail:3, and it is gone from the suite failures. ctest -j8 -E "^agc_driver_|^video_out_flip": 532/536, the remaining failures being the known guest_kernel_sys (#3510) and guest_filesystem (#3518) and the two load flakes agc_driver (#3171) and guest_ampr_markers (#3371), this run being made while seven other builds were running on the host. So #3411 is fixed on this host by this branch.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110563158 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3415#issuecomment-6110563158). Originally posted by [screamm](https://github.com/screamm) on 2026-10-11T15:24:43Z. --- Windows validation of `f942de36` merged onto `main` `a11c8f7f` (Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, `BUILD_TESTING=ON`, Developer Mode on, full build including `libs`): `windows_exceptions` passes 3/3 with `--repeat until-fail:3`, and it is gone from the suite failures. `ctest -j8 -E "^agc_driver_|^video_out_flip"`: 532/536, the remaining failures being the known `guest_kernel_sys` (#3510) and `guest_filesystem` (#3518) and the two load flakes `agc_driver` (#3171) and `guest_ampr_markers` (#3371), this run being made while seven other builds were running on the host. So #3411 is fixed on this host by this branch.
MarcZX10 commented 2026-10-11 16:07:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T16:07:15Z.


Requested Windows validation is now available

On head f942de36, Windows 11/WinLibs Release runs report windows_exceptions passing 5/5, including the 0, 1, 7, and 64 guest-frame cleanup cases. A second report confirms 3/3 repeated runs; the full suite's remaining failures were identified as existing issues or load flakes. The PR description now says “Refs #3411; #3411 stays open.”

@adriadam10, could you re-review the current head against your two requested items?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110953153 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3415#issuecomment-6110953153). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T16:07:15Z. --- ### Requested Windows validation is now available On head `f942de36`, Windows 11/WinLibs Release runs report `windows_exceptions` passing 5/5, including the 0, 1, 7, and 64 guest-frame cleanup cases. A second report confirms 3/3 repeated runs; the full suite's remaining failures were identified as existing issues or load flakes. The PR description now says “Refs #3411; #3411 stays open.” @adriadam10, could you re-review the current head against your two requested items?
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!3415
No description provided.