Repository navigation
fix(libc): start the guest environment empty instead of copying the host's - #5772
Conversation
|
Cross-check on Windows: #5772 head Host: Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, NVIDIA RTX 4070 (Ryzen 7 5700X).
Titles. Catalog releases,
PS5MC on That run also created PS5MC with the PR: The run continues, with no Control: ProsperoRadio and ProsperoTV have no stop line with either build. The last lines are the periodic Verdict: confirmed. With AI-assisted: yes (Claude Code) |
|
Linux evidence for PS5MC (PPSA99420, catalog release): WSL2 Ubuntu 24.04, GCC 13.3.0,
Nothing was written to the host's AI-assisted: yes |
|
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.
|
|
The title on Windows, for the side that only had a build and tests: with this PR PS5MC reaches Kodi's home screen from a shell with Setup: Windows 11 Home 26300, AMD Radeon 860M (driver 32.0.13058.8001), WinLibs GCC 15.2.0, Release. Started from a Git for Windows bash, so
A frame dump from a third 45 s run shows Kodi 22's home screen (Estuary: main menu from TV to Weather, clock, the weather-provider prompt). The Not tested: Linux (covered above by @DavidSamir), NVIDIA. AI-assisted: yes (Claude Code) |
|
Checked the diff, |
What
PS5MC (PPSA99420) exits about a second after start with
XBMC_Run returned -1(exit code -1) when the host hasHOMEset. The guest environment is copied from the host's, so Kodi'sgetenv("HOME")returns a host path (C:\Users\<name>on Windows,/home/<name>on Linux) and it builds its profile folder from it (C:\Users\<name>/.kodi), which it then cannot use. WithoutHOMEin the host environment the title keeps running.HOMEis set on every Linux system, and on Windows by Git for Windows, MSYS2 and Cygwin shells, so this hits anyone who starts a title from them. On the console a title starts with no such variable, and libkernel'senvironexport is already an empty environment (#2090).Cause.
Environment()seeds the guest environment from the host CRT's_environ/environon first use, so every host variable (HOME,PATH,USERPROFILE,TEMPand the rest) is visible togetenv.The guest environment now starts empty.
getenv,setenv,unsetenvandputenvwork as before on the variables the title sets itself, and the host environment is still never changed. The runtime's own settings (APS5_TRACE_CALLS,ANYPS5_SYSTEM_FONTSand the others) are read by host code with the hostgetenv, so they are unaffected.Three commits:
fix(libc): start the guest environment empty instead of copying the host's:Environment.cpp, andguest_environment's first checks, which encoded the inheritance: a variable set in the host now reads as absent in the guest, and the host value is unchanged after guestsetenv.test(libc): keep the host's HOME and PATH out of the guest environment: withHOMEset in the host,getenv("HOME")andgetenv("PATH")in the guest return null.docs(debt): record that the guest environment starts empty.There is no fourth step to split out; the change is one function.
Tested
Windows (69715e8 on
main78f1aea, Windows 11 10.0.26300, WinLibs GCC 15.2.0 r7, Release):HOMEset in the host (C:\Users\<name>), alternating: withmain's libraries it exits with code -1 after 4 s and after 1 s, its last log line[kodi-ps5] heap: 2048 MiB of direct memory; with the branch's it is still running at 40 s both times. Run withoutHOMEin the host, it keeps running withmain's libraries too. The exit messageXBMC_Run returned -1and the pathC:\Users\<name>/.kodiwere on the stack whenLibcTerminate_nid_no_patchwas reached (gdb).Environment.cppas onmainand the tests kept,guest_environmentaborts (exit 0xc0000409) at the first new check, a host variable visible to the guest. With the change it passes 5/5 (--repeat until-fail:5), andguest_getopt,guest_call_trace,guest_call_trace_abort,guest_font,guest_font_writing_line,guest_hostname,guest_audio_in_capture,guest_audio_in_no_device,file_streamsandguest_posix_filesystempass 3/3. These include the tests that set host variables for the runtime's own settings andgetopt'sPOSIXLY_CORRECT, set through the guest'ssetenv.main's libraries and with the branch's,HOMEset in the host, windows kept off-screen: ccleste (PPSA59322), RommPS (PPSA76677), SwanStationPS5 (PPSA98510), ProsperoTV (PPSA99003), DOOM (PPSA99666), ScreenTester5 (PPSA69420), Prospero Vibrate (PPSA99920), SymphonyStation5 (PPSA17641), ProsperoStore (PPSA99000), OpenNOW (PPSA99082), ProsperoRadio (PPSA99001) and PSXS5 (PPSA97510) are all still running at 35 s with both, with the same last kind of log line. PSXS5 logged fewer periodic statistics lines in the first pair of runs; four more alternating runs gave 82 lines with each set.fdopenprobe that changes from run to run.ctest --parallel 4on a full build of the last commit: 1137 of 1137 pass.guest_environment,guest_getoptandguest_hostnamepass 3/3 at each. At no commit does a rebuilt library lose an exported name.tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.py --branchreports no overlap with open pull requests.Linux (same commit, WSL2 Ubuntu 24.04, GCC 13.3.0, Release):
libsbuilds, andguest_environmentandguest_getoptpass 3/3, so the guest no longer sees the Linux host's variables either.Not checked on a console. Whether the console starts a title with any environment variables at all is not measured; the debt note says so.
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)