fix(libc): release future results' exceptions through libc on Windows #2570
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2570"
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 oneandonlydean on 2026-10-10T06:30:08Z.
Carrying @AlxcBTW's fix for #2540 while PR intake is paused. The change is theirs, unchanged (from AlxcBTW/AnyPS5#6).
What and why
libc implements the C++ exception runtime and already defines
exception_ptr's out-of-line members, so host modules that link libc
reference-count libc's exceptions. Code inside libstdc++-6.dll does not
see those definitions on Windows: std::__future_base::_Result_base's
destructor is one of them, and it releases the stored exception with
libstdc++'s own exception_ptr::_M_release. That decrements a count 0xa0
bytes before the object, while libc keeps it 0x80 bytes before, so the
decrement lands in the heap memory in front of libc's allocation and
the exception is never freed.
VideoOutDriver reports the presentation thread's start-up failure
through a std::promise, so video_out_flip_lifetime sometimes ended with
0xc0000374 when SDL's offscreen driver refused the window.
libc now defines the base destructor, with a _nid_postfix twin so that
the NID-patched libc keeps its name, and modules bind it there.
Fixes #2540.
Tested
tools/check_conventions.pypasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T06:30:46Z.
Progress report (
2e19774→cc56748)📈 System libraries: 85.69% (+0.01%, +1 implemented functions)
✅ 1 implemented
_ZNSt13__future_base12_Result_baseD2Ev_nid_postfixImported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-10T06:49:12Z.
Thanks for carrying it. The
conventionsfailure is only the template check: it wants a### Whatheading, and this body has### What and why.Measurements behind the change, Windows 11, WinLibs GCC 15.2.0 r7,
video_out_flip_tests.exewithSDL_VIDEODRIVER=offscreen:0xc0000374mainc963432dSDL_JOYSTICK_WGI=0SDL_JOYSTICK_WGI=0The same corruption also hits
guest_video_out_resolution_status, which takes the same failedsceVideoOutOpenpath. It failed with0xc0000374in an unrelated fork run without this change (windows job).A related gap I found while checking for other cases: on Windows libc doesn't export
__cxa_init_primary_exceptionorstd::uncaught_exception(s)natively either, so modules bind libstdc++'s versions.std::uncaught_exceptions()then returns 0 during unwinding, which affectsrecordDeferredLabels' failure guard. The fix is AlxcBTW/AnyPS5#7, and I'll open an issue for it.AI-assisted: yes (Claude Code).