fix(libc): use the default heap for an executable without process parameters #6713

Closed
karimibrahim07 wants to merge 2 commits from upstream-pr/6713 into main
karimibrahim07 commented 2026-10-16 06:33:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by karimibrahim07 on 2026-10-16T06:33:06Z.


What

An ELF without a PT_SCE_PROCPARAM segment, such as a ps5-payload-dev SDK program, got no .procpar section when relinked for Windows. Its first allocation then stopped with application heap: process metadata is missing; relink the executable. That message exists for executables relinked before the section was introduced, but such an ELF has no process parameters to record.

  • WindowsPePatcher now writes a .procpar section with address 0 and size 0 when the ELF has no PT_SCE_PROCPARAM segment.
  • ApplicationProcessParameters_nid_no_patch returns null for that record.
  • ApplicationHeapInitialize_nid_no_patch(nullptr) registers the heap's existing default allocator, as it already does for an all-null replacement table. sceKernelGetProcParam returns null.

An executable without any .procpar section still gets the relink message (application_heap_stats_missing still passes). On the console such a program runs inside its launcher's process, whose parameters aren't modelled. The new entry in docs/dev/debt/libc.md records that, and that Linux output still stops for such an ELF.

Tested

Windows 11 Pro (26300), WinLibs GCC 15.2.0 r7, Ninja Release, BUILD_TESTING=ON, on main 5d9dcc42d:

  • New application_heap_without_parameters test (Windows). It installs the zero record, then allocates through operator new and posix_memalign (64-byte aligned) without calling the test's allocator table, and frees. With the runtime change reverted, it fails with application heap: process parameters exceed the image.
  • New windows_process_parameters relinker test. An ELF without PT_SCE_PROCPARAM converted with --windows has exactly one .procpar section, and it holds zeros. On main there is none.
  • The application_heap* tests pass, 9 of 9. The full suite passes, 1302 tests (one conventions_function_bodies shard timed out while the machine was busy and passed alone). python tools/check_conventions.py --base origin/main passes.
  • Merges cleanly with the open PRs that touch these files, and with #6697, #6702 and #6707.

The Quake homebrew (#6698), with #6697, #6702, #6707 and this PR, relinked with --windows --to-intel --trap-sdk-syscall-stubs --registry:

  • Without this PR, it stops at application heap: process metadata is missing; relink the executable.
  • With it, it reaches its ELF entry point. The SDK's _start then expects the launcher's payload_args_t. How AnyPS5 could start such programs is the design question in #6712, where a prototype that also patches the entry reaches Quake's main menu.

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 under Silent stubs in their library's technical debt file
  • 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 for the change; the Quake evidence needs #6697, #6702 and #6707
  • Unblocks: Quake homebrew #6698 (to its entry point)
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4884473947 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6713). Originally posted by [karimibrahim07](https://github.com/karimibrahim07) on 2026-10-16T06:33:06Z. --- ### What An ELF without a `PT_SCE_PROCPARAM` segment, such as a [ps5-payload-dev SDK](https://github.com/ps5-payload-dev/sdk) program, got no `.procpar` section when relinked for Windows. Its first allocation then stopped with `application heap: process metadata is missing; relink the executable`. That message exists for executables relinked before the section was introduced, but such an ELF has no process parameters to record. - `WindowsPePatcher` now writes a `.procpar` section with address 0 and size 0 when the ELF has no `PT_SCE_PROCPARAM` segment. - `ApplicationProcessParameters_nid_no_patch` returns null for that record. - `ApplicationHeapInitialize_nid_no_patch(nullptr)` registers the heap's existing default allocator, as it already does for an all-null replacement table. `sceKernelGetProcParam` returns null. An executable without any `.procpar` section still gets the relink message (`application_heap_stats_missing` still passes). On the console such a program runs inside its launcher's process, whose parameters aren't modelled. The new entry in `docs/dev/debt/libc.md` records that, and that Linux output still stops for such an ELF. ### Tested Windows 11 Pro (26300), WinLibs GCC 15.2.0 r7, Ninja Release, `BUILD_TESTING=ON`, on `main` `5d9dcc42d`: - New `application_heap_without_parameters` test (Windows). It installs the zero record, then allocates through `operator new` and `posix_memalign` (64-byte aligned) without calling the test's allocator table, and frees. With the runtime change reverted, it fails with `application heap: process parameters exceed the image`. - New `windows_process_parameters` relinker test. An ELF without `PT_SCE_PROCPARAM` converted with `--windows` has exactly one `.procpar` section, and it holds zeros. On `main` there is none. - The `application_heap*` tests pass, 9 of 9. The full suite passes, 1302 tests (one `conventions_function_bodies` shard timed out while the machine was busy and passed alone). `python tools/check_conventions.py --base origin/main` passes. - Merges cleanly with the open PRs that touch these files, and with #6697, #6702 and #6707. The Quake homebrew (#6698), with #6697, #6702, #6707 and this PR, relinked with `--windows --to-intel --trap-sdk-syscall-stubs --registry`: - Without this PR, it stops at `application heap: process metadata is missing; relink the executable`. - With it, it reaches its ELF entry point. The SDK's `_start` then expects the launcher's `payload_args_t`. How AnyPS5 could start such programs is the design question in #6712, where a prototype that also patches the entry reaches Quake's main menu. ### 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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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 for the change; the Quake evidence needs #6697, #6702 and #6707 - [x] Unblocks: Quake homebrew #6698 (to its entry point) - [x] GPUs tested: n/a - [x] AI-assisted: yes
screamm commented 2026-10-17 11:37:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-17T11:37:34Z.


Cross-validation on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2, PR head 668d51adb, scratch-merged onto main 673f7406c (no conflict; #6681 merges with it without conflict too). Windows only, no GPU involved. No local title lacks PT_SCE_PROCPARAM, so there is no title run.

  • application_heap_without_parameters and windows_process_parameters, --repeat until-fail:3: 3 of 3, together with the other 8 application_heap* tests (11 tests, all 3 of 3). The 102 relinker tests also pass 3 of 3 on the merged tree.
  • Negative control: with ApplicationHeap.cpp and ApplicationProcessParameters.cpp from main (test kept) application_heap_without_parameters fails with application heap: process parameters exceed the image, as you describe. With WindowsPePatcher.cpp from main windows_process_parameters fails (AssertionError: [], no .procpar section). With the changes both pass.
  • tools/check_conventions.py --base origin/main and git diff --check: pass.
  • Local titles: all 54 eboot.elf inputs I have (51 titles) contain a PT_SCE_PROCPARAM segment, so none exercises this path. Relinking all 51 for Windows with main's relinker and with this one gives identical SHA-256 for all 312 output files (PPSA99995 stops with the same TLS-instruction FAIL in both). I did not scan guest modules or secondary executables.
  • To see the effect on a real ELF I changed the PT_SCE_PROCPARAM header of one local eboot (PPSA69420) to PT_NULL and relinked it with --windows: main's relinker output has no .procpar section, this PR's has one with virtual size 8 and raw size 0. I did not run that executable.

Not checked: Quake or other SDK payloads (not available here), Linux, macOS, a full-tree build, the full non-GPU suite.

Written with Claude Code assistance (validation by a subagent, reviewed in this session).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6233431061 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6713#issuecomment-6233431061). Originally posted by [screamm](https://github.com/screamm) on 2026-10-17T11:37:34Z. --- Cross-validation on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2, PR head `668d51adb`, scratch-merged onto main `673f7406c` (no conflict; #6681 merges with it without conflict too). Windows only, no GPU involved. No local title lacks `PT_SCE_PROCPARAM`, so there is no title run. - `application_heap_without_parameters` and `windows_process_parameters`, `--repeat until-fail:3`: 3 of 3, together with the other 8 `application_heap*` tests (11 tests, all 3 of 3). The 102 relinker tests also pass 3 of 3 on the merged tree. - Negative control: with `ApplicationHeap.cpp` and `ApplicationProcessParameters.cpp` from main (test kept) `application_heap_without_parameters` fails with `application heap: process parameters exceed the image`, as you describe. With `WindowsPePatcher.cpp` from main `windows_process_parameters` fails (`AssertionError: []`, no `.procpar` section). With the changes both pass. - `tools/check_conventions.py --base origin/main` and `git diff --check`: pass. - Local titles: all 54 `eboot.elf` inputs I have (51 titles) contain a `PT_SCE_PROCPARAM` segment, so none exercises this path. Relinking all 51 for Windows with main's relinker and with this one gives identical SHA-256 for all 312 output files (PPSA99995 stops with the same TLS-instruction `FAIL` in both). I did not scan guest modules or secondary executables. - To see the effect on a real ELF I changed the `PT_SCE_PROCPARAM` header of one local eboot (PPSA69420) to `PT_NULL` and relinked it with `--windows`: main's relinker output has no `.procpar` section, this PR's has one with virtual size 8 and raw size 0. I did not run that executable. Not checked: Quake or other SDK payloads (not available here), Linux, macOS, a full-tree build, the full non-GPU suite. Written with Claude Code assistance (validation by a subagent, reviewed in this session).
MarcZX10 commented 2026-10-25 13:34:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T13:34:56Z.

Review: CHANGES_REQUESTED


Follow-up after manually merging this PR with #10947: your debt entry for application heap without process parameters combines cleanly, but the resulting libc debt file contains contradictory nearbyintf observations (this branch says it uses the host rounding mode; #10947 records console measurements where MXCSR controlled rounding) and two _Thrd_sleep entries with differing behavior. Please coordinate with #10947’s author and reconcile those existing notes against their evidence while preserving both PRs’ distinct implementation notes. Update the overlap/dependency checklist as needed. I found no conflicting code paths; this request is limited to making the combined documentation accurate and non-duplicated.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5643418084 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6713#pullrequestreview-5643418084). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T13:34:56Z. **Review:** CHANGES_REQUESTED --- Follow-up after manually merging this PR with #10947: your debt entry for application heap without process parameters combines cleanly, but the resulting libc debt file contains contradictory `nearbyintf` observations (this branch says it uses the host rounding mode; #10947 records console measurements where MXCSR controlled rounding) and two `_Thrd_sleep` entries with differing behavior. Please coordinate with #10947’s author and reconcile those existing notes against their evidence while preserving both PRs’ distinct implementation notes. Update the overlap/dependency checklist as needed. I found no conflicting code paths; this request is limited to making the combined documentation accurate and non-duplicated.

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!6713
No description provided.