Windows: libc exports __cxa_init_primary_exception and std::uncaught_exception(s) only as _nid_postfix, so modules bind libstdc++'s #2597
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 AlxcBTW on 2026-10-10T08:06:34Z.
On Windows, libc exports
__cxa_init_primary_exception,std::uncaught_exceptionandstd::uncaught_exceptionsonly as_nid_postfixsymbols, becauseGCC_GLOBAL_ALIASis empty there. The#ifdef _WIN32block inExports.cppgives__cxa_throw,__cxa_begin_catchand the rest native names, but not these three. Host modules therefore bind libstdc++-6.dll's versions instead (objdump -ponmainc72d5ce1:libSceAgcDriver.prx,libSceVideoOut.prx,libkernel.prx). This is the same class of problem as #2540, fixed in #2570.std::uncaught_exceptions()reads libstdc++'s thread state, which libc's throws never touch, so it returns 0 while an exception unwinds.recordDeferredLabels' guard inDeferredLabels.cppuses it to tell a failed record from a finished one. On Windows a failed record therefore closes the label group with the tracker generation instead of 0, and thedropped ... queued labelsline is never printed.std::make_exception_ptr(used bystd::promise's destructor forbroken_promise) allocates with libc and initializes with libstdc++'s__cxa_init_primary_exception, which lays out its header differently. A test that makes such an exception and rethrows it dies with0xc0000005.__cxa_init_primary_exceptionleaves the reference count at 1. The Itanium ABI sets it to 0, and libstdc++ and libc++abi both do. Theexception_ptrcreated next adds its own reference, so a made exception is never destroyed. This affects guest code usingmake_exception_ptrtoo.Fix
AlxcBTW:fix/libc-native-exception-exports-v2(400fce30, onmaind5c8e42d). The same change before the rebase (4876aecf) passed full CI onc72d5ce1. In the run on d5c8e42d, Linux and macOS pass. The only Windows failure isagc_driver_prepared_shaders_deferred_undecodable, which fails on everymainrun at the moment (fix: AlxcBTW/AnyPS5#13). I can't open it as a PR while intake is limited, so it's here if a collaborator wants to cherry-pick it.The three are now exported natively, next to the others, and
__cxa_init_primary_exceptionsets the reference count to 0.Tested
Windows 11, WinLibs GCC 15.2.0 r7.
windows_exceptionsgains two cases. A made, rethrown and released exception must have its argument and its stored copy destroyed once each, andstd::uncaught_exceptions()must be 1 in a destructor that runs during unwinding. Without the change the test dies with0xc0000005. With only the exports, it fails withmade exception destroyed an incorrect number of times. With both, it passes.exception_runtime(Linux/macOS) gains the same made-exception check, and it passes in CI.patched_librariesloads every patched library.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by Yuva1024 on 2026-10-10T08:22:27Z.
Tested AlxcBTW/AnyPS5#8 (
400fce30) merged onto currentmain2c4828a6(--no-ff; it merges cleanly). Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, RTX 4060 (driver 617.42). This adds a run with a real GPU, which Windows CI can't do.ctest: 658/658, 5 expected skips (video-out window tests);windows_exceptionspasses.libSceVideoOut.prxandlibkernel.prxnow import__cxa_init_primary_exceptionfromlibc.prx(it waslibstdc++-6.dll), andlibSceAgcDriver.prximportsstd::uncaught_exceptionsfromlibc.prx.std::make_exception_ptr(std::runtime_error(...))and rethrows it: 1000 round trips and 50 further runs without a failure. Before the fix (on #2570 alone) the same program faulted on its first iteration inlibc.prx.video_out_flip_tests,guest_video_out_resolution_status,guest_video_out_wqhd_detection), 300 runs each withSDL_VIDEODRIVER=offscreen: 0 aborts in 900, so the #2570 fix still holds with this on top.std::futureprobe: the word atobj-0xA0is unchanged and thelibc.prxreference count goes 2 → 1.Not tested on a title.
AI-assisted: yes (Claude Code).