Windows: windows_exceptions fails since #1423, unwinding through runtime DLL frames (std::call_once) no longer reaches the catch #3411

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

Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-11T09:48:34Z.


Since #1423 (3ac63a6d, "key the .eh_frame index on the image, drop the VirtualQuery fallback, test unwinding through runtime DLLs", merged 2026-10-11 09:16) windows_exceptions fails on this Windows host, deterministically (3/3 and in two full suite runs):

[libc] unhandled exception 'St13runtime_error' thrown from 00007ff880b6ac46
terminate called after throwing an instance of 'std::runtime_error'
  what():  through runtime frames
    #0 0x00007ff880b1a0e7 libc.prx+0xa0e7
    #1 0x00007ff880ba5469 libc.prx+0x95469
    #2 0x0000000d365ff160

That is the new testUnwindThroughRuntimeModules case: the exception thrown from the std::call_once lambda (frames in libstdc++-6.dll / libwinpthread-1.dll) is not caught by the test's catch (const std::runtime_error&) at depth 0, so the unwinder stops at the runtime DLL frames. The earlier cases in the same executable (TestTypeInfoVtables, exception pointers, futures, uncaught exceptions) pass. Built on main 0490ca18 (plus an unrelated libSceAjm change in one run, none in the other); the same executable passed on main 0c617bae, before #1423.

Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7 (15.2.0posix-14.0.0-ucrt-r7), Ninja, Release, BUILD_TESTING=ON. The runtime DLLs next to the test (build/tests/libstdc++-6.dll, libwinpthread-1.dll) are byte-identical to the toolchain's mingw64/bin copies. No completed CI run on main since that merge yet (the last ones were cancelled by newer pushes), so I cannot say whether the CI runner sees the same.

Happy to run a diagnostic build (for example printing which module the new image-keyed .eh_frame index resolves for the faulting frames) if that helps.

Written with Claude Code assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5799943178 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3411). Originally posted by [screamm](https://github.com/screamm) on 2026-10-11T09:48:34Z. --- Since #1423 (`3ac63a6d`, "key the .eh_frame index on the image, drop the VirtualQuery fallback, test unwinding through runtime DLLs", merged 2026-10-11 09:16) `windows_exceptions` fails on this Windows host, deterministically (3/3 and in two full suite runs): ``` [libc] unhandled exception 'St13runtime_error' thrown from 00007ff880b6ac46 terminate called after throwing an instance of 'std::runtime_error' what(): through runtime frames #0 0x00007ff880b1a0e7 libc.prx+0xa0e7 #1 0x00007ff880ba5469 libc.prx+0x95469 #2 0x0000000d365ff160 ``` That is the new `testUnwindThroughRuntimeModules` case: the exception thrown from the `std::call_once` lambda (frames in `libstdc++-6.dll` / `libwinpthread-1.dll`) is not caught by the test's `catch (const std::runtime_error&)` at depth 0, so the unwinder stops at the runtime DLL frames. The earlier cases in the same executable (`TestTypeInfoVtables`, exception pointers, futures, uncaught exceptions) pass. Built on `main` `0490ca18` (plus an unrelated libSceAjm change in one run, none in the other); the same executable passed on `main` `0c617bae`, before #1423. Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7 (`15.2.0posix-14.0.0-ucrt-r7`), Ninja, Release, `BUILD_TESTING=ON`. The runtime DLLs next to the test (`build/tests/libstdc++-6.dll`, `libwinpthread-1.dll`) are byte-identical to the toolchain's `mingw64/bin` copies. No completed CI run on `main` since that merge yet (the last ones were cancelled by newer pushes), so I cannot say whether the CI runner sees the same. Happy to run a diagnostic build (for example printing which module the new image-keyed `.eh_frame` index resolves for the faulting frames) if that helps. Written with Claude Code assistance.
reyani-dev commented 2026-10-11 09:59:54 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-11T09:59:54Z.


Same result here (Windows 11, WinLibs GCC 15.2.0 r7, RTX 4070 machine). Bisected on main: 3e1fa82c passes and bf5458b7 (the #1423 merge) fails.

I think the cause is the new test, not the index. #1423 added testUnwindThroughRuntimeModules, and those runtime frames have no DWARF unwind data:

$ objdump -h build/tests/libstdc++-6.dll       |  $ objdump -h build/tests/libwinpthread-1.dll
.eh_frame 00000004                             |  .eh_fram 00000004
.pdata    0001152c                             |  .pdata   00000c54
.xdata    0001bb7c                             |  .xdata   00000b8c

WinLibs' x86_64 runtime DLLs unwind with SEH (.pdata/.xdata); their .eh_frame is an empty 4-byte terminator. With the posix thread model, std::call_once runs the lambda from inside pthread_once in libwinpthread-1.dll, so the exception has to pass a frame that only has SEH data. On Windows, DecodeFrame only reads .ehmeta and .ehfram sections, the names core/libs/CMakeLists.txt gives the repository's own libraries with --rename-section .eh_frame=.ehfram. Even a DLL with a real .eh_frame (8-byte name .eh_fram) wouldn't be read. So no FDE is found for the pthread_once frame, the walk stops, and the exception is reported as unhandled.

That would also explain why it can pass elsewhere: with a thread model where call_once doesn't go through a separate C runtime frame (or with that runtime built with DWARF unwind tables), the new test never crosses a frame without an FDE.

So making the test pass on WinLibs needs the Windows unwinder to step over frames that only have SEH data, for example RtlLookupFunctionEntry + RtlVirtualUnwind to recover the caller's context. Alternatively, the test should throw through a frame that has unwind data the walker reads. Happy to try either once someone who knows the intended scope says which.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6107822678 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3411#issuecomment-6107822678). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-11T09:59:54Z. --- Same result here (Windows 11, WinLibs GCC 15.2.0 r7, RTX 4070 machine). Bisected on `main`: `3e1fa82c` passes and `bf5458b7` (the #1423 merge) fails. I think the cause is the new test, not the index. #1423 added `testUnwindThroughRuntimeModules`, and those runtime frames have no DWARF unwind data: ``` $ objdump -h build/tests/libstdc++-6.dll | $ objdump -h build/tests/libwinpthread-1.dll .eh_frame 00000004 | .eh_fram 00000004 .pdata 0001152c | .pdata 00000c54 .xdata 0001bb7c | .xdata 00000b8c ``` WinLibs' x86_64 runtime DLLs unwind with SEH (`.pdata`/`.xdata`); their `.eh_frame` is an empty 4-byte terminator. With the posix thread model, `std::call_once` runs the lambda from inside `pthread_once` in `libwinpthread-1.dll`, so the exception has to pass a frame that only has SEH data. On Windows, `DecodeFrame` only reads `.ehmeta` and `.ehfram` sections, the names `core/libs/CMakeLists.txt` gives the repository's own libraries with `--rename-section .eh_frame=.ehfram`. Even a DLL with a real `.eh_frame` (8-byte name `.eh_fram`) wouldn't be read. So no FDE is found for the `pthread_once` frame, the walk stops, and the exception is reported as unhandled. That would also explain why it can pass elsewhere: with a thread model where `call_once` doesn't go through a separate C runtime frame (or with that runtime built with DWARF unwind tables), the new test never crosses a frame without an FDE. So making the test pass on WinLibs needs the Windows unwinder to step over frames that only have SEH data, for example `RtlLookupFunctionEntry` + `RtlVirtualUnwind` to recover the caller's context. Alternatively, the test should throw through a frame that has unwind data the walker reads. Happy to try either once someone who knows the intended scope says which.
Amoenus commented 2026-10-11 10:28:45 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-11T10:28:45Z.


Independent Windows reproduction and Math.cpp control (2026-10-11, a73)

Reproduced on Windows/WinLibs MinGW-w64 GCC15.2 r7/Release/BUILD_TESTING=ON. On main a73a1af9 plus only four min/max exports/tests, windows_exceptions fails in the full823-test run and a serial isolated run. Replacing only Math.cpp with exact unmodified a73 source, rebuilding native libc and keeping the same test executables/other DLLs gives the same serial failure:

ctest --test-dir build-review -R "^(windows_exceptions|agc_driver_depth_fast_clear_submit|guest_ampr_markers)$" -j1 --timeout30 --output-on-failure
[libc] unhandled exception 'St13runtime_error'
terminate called after throwing an instance of 'std::runtime_error'
  what(): through runtime frames
FATAL: abort() (SIGABRT)
libc.prx+0xa0e7
libc.prx+0x96469
Exit code 0xc0000409

Focused serial failure0.125418s; baseline-Math control0.119254s. A separate a73 math+locale integration full run also fails here. This rules out needing the added min/max wrappers to reproduce the symptom on this host; it is not a bisect of #1423 or an independent root-cause confirmation. We have not validated #3415 yet. Logs, native-DLL hashes and source control are retained outside the repository. AI-assisted validation/report: Codex.

Reproduction on newer main74981fa (2026-10-11)

Windows11/Winlibs GCC15.2r7/Release, main74981fa plus only focused D64 color change3034273: windows_exceptions again exits0xc0000409 in the completed833-test run (822pass,5skip,6fail) and in a serial isolated recheck. This stack does not carry our earlier pending min/max or locale overlay. The symptom remains the through-runtime-frames exception/terminate path. It is another reproduction on this toolchain, not a bisect of the originating change, proof about #3415, or a new diagnosis. Existing aperture failures remain on #3291. AI-assisted validation/report: Codex.

Recheck on a11-based MSAA integration (2026-10-11)

On Windows11 Enterprise26200 / WinLibs GCC15.2r7 / Release/BUILD_TESTING=ON, integration f7a2bf691, based on maina11c8f7f: windows_exceptions again fails in the842-test full run and a subsequent serial isolated recheck. Same std::runtime_error, what(): through runtime frames, libc terminate/SIGABRT, exit0xc0000409. Full build/all122 libraries pass; full run835pass/5skip/2fail. This stack carries kernel/math/D64 and sampled-MSAA proposals; it is not unchanged main. No new originating-change bisect, #3415 validation, or root-cause claim. The earlier exact-Math source control remains attributed to the earlier base. AI-assisted validation/report: Codex.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108079248 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3411#issuecomment-6108079248). Originally posted by [Amoenus](https://github.com/Amoenus) on 2026-10-11T10:28:45Z. --- ### Independent Windows reproduction and Math.cpp control (2026-10-11, a73) Reproduced on Windows/WinLibs MinGW-w64 GCC15.2 r7/Release/BUILD_TESTING=ON. On main `a73a1af9` plus only [four min/max exports/tests](https://github.com/Amoenus/AnyPS5/commit/59c6d5e1344e73ceddbab12b1e95ce0941025b8c), windows_exceptions fails in the full823-test run and a serial isolated run. Replacing **only Math.cpp with exact unmodified a73 source**, rebuilding native libc and keeping the same test executables/other DLLs gives the same serial failure: ``` ctest --test-dir build-review -R "^(windows_exceptions|agc_driver_depth_fast_clear_submit|guest_ampr_markers)$" -j1 --timeout30 --output-on-failure [libc] unhandled exception 'St13runtime_error' terminate called after throwing an instance of 'std::runtime_error' what(): through runtime frames FATAL: abort() (SIGABRT) libc.prx+0xa0e7 libc.prx+0x96469 Exit code 0xc0000409 ``` Focused serial failure0.125418s; baseline-Math control0.119254s. A separate a73 math+locale integration full run also fails here. This rules out needing the added min/max wrappers to reproduce the symptom on this host; it is **not a bisect of #1423 or an independent root-cause confirmation**. We have not validated #3415 yet. Logs, native-DLL hashes and source control are retained outside the repository. AI-assisted validation/report: Codex. ### Reproduction on newer main74981fa (2026-10-11) Windows11/Winlibs GCC15.2r7/Release, main74981fa plus only [focused D64 color change3034273](https://github.com/Amoenus/AnyPS5/commit/3034273d87c652fc00dc9851f7c378f0fc148ff6): windows_exceptions again exits0xc0000409 in the completed833-test run (822pass,5skip,6fail) and in a serial isolated recheck. This stack does **not carry our earlier pending min/max or locale overlay**. The symptom remains the through-runtime-frames exception/terminate path. It is another reproduction on this toolchain, not a bisect of the originating change, proof about #3415, or a new diagnosis. Existing aperture failures remain on #3291. AI-assisted validation/report: Codex. ### Recheck on a11-based MSAA integration (2026-10-11) On Windows11 Enterprise26200 / WinLibs GCC15.2r7 / Release/BUILD_TESTING=ON, [integration f7a2bf691](https://github.com/Amoenus/AnyPS5/commit/f7a2bf691d8237b8ccaab4cfd526213a90de13b1), based on maina11c8f7f: `windows_exceptions` again fails in the842-test full run and a subsequent serial isolated recheck. Same `std::runtime_error`, `what(): through runtime frames`, libc terminate/SIGABRT, exit0xc0000409. Full build/all122 libraries pass; full run835pass/5skip/2fail. This stack carries kernel/math/D64 and sampled-MSAA proposals; it is not unchanged main. No new originating-change bisect, #3415 validation, or root-cause claim. The earlier exact-Math source control remains attributed to the earlier base. AI-assisted validation/report: Codex.
MarcZX10 commented 2026-10-11 14:59:18 +00:00 (Migrated from github.com)
Author
Contributor

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


I updated #3415 to remove its ineffective VirtualQuery change and replace the std::call_once test path with recursive guest frames. The new test still checks destructor cleanup at depths 0, 1, 7 and 64 using the unwind tables the current Windows unwinder supports.

This corrects the regression introduced by the test's assumption that exceptions can cross the WinLibs libwinpthread/libstdc++ frames. It does not add SEH unwinding; the limitation and lack of RtlVirtualUnwind/Windows cleanup-handler support are recorded in TechnicalDebt. I linked this issue from #3415 without marking the underlying SEH limitation fixed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110331032 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3411#issuecomment-6110331032). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T14:59:18Z. --- I updated #3415 to remove its ineffective `VirtualQuery` change and replace the `std::call_once` test path with recursive guest frames. The new test still checks destructor cleanup at depths 0, 1, 7 and 64 using the unwind tables the current Windows unwinder supports. This corrects the regression introduced by the test's assumption that exceptions can cross the WinLibs `libwinpthread`/`libstdc++` frames. It does **not** add SEH unwinding; the limitation and lack of `RtlVirtualUnwind`/Windows cleanup-handler support are recorded in TechnicalDebt. I linked this issue from #3415 without marking the underlying SEH limitation fixed.
oneandonlydean commented 2026-10-11 23:27:33 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T23:27:33Z.


Closing: #3415 changed the test to unwind through guest frames only. Unwinding through runtime DLL frames that carry only SEH data stays unsupported and is recorded in TechnicalDebt.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6115101324 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3411#issuecomment-6115101324). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-11T23:27:33Z. --- Closing: #3415 changed the test to unwind through guest frames only. Unwinding through runtime DLL frames that carry only SEH data stays unsupported and is recorded in TechnicalDebt.
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#3411
No description provided.