fix(libc): share guest environment with exported environ #15095
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15095"
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 lgqdaxia on 2026-11-02T15:49:25Z.
What
Follow-up to Discussion #11161: bind libc's environment APIs to libkernel's exported
environ, so API calls and direct table replacements see the same values.Loading libkernel adopts the existing environment; actual unload detaches to libc-owned storage and reload binds again. Whole/null/offset table replacements, live
putenvaliases, owned-string retention and allocation-failure preservation are covered. The guest environment remains separate from hostHOME/PATH.Adoption and unload are separate tests. Adoption never skips; unload may report loader retention. The Linux skip audit accepts only that exact unload test and diagnostic, not other skips or Windows retention.
Tested
Nov 12, head
bd2dd42740on maine4aa14827b: rebased and moved the three new test executables into the required per-executable CMake fragments. Registration commands and all other topic changes are unchanged. All 41 skip-audit checks, fragment parsing/BUILD_TESTING=OFFinclusion, Python syntax, whitespace and exact PR conventions pass.Scope: same-process coherence. Console initial values, exact storage identity and duplicate/malformed tables remain recorded debt.
Earlier validation and overlap notes
On earlier head
a6e86fe483, hosted checks passed Windows and the relinker matrix; full Linux and pipe-write jobs were skipped. A Linux check of that head passed five checks plus the unload-retention skip, repeated three times; unload/reload was not exercised.Original head
a535212ecd: Windows production libraries/relinker and affected targets built; 9 focused CTests and 65 public-header tests passed. Original-main Shared/Binding controls failed. Four actual-source Linux component checks passed.Follow-up
15f38f293b: both split Windows tests passed; the real-project registration audit passed (1825 executables). Linux components passed Shared/adoption/unload (3/3); a test-only NODELETE component passed Shared/adoption and skipped unload. These component results do not claim a full Linux product build. Historical skip-policy checks passed on Windows/Linux.BunnyFl's review of
f0252c7af0reports five Windows environment checks passing and three expected negative-control failures. Later main integrations retain the original changes and maintainer commits.#7715's initial-environment values are a real overlap, not a prerequisite; no combined runtime result or merge order is established. Earlier adjacent declarations, registrations and debt edits are retained. Historical results keep their tested heads/platforms.
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)Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T16:03:41Z.
Review: APPROVED
The direction matches the console's design. In firmware 13.42,
environ(+2thxYZ4syk) is a data export oflibkernel.sprx(.data,0x84278), andlibSceLibcInternal.sprx(sha256a01795ab49df639dd40abd6194956ada062244826824ce486c9acab227bf5285) imports it as an undefined data symbol. Itsgetenv(smbQukfxYJM,0x74c00) loads the table through that import on every call, with no private copy (read from disassembly only, not measured on a console):So making libc read and write libkernel's exported table, as this PR does, is how the console's libc behaves.
Build and test on Windows (WinLibs GCC,
BUILD_TESTING=ON), PR merged into currentmain:guest_environment_allocation,guest_environment_binding,guest_environment_shared,guest_environment,guest_execvpandguest_system_configurationpass.main'sEnvironment.cpp,Process.cppandGeneral.hpprestored (the PR'sApi.hppdeclaration kept so the fixtures compile),guest_environment_bindingandguest_environment_sharedabort.guest_environment_allocationcompilesEnvironment.cppitself, so it has nomaincontrol.I didn't check the composition with #7715's
ASOBI_ROOTseed that the PR body mentions.Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-03T01:56:44Z.
Review: APPROVED
Re-review of
15f38f293b(delta over my approval ata535212ecd): the adoption checks now sit inguest_environment_binding, which has no skip code. Onlyguest_environment_binding_unloadkeepsSKIP_RETURN_CODE 77. Thetools/check_skips.pyexception is narrow: it applies outside the Windows branch, only to that exact test name, and only when the one skipped line is the exact string printed atcore/libs/tests/GuestEnvironmentBinding.cpp:74.Windows 11, WinLibs GCC, merged onto current
main:guest_environment_binding,guest_environment_binding_unload,check_skipsandcheck_skips_ctestpass. The unload test ran rather than skipping.General.hpp,Environment.cpp,Process.cppand libkernelApi.hpprestored: both binding tests abort (0xc0000409).Not run here: Linux, the only platform where the loader-retention skip and its audit exception can trigger.
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-04T20:53:36Z.
Review: APPROVED
@lgqdaxia re-checked at
1e006482e7, still approved.git range-diffagainst my last approval (15f38f293b): the test commit is identical, and in the fix commit only context lines moved, from themainchanges it was rebased over (a neighbouring declaration inGeneral.hpp, and themergesortandselectdebt entriesmainrewrote). None of the PR's own +/- lines changed.What I ran
Windows 11 Pro 10.0.26300, WinLibs GCC 15.2, Release, this head merged cleanly onto
mainb611e634f7(2efb13e049):guest_environment_allocation,guest_environment_binding,guest_environment_binding_unload,guest_environment_sharedandguest_system_configuration: 5 of 5 pass.core/libs/prx/libkernel/System/src/Process.cppfrommain(the fixed emptyenviron) failsguest_environment_binding,guest_environment_binding_unloadandguest_environment_shared(0xc0000409).tools/tests/test_check_skips.py: 37 tests pass (run onmain9f35c937da+ #15855 + this head).Overlap
tools/pr_overlap.py --branchon this head:guest_environment_sharedincore/libs/prx/libkernel/CMakeLists.txt; #12750 and #14902 edit the sameunexpected = ...line oftools/check_skips.pythat this PR extends; #9161 touches the same line oftools/tests/test_check_skips.py.main. I compared the ones that change this PR's code files (Environment.cpp,Process.cpp,General.hpp,Api.hpp,GuestSystemConfiguration.cpp): #5021, #7804, #11939, #13486, #14085, #9447 and #15781 change nothing environment-related there.entriesof the guest environment incore/libs/prx/libc/src/Environment.cpp, which this PR rewrites. Whichever lands second has to redo its change on the other.Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-06T17:49:27Z.
Review: APPROVED
@lgqdaxia re-checked at
f0252c7af0. The approval stands.git range-diffagainst my last approval (1e006482e7): the test commit is identical. In the fix commit only a context line moved:mainrewrote the neighbouring__prognameentry indocs/dev/debt/libkernel.md, which is the line next to theenvironentry this PR removes. None of the PR's own +/- lines changed.What I ran
Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0, Release, this head merged onto current
main(merge8b59608b17, a clean auto-merge ofdocs/dev/debt/libkernel.md):guest_environment_allocation,guest_environment_binding,guest_environment_binding_unload,guest_environment_sharedandguest_system_configuration: 5 of 5 pass.main'score/libs/prx/libkernel/System/src/Process.cppfailsguest_environment_binding,guest_environment_binding_unloadandguest_environment_shared(0xc0000409); 2 of 5 pass.tools/check_conventions.py --base upstream/main --headon this head: all checks pass.Overlap
tools/pr_overlap.py --branchon this head gives the same picture as at1e006482e7. The confirmed line overlaps are the adjacenttools/check_skips.pyandtools/tests/test_check_skips.pyedits of #12750, #14902 and #9161. #7715 still rewrites the guest environment's initial entries incore/libs/prx/libc/src/Environment.cppand remains the one real overlap: whichever lands second has to redo its change on the other.AI-assisted: yes (Claude Code)