fix(libc): use the default heap for an executable without process parameters #11979
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11979"
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 xXPBSXx on 2026-10-27T14:23:04Z.
What
Carries #6713 (karimibrahim07, head
668d51adbd; both commits keep their authorship), rebased onto currentmainafter a conflict indocs/dev/debt/libc.md, as offered in the hand-off comment on that PR. The rebase adds only the new "Application heap without process parameters" line todocs/dev/debt/libc.md. The review asked to reconcile this PR's debt notes with #10947 (merged on 27 October); after the rebase this PR adds only that one line to the debt file, and its ownnearbyintfand_Thrd_sleepnotes are no longer part of the diff. Whether the entries onmainagree with each other is not checked here.An ELF without a
PT_SCE_PROCPARAMsegment, such as a ps5-payload-dev SDK program, got no.procparsection when relinked for Windows. Its first allocation then stopped withapplication heap: process metadata is missing; relink the executable(read in the code, not run on the unchangedmain). That message, added together with the.procparwriter in9f2b41b9a1, asks for a relink, but relinking such an ELF cannot add process parameters it does not have.WindowsPePatchernow writes a.procparsection with address 0 and size 0 when the ELF has noPT_SCE_PROCPARAMsegment.ApplicationProcessParameters_nid_no_patchreturns a static zeroed 0x40-byte block for that record, so callers that read the compiled SDK version at offset 16 see 0.ApplicationHeapInitialize_nid_no_patchrecognises that block by its address and registers the heap's existing default allocator, as it already does for an all-null replacement table.sceKernelGetProcParamreturns the result of that lookup, so it returns the same block (read in the code).An executable without any
.procparsection still gets the relink message (application_heap_stats_missingstill passes). The new entry indocs/dev/debt/libc.mdrecords that, on the console, such a program runs inside its launcher's process, whose parameters aren't modelled (this is the entry's wording, not something measured here). On Linux the process-parameter lookup is unchanged and still throwsapplication heap: invalid or missing process parameterswhen it finds none (read inApplicationProcessParameters.cpp, not run here).Overlap: 170 of the 1295 open pull requests change at least one of the files this PR touches;
git merge-treeof this branch with each of their heads, each on the merge base git finds, reports a conflict for 22 of them. 20 of those already conflict withmainon their own (almost all indocs/dev/debt/libc.md), so this change adds no landing order for them. #11302 (indocs/dev/debt/libc.md) and #11463 (incore/relinker/CMakeLists.txt) conflict only with this branch; whichever lands second rebases and keeps both changes. The authors of #11302 and #11463 are asked here which of the pull requests should land first, and this PR waits for their answer before the landing order is fixed. No pull request of mine is a dependency (Depends on: none).Tested
Windows 10 Pro (19045), WinLibs GCC 15.2.0 r7, Ninja Release,
BUILD_TESTING=ON, and Ubuntu 24.04 under WSL2 (a virtualised kernel, not bare-metal; GCC 13.3, Release), both onmain8ff4baf534with this branch on top; each arm built fresh (ninja exit code 0 read), 5 runs each:application_heap*(10 tests, including the newapplication_heap_without_parameters) and the new relinker testwindows_process_parameterspass, 11 of 11, in all five runs.mainwithApplicationHeap.cpp,ApplicationProcessParameters.cppandWindowsPePatcher.cppreverted and the tests kept: 2 of 11 fail in all five runs.application_heap_without_parametersstops with exit code0xc0000409, andwindows_process_parametersfails.application_heap*tests that exist on Linux andwindows_process_parameterspass, 13 of 13, in all five runs. With the three files reverted, 1 of 13 fails in all five runs:windows_process_parameters.maineece5da035(before the final rebase onto1089f2bbfd, which changes none of the PR's files or test targets): 3 runs each, Windows 11 of 11 and Linux (WSL2) 13 of 13.0cb4dde2ee, which returns null) and the new test,application_heap_without_parametersfails in all three runs (1 of 11); Linux (WSL2), 3 runs, 13 of 13 pass. The callers that read offset 16 were not run.python tools/check_conventions.py --base upstream/mainpasses with this title and description;git merge-treeagainstmain1089f2bbfdis clean.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Co-authored by the original author of #6713.
AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-28T05:35:33Z.
Review: COMMENTED
Reviewed the relinker half on the head
944b4d753e, merged ontomain895ead67f7. I could not build the libc half or itsapplication_heap_without_parameterstest: they are Windows-only, and I only have macOS here.Ran
ctest371 of 371 passed. The newwindows_process_parameterstest passes.windows-latestfailure on this run isshader_cache_native_pathstiming out after 20.36 s. This PR changes no shader files.main_fixture():.procparhas RVA0x11000, VirtualSize 8, SizeOfRawData 0, PointerToRawData 0, flags0x40000040. The loader zero-fills it, so the reader gets address 0 and size 0, which is what the new branch inApplicationProcessParameters_nid_no_patchexpects.Mutants of the
WindowsPePatcher.cpphunk, run against the new teststd::vector<std::uint8_t>(8, 1)std::vector<std::uint8_t>(4)std::vector<std::uint8_t>(16)0x40uchanged to0x80uRaw size and raw offset are both 0 here, so
storedisb""and the zero check passes whatever the section holds. The test only checks that the section exists. The reader rejects any VirtualSize other than 8 (invalid process metadata section), so mutants 4 and 16 would fail at runtime on Windows while this test still passes. This is not blocking, but one more assertion catches both of them. The head still passes with it:I only read the libc side. Using
foundinstead ofresult != nullptrkeeps the duplicate check working when the empty record comes first. The new debt line says that returning a zeroed block, not null, fromsceKernelGetProcParamhas not been measured, which is right.AI-assisted: yes