fix(libc): implement guest getenv and setenv #2007
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!2007
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2007/head"
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?
@bobrass on GitHub · 2026-10-30 22:44 UTC · original
bobrass:codex/kytyps5-issue2000-getenv→main· +51 −2 · 1 files · 2 commits · closed without mergingSummary
init_envin a guest-owned map.LibcInternalgetenvimport and return values from that map.setenvimplementation update the same guest environment with the requested overwrite behavior, without changing the emulator host environment.This follows the corrected analysis in issue #2000: NID fallback is already version-agnostic, and these reported imports are missing implementations rather than version aliases. This only implements guest
getenv/setenv; it does not resolve the other missing symbols or claim that the affected homebrew titles will boot fully.Validation
git show --checkandgit diff --checkare clean.@coderabbitai[bot] on GitHub · 2026-10-30 22:46 UTC · original · edited 2026-10-30 23:04 UTC
No actionable comments were generated in the recent review.
eadb7f93-a1f6-4a73-9b37-cbbe9c059026Reviewing files that changed from the base of the PR and between
d53e1705c6and4611ba7541.src/libs/libC.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Walkthrough
The change adds mutex-protected guest environment storage initialized from
envp.init_envclears the stored values when it receives null parameters. Validsetenvcalls now store values and apply theoverwriterule. The newgetenvfunction looks up stored values and is registered inLibcInternal.Suggested reviewers:
nmzikChange: Bug fix
Merge Risk:
Minimal · up to
4611bNo concrete merge-blocking issue remains. Build and runtime validation are still outstanding.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 5 functions across 1 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.@ -62,0 +90,4 @@std::lock_guard lock(g_environment_mutex);auto variable = g_environment.find(name);if (variable == g_environment.end()) {g_environment.emplace(name, value);@coderabbitai[bot] on GitHub · 2026-10-30 22:52 UTC · original · edited 2026-10-30 23:04 UTC
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 4512
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 41222
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 16968
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 40884
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 5230
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 6540
Return
ENOMEMwhensetenvallocation fails.LIB_ADDstores the rawLibC::setenvaddress. It does not add an exception-translating wrapper.LibC::setenvcallsSetGuestEnvironmentVariablewithout catchingstd::bad_alloc. An allocation failure can therefore escape the export instead of returning-1with guesterrnoset toENOMEM. This is a narrow memory-pressure failure, not evidence of a broad outage.Suggested fix
✅ Addressed in commit
4611ba7@coderabbitai[bot] on GitHub · 2026-10-30 22:52 UTC · original · reviewed
Actionable comments posted: 1
079fb8b0-0f43-4bc5-94dc-6349c70f733bReviewing files that changed from the base of the PR and between
4919fdb6e6andd53e1705c6.src/libs/libC.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@ -62,0 +90,4 @@std::lock_guard lock(g_environment_mutex);auto variable = g_environment.find(name);if (variable == g_environment.end()) {g_environment.emplace(name, value);@bobrass on GitHub · 2026-10-30 23:00 UTC · original
Implemented in commit
4611ba75:setenvnow catchesstd::bad_alloc, sets the guesterrnotoENOMEM, and returns-1.git diff --checkis clean. I did not run tests or a build; host runtime validation remains needed.@ -62,0 +90,4 @@std::lock_guard lock(g_environment_mutex);auto variable = g_environment.find(name);if (variable == g_environment.end()) {g_environment.emplace(name, value);@coderabbitai[bot] on GitHub · 2026-10-30 23:04 UTC · original
@bobrass The supplied
src/libs/libC.cppconfirms the fix:setenvcatchesstd::bad_alloc, sets guesterrnotoPOSIX_ENOMEM, and returns-1. This addresses the finding.Build, test, and host runtime validation remain pending.
If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
✅ Review thread resolved.
You are interacting with an AI system.
Pull request closed