fix(libc): preserve path services through process exit #4994
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4994"
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 krishalivaibhav on 2026-10-13T07:34:15Z.
What
Keep the working-directory and path-alias services alive through host process exit. Detached guest file workers and exit callbacks can still call
ResolvePathafter C++ function-static destructors have run. Their mutexes and path/alias storage currently disappear during that interval.A local Don’t Starve Together (PPSA02070) crash on macOS shows a guest thread in
mutex::lock → ResolvePath → sceKernelOpenconcurrently with the exit thread in__cxa_finalize_ranges → exit → LibcExit. This patch preserves both process-owned services; it does not change normal path mapping, join all guest threads, fix other teardown services, or claim stable game playback.The new Unix subprocess regression registers its native exit probe before first use of these services, then resolves root/relative/alias paths, updates an alias and reads
getcwdfrom a joined worker during exit. OS process teardown reclaims the intentionally retained objects.Tested
mutex lock failed: Invalid argument. A working-directory-only fix also fails; keeping both services alive passes.guest_path_lifetime,guest_working_directoryandguest_exit_ordereach passed three consecutive runs (nine successful executions).guest_path_casecase-distinct-file assertion fails identically with original and candidate source on this case-insensitive Mac filesystem; no test was weakened.30caf2b2a5641764312a5586eebe888e4074a209. The local runtime tests above include other unpublished macOS integration patches; they do not establish a clean-main full build. The new focused clean-Linux evidence is recorded below; full Linux/Windows suites remain unverified. The Unix exit regression is not registered on Windows; Linux may expose the destroyed storage differently from Darwin’s mutex error.#4927 also edits
General.cppbut only the allocated-buffergetcwdbehavior; this patch changes the two service accessors and does not depend on it.Additional verified Linux evidence
Clean Linux execution on the exact head
99ae2e812b20d9f3d6f84685948d07de3ee45dbe: built the actual runtime andguest_path_lifetime,guest_working_directory, andguest_exit_ordertargets; all three passed three consecutive runs. A production-only negative control restored parentGeneral.cppwhile keeping the new fixture and CMake registration;guest_path_lifetimefailed. Restoring the candidate and rebuilding passed all three tests three times again. Hosted logs. This is a focused clean-head Linux result, not a full project suite or Windows exit-lifetime coverage.Checklist
main; no other open PR found implementing these accessor lifetime changesImported from boykopovar/AnyPS5. Originally posted by krishalivaibhav on 2026-10-13T07:34:56Z.
Maintainer CI request: could someone dispatch
build.ymlfrommainwithpr=4994to run the Linux and Windows builds/tests? The API rejects my dispatch with HTTP 403 (repository admin rights required).The Unix regression reproduces the original mutex error in our modified local Mac runtime and passes with both path services retained; the PR description states that limitation explicitly. The draft is awaiting clean-main CI, not claiming a full Mac build or stable title playback.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by krishalivaibhav on 2026-10-13T07:36:51Z.
Additional bounded title check, with the updated local runtime: a normal exit request at 30 seconds was followed by a different crash at 36 seconds. Its faulting guest thread is in
DirectMemoryAllocwhile the exit thread is again in__cxa_finalize_ranges → exit → LibcExit. The path regression passes, but this is not a complete game-shutdown fix. Other runtime services can still be accessed by live guest threads during host teardown; lifecycle coordination remains separate work.Discriminating local regression evidence (same repaired fixture throughout):
mutex lock failed: Invalid argument.guest_path_lifetime,guest_working_directory,guest_exit_ordereach pass three runs.This supports the narrow lifetime change in this PR. It does not establish stable Don’t Starve Together playback, a frame-rate gain, or clean-main platform test success. The shared validation-cache optimization is separate local work and is not included here.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T11:25:14Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libc/src/General.cppL123Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T17:27:32Z.
Checked on Linux (this PR merged onto current main):
guest_path_lifetimepasses and fails withGeneral.cppreverted; the libs/libc test scope (104 tests) is green, including allapplication_heap*tests. Theapplication_heap_replacementabort reported above does not reproduce with this PR alone (it concernsgetcwd(NULL, size), i.e. #4927). Windows exit-lifetime is not covered by the test; merging once the full build is green.