libkernel: Windows anonymous shm_open (SHM_ANON) descriptors are not recognised as shared memory #11372

Closed
opened 2026-10-26 09:33:53 +00:00 by tablefrogpillow · 0 comments
tablefrogpillow commented 2026-10-26 09:33:53 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by tablefrogpillow on 2026-10-26T09:33:53Z.


Split out from #11291 and PR #11296 (review by MarcZX10), to track the Windows case separately.

On Windows, a descriptor returned by anonymous shm_open(SHM_ANON, ...) is not recognised as shared memory, so any code that branches on IsSharedMemoryDescriptor_nid_no_patch treats it as an ordinary host file.

Observed symptom (reported on Windows by wachi35676 and MarcZX10 in #11291 / #11296; I have not run Windows myself): fpathconf/_fpathconf on such a descriptor returns the UFS pathconf constants (_PC_LINK_MAX 32767, _PC_NAME_MAX 255, …) instead of EOPNOTSUPP. A named shm_open("/name", ...) descriptor and a kqueue descriptor both behave correctly on Windows.

Mechanism (current main, core/libs/prx/libkernel/File/src/SharedMemory.cpp):

  • The anonymous shm_open path (shm_open_nid_postfix) calls CreateAnonymousFile() and returns the descriptor without recording it in sharedDescriptorAccess.
  • On Windows, IsHostSharedMemoryDescriptor returns false for any descriptor not present in sharedDescriptorAccess, so the anonymous descriptor is never recognised.
  • On Linux the same descriptor is recognised independently of that map, via the /memfd:anyps5 shm_open link name read from /proc/self/fd, which is why the Linux behaviour is correct.

Possible fix: record anonymous descriptors in sharedDescriptorAccess on Windows (or otherwise identify the %TEMP%\…\anyps5-shm-* object created by CreateAnonymousFile) so recognition matches Linux. This needs a Windows build to verify; I test on Linux.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6037021161 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/11372). Originally posted by [tablefrogpillow](https://github.com/tablefrogpillow) on 2026-10-26T09:33:53Z. --- Split out from #11291 and PR #11296 (review by MarcZX10), to track the Windows case separately. On Windows, a descriptor returned by anonymous `shm_open(SHM_ANON, ...)` is not recognised as shared memory, so any code that branches on `IsSharedMemoryDescriptor_nid_no_patch` treats it as an ordinary host file. **Observed symptom** (reported on Windows by wachi35676 and MarcZX10 in #11291 / #11296; I have not run Windows myself): `fpathconf`/`_fpathconf` on such a descriptor returns the UFS pathconf constants (`_PC_LINK_MAX` 32767, `_PC_NAME_MAX` 255, …) instead of `EOPNOTSUPP`. A *named* `shm_open("/name", ...)` descriptor and a kqueue descriptor both behave correctly on Windows. **Mechanism** (current `main`, `core/libs/prx/libkernel/File/src/SharedMemory.cpp`): - The anonymous `shm_open` path (`shm_open_nid_postfix`) calls `CreateAnonymousFile()` and returns the descriptor without recording it in `sharedDescriptorAccess`. - On Windows, `IsHostSharedMemoryDescriptor` returns `false` for any descriptor not present in `sharedDescriptorAccess`, so the anonymous descriptor is never recognised. - On Linux the same descriptor is recognised independently of that map, via the `/memfd:anyps5 shm_open` link name read from `/proc/self/fd`, which is why the Linux behaviour is correct. **Possible fix:** record anonymous descriptors in `sharedDescriptorAccess` on Windows (or otherwise identify the `%TEMP%\…\anyps5-shm-*` object created by `CreateAnonymousFile`) so recognition matches Linux. This needs a Windows build to verify; I test on Linux. 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#11372
No description provided.