Commit Graph

12 Commits

Author SHA1 Message Date
Nicolas Falesy db3ec02c54 fix(libc): let a title's own libunwind read _Unwind_Backtrace frames
Homebrew built with the ps5-payload-dev SDK links LLVM libunwind
statically but imports _Unwind_Backtrace from libSceLibcInternal. Its
trace callback then reads each frame with its own _Unwind_GetIP, which
treats the context as a libunwind cursor and calls through the virtual
table in its first word. AnyPS5's context started with the saved RAX, so
the call jumped to a register value and the title crashed on its error
path (vkQuake, PPSA99010, without its game data). The context now starts
with a table in AbstractUnwindCursor's slot order that answers register
reads and writes, validFloatReg and isSignalFrame; other slots throw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EvDbpwUPTa78oCAJqe7m9K
2026-10-13 01:55:14 -04:00
Celegans12 58ee73f475 fix(libc): write the whole what() when terminate reports an exception
The default terminate handler formatted its whole report into a 1024-byte
buffer, so a long what() was cut off without a trailing newline. Driver
refusals that carry a serialized RecompileRequest lost most of it, and the
next log line ran into the truncated text.

The report header still goes through the bounded RawLog, and what() is
now written in full by a raw write to the stderr handle, followed by a
newline. Both keep avoiding the CRT stream lock, as before.

exception_runtime gains a forked child that throws an uncaught
runtime_error with a message over 3000 characters and checks that the
full what() reaches stderr before SIGABRT.
2026-10-11 23:42:53 +02:00
AlxcBTW 649782b7b6 fix(libc): export the remaining exception entry points natively on Windows
On Windows libc exports __cxa_init_primary_exception, std::uncaught_exception
and std::uncaught_exceptions only as _nid_postfix symbols (GCC_GLOBAL_ALIAS
is empty there), so host modules bind libstdc++-6.dll's versions:

- std::make_exception_ptr, which std::promise's destructor uses for
  broken_promise, allocated the exception with libc and initialized it with
  libstdc++'s __cxa_init_primary_exception, whose header layout differs.
  A test that makes one and rethrows it dies with an access violation.
- std::uncaught_exceptions read libstdc++'s thread state, which libc's
  throws never touch, so it returned 0 while an exception unwound. The
  AGC driver's deferred-label guard relies on it to tell a failed record
  from a finished one.

The three are now exported natively, like __cxa_throw and the rest.
__cxa_init_primary_exception also sets the reference count to 0, as the
Itanium ABI does: the exception_ptr created next takes the only
reference, so a made exception is destroyed once instead of leaking.
2026-10-10 21:20:29 +13:00
Achraf Reyani df570de6d5 feat(libc): implement std::bad_weak_ptr and _Throw_bad_weak_ptr
BnMAMrsfVWo is _ZSt19_Throw_bad_weak_ptrv. Replace the unknown stub
with a throw of a guest std::bad_weak_ptr, and add its type info,
vtable, destructors and what().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 10:00:54 +02:00
Adrià 8cb527165a
Merge pull request #1120 from TideOPL/feat/libc-sce-v2-runtime-symbols
feat(libc): export the __sce_v2 _Xbad_function_call and sized aligned delete
2026-10-08 09:40:20 +02:00
TideOPL 88e742208b test(libc): require std::bad_function_call from the __sce_v2 thrower 2026-10-07 15:44:33 +01:00
Aarav 742fa2e395 test(libc): keep exception runtime assertions enabled in Release 2026-10-07 18:49:42 +05:30
TideOPL 183491b263 feat(libc): export the __sce_v2 _Xbad_function_call and sized aligned delete
PPSA16064 (Minecraft Dungeons II) ships its own libc.prx, which imports
two C++ runtime symbols from libSceLibcInternal that no host library
exported, so the title failed to load:

- std::__sce_v2::_Xbad_function_call() (_ZNSt8__sce_v219_Xbad_function_callEv),
  the inline-namespace spelling of the existing std::_Xbad_function_call.
  It throws std::bad_function_call the same way.
- operator delete(void*, std::size_t, std::align_val_t)
  (_ZdlPvmSt11align_val_t), the sized form of the existing aligned
  delete. It frees the pointer the same way and ignores the size.

application_heap_default frees an aligned block through the sized form
and checks that a null pointer frees nothing. exception_runtime checks
that the new thrower throws a standard exception; it is built only on
Linux and was not run here (Windows 11, MinGW GCC 15.2).
2026-10-07 14:08:13 +01:00
Adrià Franch fbf0099790 feat(libc): implement std::_Xrange_error and the range_error type
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-05 19:49:33 +02:00
asimplestray b42db4b6f3 feat(libc): implement RaiseEv, catchReturnFromMain and reallocalign 2026-09-30 23:55:00 +00:00
boykopovar ba6d7afc22 refactor(libc): __attribute__ replacing and removing 2026-09-06 13:02:22 +03:00
boykopovar baa8a8d9d3 feat(libc): add ex tests + remove bad_alloc dup 2026-09-06 07:30:59 +03:00