Repository navigation
fix(libc): keep the app0.zar state through exit handlers - #7558
Merged
Merged
Conversation
Every path resolution reaches the app0.zar state, which was a function-local static: it is destroyed during exit before the handlers registered ahead of its first use run, so a path resolved in such a handler locked a destroyed mutex. glibc lets that pass; macOS fails it with EINVAL, and guest_path_lifetime failed there. The state is now allocated once and never destroyed, as the working directory state beside it already is.
MarcZX10
approved these changes
Oct 18, 2026
MarcZX10
left a comment
Contributor
There was a problem hiding this comment.
Reviewed the change against the exit-ordering failure and current call sites. Keeping Archive alive for the process lifetime prevents its mutex and reader from being destroyed before registered exit handlers finish resolving app0 paths; this matches the lifetime used for the shared directory state.
The PR reports a focused macOS guest_path_lifetime fail/pass reproduction, and its hosted checks are green. I did not run the macOS reproduction locally. I found no correctness issue in this diff.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
guest_path_lifetimefails on macOS onmainsince #5835:path services during exit: mutex lock failed: Invalid argument. Every path resolution reaches the app0.zar state inAppArchive.cpp, which was a function-local static. The test registers an exit handler before its first path resolution, so the static is constructed after the handler is registered and destroyed before it runs: the handler resolves a path and locks the destroyed mutex. glibc does not check that; macOS fails the lock withEINVAL.The state is now allocated once and never destroyed, as the working directory state in
General.cpp(Directories()) already is.#7332, which brings the open macOS pull requests together, makes the same change to
State()among its other fixes; this pull request is that change on its own.Tested
main385ed71 with the macOS series and the open macOS fixes fix(libkernel): create the JIT shared memory backing on macOS hosts #6928, fix(libkernel_sys): build and check fchdir search permission on macOS #6667, fix(libSceLibcInternal): read statvfs by path on macOS #6668, fix(tests): keep generic category vtable entries castable to functions #6969, fix(libc): keep errno when strtol converts nothing on macOS #6853, fix(libkernel): set the open file limit at load on macOS #6836, perf(libc): add steady_clock fast path in PreciseSleepUntil #6620 and fix(tests): compare the Bessel exports with fixed reference values #7524 (the libraries do not link on macOS without the series):guest_path_lifetimefails without this change and passes with it;guest_kernel_app_archive_archiveandguest_kernel_app_archive_plainpass.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)