Skip to content

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

Closed
karimibrahim07 wants to merge 2 commits into
boykopovar:mainfrom
karimibrahim07:fix/libc-heap-without-process-parameters
Closed

karimibrahim07 wants to merge 2 commits into
boykopovar:mainfrom
karimibrahim07:fix/libc-heap-without-process-parameters

Conversation

@karimibrahim07

Copy link
Copy Markdown
Contributor

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 fix(relinker): resolve symbol-name imports through NIDs on Windows #6697, fix(relinker): leave weak imports of bundled modules unbound on Windows #6702 and feat(libc): implement qsort_s #6707.

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

Checklist

…ameters

An ELF without a PT_SCE_PROCPARAM segment, such as a ps5-payload-dev
SDK program, had no .procpar section after relinking, so the first
allocation stopped with "process metadata is missing; relink the
executable".

The Windows relinker now writes a .procpar section that records no
parameters for such an ELF, and the application heap registers its
default allocator when it finds that record. An executable without
any .procpar section still gets the relink message.
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 3965 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 5021 core/libs/prx/libc/CMakeLists.txt
core/libs/prx/libc/src/ApplicationProcessParameters.cpp
core/relinker/CMakeLists.txt
docs/dev/debt/libc.md
PR 5303 docs/dev/debt/libc.md
PR 6084 core/libs/prx/libc/CMakeLists.txt
PR 6085 core/libs/prx/libc/CMakeLists.txt
PR 6204 core/relinker/CMakeLists.txt
PR 6565 docs/dev/debt/libc.md
PR 6819 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 7081 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 7173 core/relinker/CMakeLists.txt
PR 7386 docs/dev/debt/libc.md
PR 7447 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 7531 core/relinker/CMakeLists.txt
PR 7532 core/relinker/CMakeLists.txt
PR 7544 docs/dev/debt/libc.md
PR 7648 docs/dev/debt/libc.md
PR 7704 core/relinker/CMakeLists.txt
PR 7715 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 7851 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 8150 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 8251 core/relinker/CMakeLists.txt
PR 8397 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 8417 docs/dev/debt/libc.md
PR 8937 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 8965 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 9087 docs/dev/debt/libc.md
PR 9340 docs/dev/debt/libc.md
PR 9371 docs/dev/debt/libc.md
PR 9414 core/relinker/CMakeLists.txt
PR 9447 docs/dev/debt/libc.md
PR 9466 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 9526 docs/dev/debt/libc.md
PR 9584 core/libs/prx/libc/CMakeLists.txt
PR 9589 core/relinker/CMakeLists.txt
PR 9677 docs/dev/debt/libc.md
PR 9688 docs/dev/debt/libc.md
PR 9761 docs/dev/debt/libc.md
PR 9773 core/libs/prx/libc/CMakeLists.txt
PR 9775 core/libs/prx/libc/CMakeLists.txt
PR 9793 core/relinker/CMakeLists.txt
PR 9798 core/libs/prx/libc/CMakeLists.txt
PR 9863 docs/dev/debt/libc.md
PR 9867 docs/dev/debt/libc.md
PR 9873 docs/dev/debt/libc.md
PR 9929 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 9935 docs/dev/debt/libc.md
PR 9953 docs/dev/debt/libc.md
PR 9964 docs/dev/debt/libc.md
PR 10002 docs/dev/debt/libc.md
PR 10007 docs/dev/debt/libc.md
PR 10113 docs/dev/debt/libc.md
PR 10142 core/relinker/CMakeLists.txt
PR 10158 docs/dev/debt/libc.md
PR 10165 docs/dev/debt/libc.md
PR 10200 docs/dev/debt/libc.md
PR 10222 docs/dev/debt/libc.md
PR 10226 docs/dev/debt/libc.md
PR 10229 docs/dev/debt/libc.md
PR 10234 docs/dev/debt/libc.md
PR 10245 docs/dev/debt/libc.md
PR 10247 docs/dev/debt/libc.md
PR 10250 docs/dev/debt/libc.md
PR 10253 docs/dev/debt/libc.md
PR 10265 docs/dev/debt/libc.md
PR 10270 docs/dev/debt/libc.md
PR 10274 docs/dev/debt/libc.md
PR 10315 docs/dev/debt/libc.md
PR 10317 docs/dev/debt/libc.md
PR 10321 docs/dev/debt/libc.md
PR 10324 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 10325 docs/dev/debt/libc.md
PR 10328 docs/dev/debt/libc.md
PR 10345 docs/dev/debt/libc.md
PR 10349 docs/dev/debt/libc.md
PR 10397 docs/dev/debt/libc.md
PR 10405 docs/dev/debt/libc.md
PR 10433 docs/dev/debt/libc.md
PR 10495 core/relinker/CMakeLists.txt
PR 10506 docs/dev/debt/libc.md
PR 10510 docs/dev/debt/libc.md
PR 10512 docs/dev/debt/libc.md
PR 10565 docs/dev/debt/libc.md
PR 10569 docs/dev/debt/libc.md
PR 10615 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 10620 docs/dev/debt/libc.md
PR 10729 docs/dev/debt/libc.md
PR 10749 docs/dev/debt/libc.md
PR 10780 docs/dev/debt/libc.md
PR 10792 core/relinker/CMakeLists.txt
PR 10861 core/relinker/CMakeLists.txt
core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp
PR 10895 docs/dev/debt/libc.md
PR 10927 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 10929 docs/dev/debt/libc.md
PR 10953 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 10970 core/relinker/CMakeLists.txt
PR 10983 core/relinker/CMakeLists.txt
PR 10987 docs/dev/debt/libc.md
PR 10989 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 11077 docs/dev/debt/libc.md
PR 11107 core/relinker/CMakeLists.txt
PR 11109 docs/dev/debt/libc.md
PR 11172 docs/dev/debt/libc.md
PR 11214 docs/dev/debt/libc.md
PR 11260 docs/dev/debt/libc.md
PR 11262 docs/dev/debt/libc.md
PR 11266 docs/dev/debt/libc.md
PR 11270 docs/dev/debt/libc.md
PR 11332 docs/dev/debt/libc.md
PR 11341 core/libs/prx/libc/src/ApplicationProcessParameters.cpp
docs/dev/debt/libc.md
PR 11432 core/relinker/CMakeLists.txt
core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp
PR 11468 core/libs/prx/libc/CMakeLists.txt
PR 11504 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 11565 core/relinker/CMakeLists.txt
PR 11621 docs/dev/debt/libc.md
PR 11624 core/libs/prx/libc/CMakeLists.txt
PR 11625 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 11628 core/libs/prx/libc/CMakeLists.txt
core/relinker/CMakeLists.txt
core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp
PR 11632 docs/dev/debt/libc.md
PR 11634 docs/dev/debt/libc.md
PR 11661 core/libs/prx/libc/CMakeLists.txt
core/relinker/CMakeLists.txt
core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp
docs/dev/debt/libc.md
PR 11664 docs/dev/debt/libc.md
PR 11689 core/libs/prx/libc/CMakeLists.txt
core/relinker/CMakeLists.txt
core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp
docs/dev/debt/libc.md
PR 11698 core/libs/prx/libc/CMakeLists.txt
core/relinker/CMakeLists.txt
core/relinker/elfpatcher/src/windows/WindowsPePatcher.cpp
docs/dev/debt/libc.md
PR 11724 docs/dev/debt/libc.md
PR 11726 docs/dev/debt/libc.md
PR 11733 docs/dev/debt/libc.md
PR 11773 docs/dev/debt/libc.md
PR 11793 docs/dev/debt/libc.md
PR 11831 docs/dev/debt/libc.md
PR 11843 docs/dev/debt/libc.md
PR 11848 core/libs/tests/ApplicationHeap.cpp
docs/dev/debt/libc.md
PR 11849 docs/dev/debt/libc.md
PR 11850 docs/dev/debt/libc.md
PR 11852 docs/dev/debt/libc.md
PR 11870 docs/dev/debt/libc.md
PR 11892 docs/dev/debt/libc.md
PR 11893 docs/dev/debt/libc.md
PR 11895 docs/dev/debt/libc.md
PR 11907 docs/dev/debt/libc.md
PR 11947 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 11960 core/relinker/CMakeLists.txt
PR 12053 docs/dev/debt/libc.md
PR 12054 docs/dev/debt/libc.md
PR 12057 docs/dev/debt/libc.md
PR 12060 docs/dev/debt/libc.md
PR 12068 core/relinker/CMakeLists.txt
PR 12071 core/libs/prx/libc/CMakeLists.txt
PR 12111 docs/dev/debt/libc.md
PR 12117 docs/dev/debt/libc.md
PR 12122 docs/dev/debt/libc.md
PR 12146 core/libs/prx/libc/CMakeLists.txt
PR 12149 docs/dev/debt/libc.md
PR 12160 core/libs/prx/libc/CMakeLists.txt
PR 12162 docs/dev/debt/libc.md
PR 12178 docs/dev/debt/libc.md
PR 12184 core/libs/tests/ApplicationHeap.cpp
docs/dev/debt/libc.md
PR 12186 docs/dev/debt/libc.md
PR 12255 core/relinker/CMakeLists.txt
PR 12258 core/relinker/CMakeLists.txt
PR 12271 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 12327 core/libs/prx/libc/CMakeLists.txt
PR 12355 core/relinker/CMakeLists.txt
PR 12363 docs/dev/debt/libc.md
PR 12364 docs/dev/debt/libc.md
PR 12365 docs/dev/debt/libc.md
PR 12381 core/relinker/CMakeLists.txt
PR 12397 docs/dev/debt/libc.md
PR 12420 docs/dev/debt/libc.md
PR 12428 docs/dev/debt/libc.md
PR 12468 docs/dev/debt/libc.md
PR 12469 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 12480 docs/dev/debt/libc.md
PR 12495 core/relinker/CMakeLists.txt
PR 12500 core/relinker/CMakeLists.txt
PR 12501 core/relinker/CMakeLists.txt
PR 12510 docs/dev/debt/libc.md
PR 12511 docs/dev/debt/libc.md
PR 12514 docs/dev/debt/libc.md
PR 12518 docs/dev/debt/libc.md
PR 12519 core/libs/prx/libc/CMakeLists.txt
PR 12520 core/relinker/CMakeLists.txt
PR 12524 docs/dev/debt/libc.md
PR 12527 docs/dev/debt/libc.md
PR 12530 docs/dev/debt/libc.md
PR 12532 docs/dev/debt/libc.md
PR 12553 docs/dev/debt/libc.md
PR 12555 docs/dev/debt/libc.md
PR 12560 docs/dev/debt/libc.md
PR 12574 docs/dev/debt/libc.md
PR 12586 docs/dev/debt/libc.md
PR 12589 docs/dev/debt/libc.md
PR 12592 docs/dev/debt/libc.md
PR 12593 docs/dev/debt/libc.md
PR 12594 docs/dev/debt/libc.md
PR 12595 docs/dev/debt/libc.md
PR 12597 docs/dev/debt/libc.md
PR 12598 docs/dev/debt/libc.md
PR 12605 docs/dev/debt/libc.md
PR 12622 docs/dev/debt/libc.md
PR 12627 docs/dev/debt/libc.md
PR 12659 docs/dev/debt/libc.md
PR 12678 core/relinker/CMakeLists.txt
PR 12682 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 12688 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 12691 docs/dev/debt/libc.md
PR 12700 core/libs/prx/libc/CMakeLists.txt
docs/dev/debt/libc.md
PR 12704 docs/dev/debt/libc.md

@screamm

screamm commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

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).

@xXPBSXx

xXPBSXx commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

This PR now conflicts with main in docs/dev/debt/libc.md only (one debt entry; the code files apply cleanly), and no review has asked for changes yet. If you cannot get to the rebase, I can open a new PR from this branch with your two commits and authorship kept, rebased on main, no earlier than 24 hours after this comment; say here if you would rather do it yourself.

AI-assisted (Claude Code).

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@roboterspinne

Copy link
Copy Markdown
Contributor

@karimibrahim07 @MarcZX10 From #10947's side there is nothing to reconcile: it does not touch docs/dev/debt/libc.md (git diff upstream/main... of #10947 on that file is empty). The nearbyintf and _Thrd_sleep texts that differ are main's, from 2151929 (the console measurement of nearbyintf) and 81b28ce (precise Windows thread sleep), both newer than this branch's base 5d9dcc4; upstream/main plus this PR alone produces the same conflict block. Rebasing this PR on main, keeping main's entries and adding the new "Application heap without process parameters" line above nearbyintf, resolves it. Details in my reply on #10947: #10947 (comment)

Written with AI assistance (Claude Code). I ran the git checks above on my Windows 11 machine.

@Danigamer05 Danigamer05 mentioned this pull request Oct 27, 2026
12 tasks done
@karimibrahim07

Copy link
Copy Markdown
Contributor Author

Closing as landed through #11979, which carried both commits of this branch onto main (fc80fa90ff, 0cb4dde2ee). Thanks @xXPBSXx for the rebase and the follow-up commits, and @roboterspinne for tracing the nearbyintf/_Thrd_sleep notes back to main.

AI-assisted: yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build docs libc needs rebase Conflicts with main, rebase needed relinker

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants