Windows: exceptions raised inside libstdc++-6.dll (regex_error, filesystem_error, …) can't reach AnyPS5 catch sites #25728
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-11-22T15:45:20Z.
On Windows, an exception that is raised inside
libstdc++-6.dllisn't delivered to acatchin AnyPS5 code, even when thecatchis one frame up. The process aborts with:I hit this twice on 2026-11-22. In both cases the code was correct C++ and works on Linux.
1.
libSceNKWebKit.prx(#25548, heada2e45c2255).ParsePredicateinsrc/JscConfigFile.cppwrapsstd::regex::assignincatch (const std::regex_error&). On an invalid pattern,nkwebkit_jscconfigfileaborts in every run, locally and in Windows CI. Stack, innermost first:libstdc++-6.dll(__throw_regex_error) →libgcc_s_seh-1.dll→KERNELBASE!RaiseException; the first non-runtime frame islibSceNKWebKit.prx+0x2c829e.2. A host tool executable (#25559, head
9acd199d07).agc_pipeline_journal_replay'smainwas atry { … } catch (const std::exception&). Under ANSI code page 1252, a Cyrillic path argument madestd::filesystem::existsthrowfilesystem_errorfrom inside the libstdc++ DLL, and the process aborted with the same message instead of reaching thecatch. (That PR has since switched towmain, so the throw no longer happens there.)Why: AnyPS5's own throws go through the libc Windows exception unwinder, which reads the DWARF unwind data that
configure_windows_unwindkeeps in.ehfram. An exception raised bylibstdc++-6.dllgoes throughlibgcc_s_sehand Windows SEH dispatch instead, which needs.pdatafor each frame. Project modules have almost none:libSceNKWebKit.prxhas 0x5d0 bytes of.pdatafor 3.4 MB of.text. The dispatch stops at the first project frame.docs/dev/debt/libc.mdalready documents the reverse case: a handler in an unmarked module such aslibstdc++-6.dllstops an AnyPS5 unwind. This report is about exceptions thrown from inside that module.Possible scope, not verified one by one. On
main, non-test code undercore/libs/prxhascatchsites for exception types that, in practice, only libstdc++ raises:catchsitesstd::filesystem::filesystem_errorFilesystem.cpp,General.cpp,RealPath.cpp,Rename.cpp,FileAndHeap.cpp; libkernelSharedMemory.cpp,DynamicLoader.cpp;libSceSaveData.native;libSceContentExport)std::bad_allocoperator newlives in the libstdc++ DLL)std::system_errorThere is also
std::stoullinlibc/src/GuestAllocations.cpp:141. A site is only affected if itstryblock reaches a throwing libstdc++ call, such as a non-error_codefilesystem overload or allocation failure. Many may never do so. Each of these needs checking against the actual calls; this list is candidates only.Directions, none tried:
error_codefilesystem overloads,std::nothrowallocation,std::from_chars, and a non-throwing regex engine such as ICUuregex_*;libstdc++-6.dlland hand it to its own DWARF unwinder, the way it delivers AnyPS5 throws;Setup for both reproductions: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT r7, Release,
main2c08875217ande83839c042.AI-assisted: yes.