macOS: guest paths near PATH_MAX fail with ENAMETOOLONG because the host path adds the emulator root #22270

Open
opened 2026-11-17 10:50:57 +00:00 by Jazeupoi · 0 comments
Jazeupoi commented 2026-11-17 10:50:57 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Jazeupoi on 2026-11-17T10:50:57Z.


What happens

On macOS, guest_kernel_sys and guest_kernel_sys_execve fail on guest paths near the 1024-byte guest PATH_MAX (Kernel sys check failed at line 1323 (guest errno 63) and execve with a 1023 byte pathname did not reach the lookup), because the host path built from them exceeds macOS's own 1024-byte PATH_MAX.

Title, test or build step

guest_kernel_sys, guest_kernel_sys_execve

AnyPS5 commit

main e798a424c7 with #17425 and #11049 merged (needed for the macOS build).

System

macOS 27.0.1, Apple M4 (GPU not used by these tests), Apple clang 21.0.0 (SDK 27.2), x86-64 Release build under Rosetta 2.

Steps to reproduce

ctest -R '^guest_kernel_sys$' --output-on-failure
ctest -R '^guest_kernel_sys_execve$' --output-on-failure

Both fail within a few seconds.

Log

Kernel sys check failed at line 1323 (guest errno 63)
kernel sys execve: execve with a 1023 byte pathname did not reach the lookup

What was checked

  • Same result every run on this Mac. In a run of all non-AGC tests, these are the only two path-length failures.
  • guest_kernel_sys fails in CheckRawGetcwdPathLimit: mkdirat of the leaf that makes the working directory 1023 bytes long fails with ENAMETOOLONG. guest_kernel_sys_execve expects ENOENT from the lookup of a 1023-byte relative path. I haven't traced that one, but it's most likely the same cause.
  • Cause: the guest path is within the limit, but the libc hands the host an absolute path, the emulator root joined with the guest path (Resolve/state.root in General.cpp, GetDirectoryDescriptorPath_nid_no_patch in mkdirat). macOS rejects host paths of 1024 bytes or more with ENAMETOOLONG (Linux allows 4096), so a guest path longer than about 1024 minus the root's length fails before the lookup. The Linux CI doesn't hit it, and the getcwd limit test is skipped on Windows.
  • No open PR or issue covers this. #16414 and #16370 added the getcwd limit checks; #21984 (kenv name bound) touches guest_kernel_sys but not this check.
  • A fix probably means not handing macOS absolute native paths longer than PATH_MAX. For example, walk long paths with openat and a directory descriptor, then use the *at call on the last component. That touches every path entry point (mkdir, open, stat, chdir, unlink, rename, ...), so I'm reporting it first rather than opening a large PR.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6442888834 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/22270). Originally posted by [Jazeupoi](https://github.com/Jazeupoi) on 2026-11-17T10:50:57Z. --- ### What happens On macOS, `guest_kernel_sys` and `guest_kernel_sys_execve` fail on guest paths near the 1024-byte guest `PATH_MAX` (`Kernel sys check failed at line 1323 (guest errno 63)` and `execve with a 1023 byte pathname did not reach the lookup`), because the host path built from them exceeds macOS's own 1024-byte `PATH_MAX`. ### Title, test or build step `guest_kernel_sys`, `guest_kernel_sys_execve` ### AnyPS5 commit `main` `e798a424c7` with #17425 and #11049 merged (needed for the macOS build). ### System macOS 27.0.1, Apple M4 (GPU not used by these tests), Apple clang 21.0.0 (SDK 27.2), x86-64 Release build under Rosetta 2. ### Steps to reproduce ``` ctest -R '^guest_kernel_sys$' --output-on-failure ctest -R '^guest_kernel_sys_execve$' --output-on-failure ``` Both fail within a few seconds. ### Log ``` Kernel sys check failed at line 1323 (guest errno 63) kernel sys execve: execve with a 1023 byte pathname did not reach the lookup ``` ### What was checked - Same result every run on this Mac. In a run of all non-AGC tests, these are the only two path-length failures. - `guest_kernel_sys` fails in `CheckRawGetcwdPathLimit`: `mkdirat` of the leaf that makes the working directory 1023 bytes long fails with `ENAMETOOLONG`. `guest_kernel_sys_execve` expects `ENOENT` from the lookup of a 1023-byte relative path. I haven't traced that one, but it's most likely the same cause. - Cause: the guest path is within the limit, but the libc hands the host an absolute path, the emulator root joined with the guest path (`Resolve`/`state.root` in `General.cpp`, `GetDirectoryDescriptorPath_nid_no_patch` in `mkdirat`). macOS rejects host paths of 1024 bytes or more with `ENAMETOOLONG` (Linux allows 4096), so a guest path longer than about 1024 minus the root's length fails before the lookup. The Linux CI doesn't hit it, and the getcwd limit test is skipped on Windows. - No open PR or issue covers this. #16414 and #16370 added the getcwd limit checks; #21984 (kenv name bound) touches `guest_kernel_sys` but not this check. - A fix probably means not handing macOS absolute native paths longer than `PATH_MAX`. For example, walk long paths with `openat` and a directory descriptor, then use the `*at` call on the last component. That touches every path entry point (`mkdir`, `open`, `stat`, `chdir`, `unlink`, `rename`, ...), so I'm reporting it first rather than opening a large PR. AI-assisted: yes (Claude Code)
Sign in to join this conversation.
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#22270
No description provided.