fix(libc): retain owned storage borrowed by putenv #4823
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4823"
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 QRMOE on 2026-10-12T23:00:50Z.
What
Keep environment-owned storage alive when
putenvreceives a pointer into it. On current main,setenv("A", "A=value", 1); putenv(getenv("A"));replaces the owning entry with a borrowed pointer and frees its backing string. Later environment allocations can overwrite the registered value or make it disappear.Share ownership of the backing string with entries that borrow from it, including nested aliases. Ordinary caller-owned
putenvbuffers stay borrowed and remain live when the caller edits them. The allocation is released when its last owning entry is removed.FreeBSD 11.4
putenvretains the old owned entry when registering such a pointer. The regression covers short and large strings, self aliases, cross-variable aliases after removal or a larger replacement, nested aliases, and subsequent allocation churn.Tested
Windows, MinGW GCC 15.2, Release,
BUILD_TESTING=ON:putenv lost an aliased environment value.git diff --checkpassed. No title playback was tested.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 repositoryImported from boykopovar/AnyPS5. Originally posted by nicolasfalesy on 2026-10-13T07:24:56Z.
Linux test (Arch, GCC 16.2.1, glibc, Release), this PR merged onto
main7e181fcc3together with #4927, #4903, #4877, #4822 and #4823 (no conflicts):guest_environmentpasses. With this PR's source change reverted (test kept),guest_environmentfails on Linux, so the check guards the change on Linux too.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:37:31Z.
Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.
Imported from boykopovar/AnyPS5. Originally posted by QRMOE on 2026-10-15T07:43:41Z.
Understood. I’ll leave this closed and revisit it only with a title ID and a current-main log showing the failure. I’ll hold off on new PRs without a title needing the change while the queue is high.
Pull request closed