Repository navigation
fix(libc): share guest environment with exported environ - #15095
oneandonlydean merged 3 commits into
Conversation
BunnyFl
left a comment
There was a problem hiding this comment.
The direction matches the console's design. In firmware 13.42, environ (+2thxYZ4syk) is a data export of libkernel.sprx (.data, 0x84278), and libSceLibcInternal.sprx (sha256 a01795ab49df639dd40abd6194956ada062244826824ce486c9acab227bf5285) imports it as an undefined data symbol. Its getenv (smbQukfxYJM, 0x74c00) loads the table through that import on every call, with no private copy (read from disassembly only, not measured on a console):
74c11: test rdi, rdi ; je ret-null
74c30..74c42: scan the name; '=' in the name -> return NULL
74c4a: mov rax, [rip+0x13de27] ; GOT slot: &environ
74c51: mov r14, [rax] ; environ
74c59: mov r12, [r14] ; walk environ[i]
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 current main:
guest_environment_allocation,guest_environment_binding,guest_environment_shared,guest_environment,guest_execvpandguest_system_configurationpass.- With
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_ROOT seed that the PR body mentions.
|
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.
|
|
Hi lgqdaxia, Reviewed at
Cause: libkernel.prx exports 24 A local check at this head: adding if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(libkernel PRIVATE -fno-gnu-unique)
endif()to core/libs/prx/libkernel/CMakeLists.txt leaves 0 UNIQUE symbols in libkernel.prx. The test then unloads and reloads libkernel and passes all of its checks ( Could you either:
|
✅ AMD GPU test: passedPR head
Unstable on main (2, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (13, not counted against this PR)Passed on retry (2, failed in the parallel run, passed when re-run with a 360 s timeout; not counted against this PR)Validated but not compared (1, not in the main baseline's validation pass)Validation IDs already present on main (4 IDs in 754 tests)Skipped (60)ReproduceAutomated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
|
Thanks for identifying the full-libkernel GCC loader behavior and testing the flag alternative. I took option 2 in
I left libkernel's production compiler options unchanged. Disabling GNU_UNIQUE would change static-object sharing beyond this environment fix, and I have not established the requested cross-module static audit. Validation: the real Windows full-project Ninja configuration and registration audit pass (1,825 executables, zero registration gaps). The changed fixture was compiled against the unchanged, previously validated Windows libc/libkernel artifacts; both registered split CTests pass with no skips. This reused those artifacts rather than rebuilding production libraries. The skip-policy suite passes all 37 tests on Windows and Linux. In WSL/GCC 13.3, actual-source Environment/Process component DSOs pass all three Shared/Binding/Unload tests when unloadable. A separate test-only |
BunnyFl
left a comment
There was a problem hiding this comment.
Re-review of 15f38f293b (delta over my approval at a535212ecd): the adoption checks now sit in guest_environment_binding, which has no skip code. Only guest_environment_binding_unload keeps SKIP_RETURN_CODE 77. The tools/check_skips.py exception 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 at core/libs/tests/GuestEnvironmentBinding.cpp:74.
Windows 11, WinLibs GCC, merged onto current main:
- PR:
guest_environment_binding,guest_environment_binding_unload,check_skipsandcheck_skips_ctestpass. The unload test ran rather than skipping. - Main's
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.
|
Correction to the last line of my approval: in CI the non-Windows |
✅ AMD GPU test: passedPR head
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (12, not counted against this PR)Validated but not compared (1, not in the main baseline's validation pass)Validation IDs already present on main (4 IDs in 754 tests)Skipped (60)ReproduceAutomated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
15f38f2 to
91bd22c
Compare
✅ AMD GPU test: passedPR head
Unstable on main (3, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (11, not counted against this PR)Validated but not compared (1, not in the main baseline's validation pass)Validation IDs already present on main (8 IDs in 799 tests)Skipped (62)ReproduceAutomated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
91bd22c to
1e00648
Compare
BunnyFl
left a comment
There was a problem hiding this comment.
@lgqdaxia re-checked at 1e006482e7, still approved.
git range-diff against my last approval (15f38f293b): the test commit is identical, and in the fix commit only context lines moved, from the main changes it was rebased over (a neighbouring declaration in General.hpp, and the mergesort and select debt entries main rewrote). 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 main b611e634f7 (2efb13e049):
guest_environment_allocation,guest_environment_binding,guest_environment_binding_unload,guest_environment_sharedandguest_system_configuration: 5 of 5 pass.- Negative control: the same tree with
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 --branch on this head:
- Line overlaps it confirmed are all adjacent edits rather than the same change: #12970 registers its test next to
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. - The tool could not compare 78 PRs that conflict with
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. - #7715 (renzipego-cpu) is the one real overlap: it seeds the initial
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.
1e00648 to
f0252c7
Compare
BunnyFl
left a comment
There was a problem hiding this comment.
@lgqdaxia re-checked at f0252c7af0. The approval stands.
git range-diff against my last approval (1e006482e7): the test commit is identical. In the fix commit only a context line moved: main rewrote the neighbouring __progname entry in docs/dev/debt/libkernel.md, which is the line next to the environ entry 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 (merge 8b59608b17, a clean auto-merge of docs/dev/debt/libkernel.md):
guest_environment_allocation,guest_environment_binding,guest_environment_binding_unload,guest_environment_sharedandguest_system_configuration: 5 of 5 pass.- Negative control: the same tree with
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 --branch on this head gives the same picture as at 1e006482e7. The confirmed line overlaps are the adjacent tools/check_skips.py and tools/tests/test_check_skips.py edits of #12750, #14902 and #9161. #7715 still rewrites the guest environment's initial entries in core/libs/prx/libc/src/Environment.cpp and remains the one real overlap: whichever lands second has to redo its change on the other.
AI-assisted: yes (Claude Code)
|
Hi @lgqdaxia, We merged current main into your branch (c4d53a7) so this can go ahead without another round. The only conflict was in |
|
Hi @lgqdaxia, Main moved again and the branch conflicted in |
|
Linux check of head Setup: Arch Linux x86-64, kernel 7.2.14-arch1-1, GCC 16.2.1 20260810, CMake 4.4.5, Ninja, Release,
So on this machine the loader-retention skip path is taken and the unload/reload checks do not run. Not run: other libc and libkernel tests, the head merged onto current AI-assisted: yes. |
5d41187 to
bd2dd42
Compare
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)