fix(libSceNet): report the registered socket as the epoll event ident #4612

Merged
EagleBearerYS merged 1 commit from upstream-pr/4612 into main 2026-10-13 15:30:06 +00:00
EagleBearerYS commented 2026-10-12 16:45:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-12T16:45:28Z.


What

sceNetEpollWait copied the whole event a title passed to sceNetEpollControl, so ident and reserved came back as the title had left them. The ident of a returned event is the id that was registered, and reserved is 0: shadPS4 net.cpp with guest_net.h (ident // socket id), and KytyPS5 network.cpp. Socket 32, registered with reserved 0x5a5a5a5a:

Registered ident main returns This branch
0 ident 0, reserved 0x5a5a5a5a ident 0x20, reserved 0
0x123456789abcdef0 ident 0x123456789abcdef0, reserved 0x5a5a5a5a ident 0x20, reserved 0

A title that registers a socket without filling ident and looks the socket up by it now finds it. data is returned unchanged, as before.

Tested

Windows 11 (10.0.26300), WinLibs MinGW-w64 GCC 15.2.0 r7 (UCRT), Release, -DBUILD_TESTING=ON, on main at 2a5eca11:

  • With main's Export.cpp, the new CheckEpollIdent in guest_sce_net aborts (exit 0xc0000409); guest_sce_net passes on main itself, IPv6 checks included, so the abort is the new check. With the change it passes, 20 runs in a row.
  • All 128 tests registered in core/libs/prx/libc/CMakeLists.txt and core/libs/prx/libkernel/CMakeLists.txt that build on Windows pass, and so do the network tests (guest_datagram_recv, guest_datagram_recvfrom, guest_datagram_sceNetRecv, guest_datagram_sceNetRecvfrom, guest_udp, guest_resolver, guest_posix_filesystem).

Linux (Ubuntu 24.04, GCC 13.3, Release), base 33ae282e: the new CheckEpollIdent in guest_sce_net aborts on main and passes with the change, 20/20; the libSceNet, libc and libkernel tests are unchanged. Again on WSL2 (Ubuntu 24.04, GCC 13.3.0, Release with CI's configure flags), merged into main at c952c2b0e, IPv6 checks included: it aborts with main's Export.cpp and passes with the change, 20 runs in a row.

tools/check_conventions.py --base origin/main passes.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4832394173 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4612). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-12T16:45:28Z. --- ### What `sceNetEpollWait` copied the whole event a title passed to `sceNetEpollControl`, so `ident` and `reserved` came back as the title had left them. The `ident` of a returned event is the id that was registered, and `reserved` is 0: shadPS4 [net.cpp](https://github.com/shadps4-emu/shadPS4/blob/e0a466753a1aacbc8db8253be685bf7ab4d9daae/src/core/libraries/net/net.cpp#L1236-L1241) with [guest_net.h](https://github.com/shadps4-emu/shadPS4/blob/e0a466753a1aacbc8db8253be685bf7ab4d9daae/src/core/net/guest_net.h#L135-L139) (`ident // socket id`), and KytyPS5 [network.cpp](https://github.com/KytyPS5/KytyPS5/blob/df5b9b92be7dfd463b47756b707d6d356a9f0550/src/libs/network.cpp#L1801-L1803). Socket 32, registered with `reserved` 0x5a5a5a5a: | Registered `ident` | `main` returns | This branch | |---|---|---| | 0 | `ident` 0, `reserved` 0x5a5a5a5a | `ident` 0x20, `reserved` 0 | | 0x123456789abcdef0 | `ident` 0x123456789abcdef0, `reserved` 0x5a5a5a5a | `ident` 0x20, `reserved` 0 | A title that registers a socket without filling `ident` and looks the socket up by it now finds it. `data` is returned unchanged, as before. ### Tested Windows 11 (10.0.26300), WinLibs MinGW-w64 GCC 15.2.0 r7 (UCRT), Release, `-DBUILD_TESTING=ON`, on `main` at 2a5eca11: - With `main`'s `Export.cpp`, the new `CheckEpollIdent` in `guest_sce_net` aborts (exit `0xc0000409`); `guest_sce_net` passes on `main` itself, IPv6 checks included, so the abort is the new check. With the change it passes, 20 runs in a row. - All 128 tests registered in `core/libs/prx/libc/CMakeLists.txt` and `core/libs/prx/libkernel/CMakeLists.txt` that build on Windows pass, and so do the network tests (`guest_datagram_recv`, `guest_datagram_recvfrom`, `guest_datagram_sceNetRecv`, `guest_datagram_sceNetRecvfrom`, `guest_udp`, `guest_resolver`, `guest_posix_filesystem`). Linux (Ubuntu 24.04, GCC 13.3, Release), base 33ae282e: the new `CheckEpollIdent` in `guest_sce_net` aborts on `main` and passes with the change, 20/20; the libSceNet, libc and libkernel tests are unchanged. Again on WSL2 (Ubuntu 24.04, GCC 13.3.0, Release with CI's configure flags), merged into `main` at c952c2b0e, IPv6 checks included: it aborts with `main`'s `Export.cpp` and passes with the change, 20 runs in a row. `tools/check_conventions.py --base origin/main` passes. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
adriadam10 commented 2026-10-13 14:44:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T14:44:58Z.


Checked against shadPS4 and KytyPS5 (both return the registered id as ident and reserved 0; NetEpollEvent layout matches). Built and ran the libSceNet/libc/libkernel tests on the PR merged into main: all pass, and guest_sce_net fails with main's Export.cpp. Merging once the full build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6148197837 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4612#issuecomment-6148197837). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T14:44:58Z. --- Checked against shadPS4 and KytyPS5 (both return the registered id as `ident` and `reserved` 0; `NetEpollEvent` layout matches). Built and ran the libSceNet/libc/libkernel tests on the PR merged into main: all pass, and `guest_sce_net` fails with `main`'s `Export.cpp`. Merging once the full build is green.
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!4612
No description provided.