feat(libkernel): answer the coredump attach calls made outside the handler #3243

Closed
dantdmdarealguy wants to merge 1 commit from upstream-pr/3243 into main
dantdmdarealguy commented 2026-10-11 03:12:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by dantdmdarealguy on 2026-10-11T03:12:01Z.


What

sceCoredumpAttachMemoryRegion and sceCoredumpAttachUserMemoryFile (libkernel, Coredump.cpp) were (void) stubs that threw. They now have their signatures and answer as the console does for a call made outside the core dump handler.

  • Signatures: both take (uint32_t userValue, const void* mem, size_t size). For sceCoredumpAttachMemoryRegion the Orbital IDA type database (int32_t sceCoredumpAttachMemoryRegion(uint32_t user_value, const void* mem, size_t size)) and the SharpProspero bindings agree. sceCoredumpAttachUserMemoryFile has only SharpProspero (uint userValue, void* mem, nuint size, "as an unnamed file"): the PS4 5.05 firmware does not export it, so Orbital has no entry. The RED engine's PS4 crash handler (Vangaurd) calls the sibling sceCoredumpAttachMemoryRegionAsUserFile(999, buffer, bytesWritten, "LoggerQueueCrashDump.txt"), confirming the (user value, memory, size, ...) order on a title.
  • Behaviour: attaching belongs inside the core dump handler, which the system runs on its own thread after the process stops. SharpProspero states it ("the attach, write and read calls belong inside the handler, and the service has an error code of its own for reaching them from anywhere else"), the RED engine keeps its own attachment table and attaches only from its callback, and the Vita's SceCoredump error table (RivetDB) names that error: SCE_COREDUMP_ERROR_NOT_IN_COREDUMP_HANDLER, "function was not called from registered core dump handler". AnyPS5 records the handler but never invokes it, so every call is outside the handler and returns that error; nothing is recorded, as there is no dump to attach to. Registrations are neither kept nor acknowledged, because on the console there is no registration outside the handler to keep.
  • Error value: 0x81180003 is inferred. fpPS4 has SCE_COREDUMP_ERROR_NOT_REGISTERED 0x81180001 and SCE_COREDUMP_ERROR_ALREADY_REGISTERED 0x81180002, and the Vita table numbers PARAM 0, NOT_REGISTERED 1, ALREADY_REGISTERED 2, NOT_IN_COREDUMP_HANDLER 3. No PS4 or PS5 reference carries the value.
  • Argument checks: whether the console checks the region before the calling context is unknown (PARAM or NOT_IN_COREDUMP_HANDLER), so a null, empty or wrapping region throws std::runtime_error naming the function. userValue is not interpreted (SharpProspero names bits 31 and 30 as truncation flags for the user file variants).
  • TechnicalDebt: the two "unknown signature" lines are replaced by one entry with the sources and what remains unverified.

The other coredump exports in the file (sceCoredumpAttachUserFile, sceCoredumpAttachMemoryRegionAsUserFile, sceCoredumpSetUserDataType, sceCoredumpDebugTextOut, sceCoredumpGetStopInfoCpu, sceCoredumpGetStopInfoGpu_Agc, sceCoredumpWriteUserString) are untouched and still throw.

Tested

  • Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs), Release, -DBUILD_TESTING=ON. cmake --build (full) and --target libs succeed with no warnings in the touched files.
  • New guest_coredump_attach_tests (ctest guest_coredump_attach, registered in core/libs/prx/libkernel/CMakeLists.txt): both calls return 0x81180003 with no handler, with a registered handler (from the registering thread and from another thread) and after unregistering; the handler is never run and the region's bytes are untouched; a null, empty (size 0) or wrapping (size SIZE_MAX) region throws a std::runtime_error whose message names the function. Runs in 0.07 s.
  • ctest -R "guest_coredump_attach|patched_libraries": 2/2 pass. The patched libkernel.prx exports +YX0z-GUSNw and DoKHmUw1yiQ (objdump -p).
  • The test fails against four deliberate breakages: returning 0, dropping the argument check, dropping only the wrap check, and returning 0x81180000 (PARAM) instead.
  • python tools/check_test_registration.py and python tools/check_conventions.py --base origin/main pass.
  • No title tested.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes, some AI assistance was used
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4816213636 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3243). Originally posted by [dantdmdarealguy](https://github.com/dantdmdarealguy) on 2026-10-11T03:12:01Z. --- ### What `sceCoredumpAttachMemoryRegion` and `sceCoredumpAttachUserMemoryFile` (libkernel, [Coredump.cpp](core/libs/prx/libkernel/System/src/Coredump.cpp)) were `(void)` stubs that threw. They now have their signatures and answer as the console does for a call made outside the core dump handler. - Signatures: both take `(uint32_t userValue, const void* mem, size_t size)`. For `sceCoredumpAttachMemoryRegion` the [Orbital IDA type database](https://github.com/AlexAltea/orbital/blob/master/tools/ida/db_types.json) (`int32_t sceCoredumpAttachMemoryRegion(uint32_t user_value, const void* mem, size_t size)`) and the [SharpProspero](https://github.com/SvenGDK/SharpProspero/blob/main/src/SharpProspero/Interop/Kernel/KernelSystem.cs) bindings agree. `sceCoredumpAttachUserMemoryFile` has only SharpProspero (`uint userValue, void* mem, nuint size`, "as an unnamed file"): the PS4 5.05 firmware does not export it, so Orbital has no entry. The RED engine's PS4 crash handler ([Vangaurd](https://github.com/vurimad/Vangaurd/blob/main/source/imported/common/redSystem/src/errorHandlerImplErrorHooksOrbis.cpp)) calls the sibling `sceCoredumpAttachMemoryRegionAsUserFile(999, buffer, bytesWritten, "LoggerQueueCrashDump.txt")`, confirming the `(user value, memory, size, ...)` order on a title. - Behaviour: attaching belongs inside the core dump handler, which the system runs on its own thread after the process stops. SharpProspero states it ("the attach, write and read calls belong inside the handler, and the service has an error code of its own for reaching them from anywhere else"), the RED engine keeps its own attachment table and attaches only from its callback, and the Vita's SceCoredump error table ([RivetDB](https://github.com/CreepNT/RivetDB/blob/master/rivetdb.json)) names that error: `SCE_COREDUMP_ERROR_NOT_IN_COREDUMP_HANDLER`, "function was not called from registered core dump handler". AnyPS5 records the handler but never invokes it, so every call is outside the handler and returns that error; nothing is recorded, as there is no dump to attach to. Registrations are neither kept nor acknowledged, because on the console there is no registration outside the handler to keep. - Error value: `0x81180003` is inferred. [fpPS4](https://github.com/red-prig/fpPS4/blob/master/kernel/ps4_libkernel.pas) has `SCE_COREDUMP_ERROR_NOT_REGISTERED` 0x81180001 and `SCE_COREDUMP_ERROR_ALREADY_REGISTERED` 0x81180002, and the Vita table numbers `PARAM` 0, `NOT_REGISTERED` 1, `ALREADY_REGISTERED` 2, `NOT_IN_COREDUMP_HANDLER` 3. No PS4 or PS5 reference carries the value. - Argument checks: whether the console checks the region before the calling context is unknown (`PARAM` or `NOT_IN_COREDUMP_HANDLER`), so a null, empty or wrapping region throws `std::runtime_error` naming the function. `userValue` is not interpreted (SharpProspero names bits 31 and 30 as truncation flags for the user file variants). - TechnicalDebt: the two "unknown signature" lines are replaced by one entry with the sources and what remains unverified. The other coredump exports in the file (`sceCoredumpAttachUserFile`, `sceCoredumpAttachMemoryRegionAsUserFile`, `sceCoredumpSetUserDataType`, `sceCoredumpDebugTextOut`, `sceCoredumpGetStopInfoCpu`, `sceCoredumpGetStopInfoGpu_Agc`, `sceCoredumpWriteUserString`) are untouched and still throw. ### Tested - Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs), Release, `-DBUILD_TESTING=ON`. `cmake --build` (full) and `--target libs` succeed with no warnings in the touched files. - New `guest_coredump_attach_tests` (ctest `guest_coredump_attach`, registered in `core/libs/prx/libkernel/CMakeLists.txt`): both calls return `0x81180003` with no handler, with a registered handler (from the registering thread and from another thread) and after unregistering; the handler is never run and the region's bytes are untouched; a null, empty (`size` 0) or wrapping (`size` `SIZE_MAX`) region throws a `std::runtime_error` whose message names the function. Runs in 0.07 s. - `ctest -R "guest_coredump_attach|patched_libraries"`: 2/2 pass. The patched `libkernel.prx` exports `+YX0z-GUSNw` and `DoKHmUw1yiQ` (`objdump -p`). - The test fails against four deliberate breakages: returning 0, dropping the argument check, dropping only the wrap check, and returning `0x81180000` (`PARAM`) instead. - `python tools/check_test_registration.py` and `python tools/check_conventions.py --base origin/main` pass. - No title tested. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes, some AI assistance was used
github-actions[bot] commented 2026-10-11 03:12:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T03:12:10Z.


Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104913588 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3243#issuecomment-6104913588). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T03:12:10Z. --- Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

Pull request closed

Sign in to join this conversation.
No reviewers
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!3243
No description provided.