fix(libSceLibcInternal): fail posix_spawn with ENOENT when the program is not there #6233

Merged
milescoviello merged 1 commit from upstream-pr/6233 into main 2026-10-18 20:37:15 +00:00
milescoviello commented 2026-10-15 06:05:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-15T06:05:35Z.


What

Dusklight (PPSA99305, catalog 1.0.0) aborts on main d92a8dad3 as soon as Select disc image is chosen on its first menu, with no disc image in its folder:

terminate called after throwing an instance of 'std::runtime_error'
  what():  posix_spawnp: process creation not implemented

With a temporary print in posix_spawnp (not part of this PR), the title calls it twice with file zenity, arguments zenity --version and three file actions. Its next log line names SDL's file dialog: File selection failed: File dialog driver unsupported (supported values for SDL_HINT_FILE_DIALOG_DRIVER are 'zenity' and 'portal'). The port's own patch says the console has no file dialog (dusklight.patch); it takes a disc image from its folder instead.

FreeBSD 11.4's posix_spawn returns the error the child's exec leaves, and writes the process ID only when the exec succeeds (_posix_spawn_thr, do_posix_spawn). posix_spawnp searches PATH, or _PATH_DEFPATH when it is unset, and fails with ENOENT when no directory holds the program (_execvpe, execvPe).

Both calls now look for the program in the guest file system the same way. When it is not there they return ENOENT without writing the process ID; when it is there they still throw, since no process is created. This is the same model system already uses (a sandbox without /bin/sh). The attributes and file actions are not applied, and whether the console lets the child be created at all is unverified; docs/dev/debt/libSceLibcInternal.md records both.

guest_posix_spawn now spawns an existing and a missing program by path, through a PATH search (including an empty entry, which means the working directory) and with PATH unset.

Tested

Ubuntu 24.04, GCC 13.3, Release, on main d92a8dad3:

  • guest_posix_spawn passes 3/3. With main's Spawn.cpp and the new checks, it fails 3/3 with posix_spawn: process creation not implemented for the missing program.
  • All 376 guest_* tests pass or skip; the 5 guest_video_out_* skips are their own no-display check.
  • PPSA99305 1.0.0, relinked with --to-intel and run with pad input from 8 s (RTX 4070 Ti, NVIDIA 595.99): on main it aborts at 8–9 s in 3 of 3 runs, at the first Cross press. With this change, 6 of 7 runs reach the 30–45 s limit: the title logs File selection failed, stays on its menu, and opens and moves through its Settings window (seen in screenshots). One run exited with code 0 at 11 s. Choosing the title's own Quit item gives the same exit; I did not capture which item that run chose.
  • Wind Waker (PPSA99309), the other title the old debt entry names, exits by itself at 2 s with no disc image ("no game found") and does not reach this call.
  • tools/check_conventions.py --base upstream/main passes, and tools/pr_overlap.py --branch fix/spawn-missing-program finds no overlap.

On Windows 11 (RTX 3070, NVIDIA 610.60, MinGW), @DavidSamir ran Dusklight with this PR merged onto main 4eb91eacd. main aborts at the first Cross with posix_spawnp: process creation not implemented. With this PR, a Cross-only run logs File selection failed 79 times and is still running at its 150 s limit, and a mixed button sequence exits with code 0 at 16 s after reaching the menu's Quit, whose handler only sets IsRunning = false (comment). That also accounts for my one code-0 run.

Not checked on a console.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4868996909 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6233). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-15T06:05:35Z. --- ### What Dusklight (PPSA99305, catalog 1.0.0) aborts on `main` d92a8dad3 as soon as Select disc image is chosen on its first menu, with no disc image in its folder: ``` terminate called after throwing an instance of 'std::runtime_error' what(): posix_spawnp: process creation not implemented ``` With a temporary print in `posix_spawnp` (not part of this PR), the title calls it twice with file `zenity`, arguments `zenity --version` and three file actions. Its next log line names SDL's file dialog: `File selection failed: File dialog driver unsupported (supported values for SDL_HINT_FILE_DIALOG_DRIVER are 'zenity' and 'portal')`. The port's own patch says the console has no file dialog ([dusklight.patch](https://github.com/griches/PS5_Dusklight/blob/577c76212bec33198d69ca727433573ec00beb78/ps5/patches/dusklight.patch#L222-L224)); it takes a disc image from its folder instead. FreeBSD 11.4's `posix_spawn` returns the error the child's exec leaves, and writes the process ID only when the exec succeeds ([`_posix_spawn_thr`](https://github.com/freebsd/freebsd-src/blob/8c639945a44588f6cfdddfb057bb5aad88735da0/lib/libc/gen/posix_spawn.c#L227-L231), [`do_posix_spawn`](https://github.com/freebsd/freebsd-src/blob/8c639945a44588f6cfdddfb057bb5aad88735da0/lib/libc/gen/posix_spawn.c#L295-L303)). `posix_spawnp` searches `PATH`, or `_PATH_DEFPATH` when it is unset, and fails with `ENOENT` when no directory holds the program ([`_execvpe`](https://github.com/freebsd/freebsd-src/blob/8c639945a44588f6cfdddfb057bb5aad88735da0/lib/libc/gen/exec.c#L272-L281), [`execvPe`](https://github.com/freebsd/freebsd-src/blob/8c639945a44588f6cfdddfb057bb5aad88735da0/lib/libc/gen/exec.c#L257-L260)). Both calls now look for the program in the guest file system the same way. When it is not there they return `ENOENT` without writing the process ID; when it is there they still throw, since no process is created. This is the same model `system` already uses (a sandbox without `/bin/sh`). The attributes and file actions are not applied, and whether the console lets the child be created at all is unverified; `docs/dev/debt/libSceLibcInternal.md` records both. `guest_posix_spawn` now spawns an existing and a missing program by path, through a `PATH` search (including an empty entry, which means the working directory) and with `PATH` unset. ### Tested Ubuntu 24.04, GCC 13.3, Release, on `main` d92a8dad3: - `guest_posix_spawn` passes 3/3. With `main`'s `Spawn.cpp` and the new checks, it fails 3/3 with `posix_spawn: process creation not implemented` for the missing program. - All 376 `guest_*` tests pass or skip; the 5 `guest_video_out_*` skips are their own no-display check. - PPSA99305 1.0.0, relinked with `--to-intel` and run with pad input from 8 s (RTX 4070 Ti, NVIDIA 595.99): on `main` it aborts at 8–9 s in 3 of 3 runs, at the first Cross press. With this change, 6 of 7 runs reach the 30–45 s limit: the title logs `File selection failed`, stays on its menu, and opens and moves through its Settings window (seen in screenshots). One run exited with code 0 at 11 s. Choosing the title's own Quit item gives the same exit; I did not capture which item that run chose. - Wind Waker (PPSA99309), the other title the old debt entry names, exits by itself at 2 s with no disc image ("no game found") and does not reach this call. - `tools/check_conventions.py --base upstream/main` passes, and `tools/pr_overlap.py --branch fix/spawn-missing-program` finds no overlap. On Windows 11 (RTX 3070, NVIDIA 610.60, MinGW), @DavidSamir ran Dusklight with this PR merged onto `main` 4eb91eacd. `main` aborts at the first Cross with `posix_spawnp: process creation not implemented`. With this PR, a Cross-only run logs `File selection failed` 79 times and is still running at its 150 s limit, and a mixed button sequence exits with code 0 at 16 s after reaching the menu's Quit, whose handler only sets `IsRunning = false` ([comment](https://github.com/boykopovar/AnyPS5/pull/6233#issuecomment-6204293365)). That also accounts for my one code-0 run. Not checked on a console. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-15 12:17:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:17:09Z.


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.

Pull request Shared files not compared
PR 5021 docs/dev/debt/libSceLibcInternal.md
PR 6044 core/libs/tests/GuestPosixSpawn.cpp
PR 6447 core/libs/prx/libSceLibcInternal/Spawn.cpp
docs/dev/debt/libSceLibcInternal.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191841052 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6233#issuecomment-6191841052). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:17:09Z. --- <!-- pr-overlap --> 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. | Pull request | Shared files not compared | |---|---| | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `docs/dev/debt/libSceLibcInternal.md` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestPosixSpawn.cpp` | | [PR 6447](https://www.github.com/boykopovar/AnyPS5/pull/6447) | `core/libs/prx/libSceLibcInternal/Spawn.cpp`<br>`docs/dev/debt/libSceLibcInternal.md` |
DavidSamir commented 2026-10-15 23:18:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-15T23:18:40Z.


Windows result for this PR, with Dusklight (PPSA99305, catalog 1.0.0).

Setup: Windows 11, RTX 3070 (NVIDIA 610.60), MinGW build. This PR's head 3d42bdf0c5 merged onto main 4eb91eacdf. Relinked with --windows --registry, then run with pad input through APS5_PAD_INPUT_FILE, starting about 12 s after launch.

  • main (b7cedd900d; Spawn.cpp is the same on 4eb91eacdf): aborts at 7 s, at the first Cross press.
    terminate called after throwing an instance of 'std::runtime_error'
      what():  posix_spawnp: process creation not implemented
    
  • This PR, mixed button sequence (Cross, Down, Cross, Right, Cross, Circle, …): the title logs File selection failed: File dialog driver unsupported (supported values for SDL_HINT_FILE_DIALOG_DRIVER are 'zenity' and 'portal') 3 times and stays on its menu. It then exits with code 0 at 16 s, logging exit status 0: asking the shell to close the title.
  • This PR, Cross only (a Cross press every 1.2 s for 150 s): the title logs File selection failed 79 times and is still running when the 150 s limit stops it. It has no what() line and no exit.

On the code-0 exit you saw once: the prelaunch menu at the pinned dusklight commit 34a144a49 has Select Disc Image, Settings, Mods and Quit. Quit's handler only sets IsRunning = false (prelaunch.cpp). The Cross-only run never leaves Select Disc Image and never exits. So in my runs the code-0 exit comes from the mixed sequence reaching Quit, not from this change.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6204293365 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6233#issuecomment-6204293365). Originally posted by [DavidSamir](https://github.com/DavidSamir) on 2026-10-15T23:18:40Z. --- Windows result for this PR, with Dusklight (PPSA99305, catalog 1.0.0). Setup: Windows 11, RTX 3070 (NVIDIA 610.60), MinGW build. This PR's head 3d42bdf0c5 merged onto `main` 4eb91eacdf. Relinked with `--windows --registry`, then run with pad input through `APS5_PAD_INPUT_FILE`, starting about 12 s after launch. - **`main`** (b7cedd900d; `Spawn.cpp` is the same on 4eb91eacdf): aborts at 7 s, at the first Cross press. ``` terminate called after throwing an instance of 'std::runtime_error' what(): posix_spawnp: process creation not implemented ``` - **This PR, mixed button sequence** (Cross, Down, Cross, Right, Cross, Circle, …): the title logs `File selection failed: File dialog driver unsupported (supported values for SDL_HINT_FILE_DIALOG_DRIVER are 'zenity' and 'portal')` 3 times and stays on its menu. It then exits with code 0 at 16 s, logging `exit status 0: asking the shell to close the title`. - **This PR, Cross only** (a Cross press every 1.2 s for 150 s): the title logs `File selection failed` 79 times and is still running when the 150 s limit stops it. It has no `what()` line and no exit. On the code-0 exit you saw once: the prelaunch menu at the pinned dusklight commit 34a144a49 has Select Disc Image, Settings, Mods and Quit. Quit's handler only sets `IsRunning = false` ([prelaunch.cpp](https://github.com/TwilitRealm/dusklight/blob/34a144a493b7f57adeb4034d382317c826eb5c8d/src/dusk/ui/prelaunch.cpp#L959-L960)). The Cross-only run never leaves Select Disc Image and never exits. So in my runs the code-0 exit comes from the mixed sequence reaching Quit, not from this change. AI-assisted: yes
milescoviello commented 2026-10-15 23:21:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-15T23:21:39Z.


@DavidSamir thanks for the Windows run, and for tracing the code-0 exit to the menu's Quit. That explains my one odd run too. I added your result to the description.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6204333192 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6233#issuecomment-6204333192). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-15T23:21:39Z. --- @DavidSamir thanks for the Windows run, and for tracing the code-0 exit to the menu's Quit. That explains my one odd run too. I added your result to the description. AI-assisted: yes (Claude Code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!6233
No description provided.