fix(libSceNet): print the console's line for a negative sceNetUsleep #10572

Merged
ZSWolt merged 1 commit from upstream-pr/10572 into main 2026-10-25 06:06:10 +00:00
ZSWolt commented 2026-10-24 10:31:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ZSWolt on 2026-10-24T10:31:08Z.


What

After sceNetInit, a negative count to sceNetUsleep now prints [LIBNET] usleep <count> and a newline to standard output before it fails with EINVAL, as the console does. Main already returned EINVAL for a negative count, but printed nothing.

The evidence is the firmware 13.60 payload run from #9076, which recorded this gap in docs/dev/debt/libSceNet.md:

  • In its console log, lines 283–284 are [LIBNET] usleep -1 and [LIBNET] usleep -2147483648.
  • They come from the counts 0xffffffffffffffff and 0xffffffff80000000, so the line prints the signed 32-bit count the call already uses.
  • The probe in the same gist (netutil_main.c) calls sceNetInit before these cases, so the line is printed after the init check. Before sceNetInit nothing is printed, as before; that case is unmeasured and stays in the debt entry.

Tested

  • Windows 11 with WSL2, Ubuntu 26.04.1, GCC 15.2.0, Release, BUILD_TESTING=ON.
  • CheckUsleep in guest_sce_net now captures standard output:
    • sceNetUsleep(0) prints nothing.
    • sceNetUsleep(-1) and sceNetUsleep(INT32_MIN) print exactly "[LIBNET] usleep -1\n[LIBNET] usleep -2147483648\n", and still fail with errno 22.
  • It aborts on main and passes with this change (3 runs).
  • Full ctest: 2028/2029. The one failure, agc_driver_multisample_retirement, also fails on main under WSL, where /dev/udmabuf is missing; it is unrelated to this change.
  • tools/check_conventions.py: all checks passed.
  • No open PR changes sceNetUsleep. The 30 open PRs that touch libSceNet/Export.cpp don't add or remove any line mentioning usleep or LIBNET.

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 (#10628 lands after this one and rebases on it, as its own Depends on line records; #6044 was closed without merging)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4994634089 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10572). Originally posted by [ZSWolt](https://github.com/ZSWolt) on 2026-10-24T10:31:08Z. --- ### What After `sceNetInit`, a negative count to `sceNetUsleep` now prints `[LIBNET] usleep <count>` and a newline to standard output before it fails with `EINVAL`, as the console does. Main already returned `EINVAL` for a negative count, but printed nothing. The evidence is the firmware 13.60 payload run from #9076, which recorded this gap in `docs/dev/debt/libSceNet.md`: - In its [console log](https://gist.github.com/orezraey/789290577123af3c45b340d6db6f395c), lines 283–284 are `[LIBNET] usleep -1` and `[LIBNET] usleep -2147483648`. - They come from the counts `0xffffffffffffffff` and `0xffffffff80000000`, so the line prints the signed 32-bit count the call already uses. - The probe in the same gist (`netutil_main.c`) calls `sceNetInit` before these cases, so the line is printed after the init check. Before `sceNetInit` nothing is printed, as before; that case is unmeasured and stays in the debt entry. ### Tested - Windows 11 with WSL2, Ubuntu 26.04.1, GCC 15.2.0, Release, `BUILD_TESTING=ON`. - `CheckUsleep` in `guest_sce_net` now captures standard output: - `sceNetUsleep(0)` prints nothing. - `sceNetUsleep(-1)` and `sceNetUsleep(INT32_MIN)` print exactly `"[LIBNET] usleep -1\n[LIBNET] usleep -2147483648\n"`, and still fail with errno 22. - It aborts on main and passes with this change (3 runs). - Full `ctest`: 2028/2029. The one failure, `agc_driver_multisample_retirement`, also fails on main under WSL, where `/dev/udmabuf` is missing; it is unrelated to this change. - `tools/check_conventions.py`: all checks passed. - No open PR changes `sceNetUsleep`. The 30 open PRs that touch `libSceNet/Export.cpp` don't add or remove any line mentioning `usleep` or `LIBNET`. ### 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 (#10628 lands after this one and rebases on it, as its own `Depends on` line records; #6044 was closed without merging) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-24 10:34:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T10:34:57Z.

Review: APPROVED


Reviewed the implementation and regression diff. The new diagnostic is emitted only after the existing g_net_inited guard and only for negative signed int inputs; it then preserves the existing EINVAL return path. The test captures stdout and checks zero, -1, and INT32_MIN, including exact signed formatting and errno. The evidence and scope are recorded in the debt entry, including the unmeasured pre-init case. GitHub eligibility, conventions, intake, labels, and report checks pass; platform build jobs were skipped by the eligibility gate. I did not rerun the contributor-reported WSL test suite locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5637942569 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10572#pullrequestreview-5637942569). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T10:34:57Z. **Review:** APPROVED --- Reviewed the implementation and regression diff. The new diagnostic is emitted only after the existing `g_net_inited` guard and only for negative signed `int` inputs; it then preserves the existing `EINVAL` return path. The test captures stdout and checks zero, -1, and INT32_MIN, including exact signed formatting and errno. The evidence and scope are recorded in the debt entry, including the unmeasured pre-init case. GitHub eligibility, conventions, intake, labels, and report checks pass; platform build jobs were skipped by the eligibility gate. I did not rerun the contributor-reported WSL test suite locally.
MarcZX10 commented 2026-10-24 10:43:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T10:43:58Z.

Review: APPROVED


The firmware capture and debt note provide a specific basis for the added negative-count log line, and the implementation preserves the existing initialization check and EINVAL result. The focused test asserts no output for zero, exact signed output for -1 and INT32_MIN, and errno preservation. The PR reports the WSL full-suite result with its unrelated /dev/udmabuf failure identified, plus conventions passing. Hosted eligibility, conventions, intake, labels and report checks pass; the build matrix was skipped by workflow selection. git diff --check on the PR head is clean. I approve.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5637963778 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10572#pullrequestreview-5637963778). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T10:43:58Z. **Review:** APPROVED --- The firmware capture and debt note provide a specific basis for the added negative-count log line, and the implementation preserves the existing initialization check and `EINVAL` result. The focused test asserts no output for zero, exact signed output for `-1` and `INT32_MIN`, and errno preservation. The PR reports the WSL full-suite result with its unrelated `/dev/udmabuf` failure identified, plus conventions passing. Hosted eligibility, conventions, intake, labels and report checks pass; the build matrix was skipped by workflow selection. `git diff --check` on the PR head is clean. I approve.
MarcZX10 commented 2026-10-24 11:27:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T11:27:36Z.

Review: CHANGES_REQUESTED


The negative-count behavior and captured stdout tests remain sound; the previous approvals addressed the code. I manually followed up on the new overlap report. #5836 changes socket type/options, #7201 changes macOS resolver/socket paths, #8234 changes sceNetShowIfconfigWithMemory, #9727 changes resolver/epoll argument validation, #9733 changes macOS send/receive, #10502 changes socket names/netstat, and #7511 changes kernel socket timeout cases; none edits sceNetUsleep or its new CheckUsleep assertions. However, #6044 renames core/libs/tests/GuestSceNet.cpp to core/libs/tests/networking/GuestSceNet.cpp, so this PR’s test edit needs a coordinated order to avoid being left behind during the move. Please agree on the order with #6044’s author and update the dependency/merge coordination information as needed. The author reports its focused/full tests and conventions; hosted platform builds were skipped.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638076215 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10572#pullrequestreview-5638076215). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T11:27:36Z. **Review:** CHANGES_REQUESTED --- The negative-count behavior and captured stdout tests remain sound; the previous approvals addressed the code. I manually followed up on the new overlap report. #5836 changes socket type/options, #7201 changes macOS resolver/socket paths, #8234 changes `sceNetShowIfconfigWithMemory`, #9727 changes resolver/epoll argument validation, #9733 changes macOS send/receive, #10502 changes socket names/netstat, and #7511 changes kernel socket timeout cases; none edits `sceNetUsleep` or its new `CheckUsleep` assertions. However, #6044 renames `core/libs/tests/GuestSceNet.cpp` to `core/libs/tests/networking/GuestSceNet.cpp`, so this PR’s test edit needs a coordinated order to avoid being left behind during the move. Please agree on the order with #6044’s author and update the dependency/merge coordination information as needed. The author reports its focused/full tests and conventions; hosted platform builds were skipped.
MarcZX10 commented 2026-10-24 14:01:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T14:01:47Z.

Review: CHANGES_REQUESTED


Follow-up on exact head 412c3cd91f3aa7563417fc512813527cb3535646: the prior #6044 blocker is cleared because #6044 is closed without merging and this PR now records Depends on: none.

A new overlap with open #10628 needs coordination before merge. I confirmed with git merge-tree that the current heads conflict in docs/dev/debt/libSceNet.md; the source changes are separate, but the two debt entries need to be retained together. Please agree with #10628's author which PR lands first and how the second will rebase, then record the dependency/order in the checklist as required by CONTRIBUTING. The existing code review and tests remain applicable; hosted checks are green for this PR, with product builds skipped by eligibility.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638515116 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10572#pullrequestreview-5638515116). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T14:01:47Z. **Review:** CHANGES_REQUESTED --- Follow-up on exact head `412c3cd91f3aa7563417fc512813527cb3535646`: the prior #6044 blocker is cleared because #6044 is closed without merging and this PR now records `Depends on: none`. A new overlap with open #10628 needs coordination before merge. I confirmed with `git merge-tree` that the current heads conflict in `docs/dev/debt/libSceNet.md`; the source changes are separate, but the two debt entries need to be retained together. Please agree with #10628's author which PR lands first and how the second will rebase, then record the dependency/order in the checklist as required by CONTRIBUTING. The existing code review and tests remain applicable; hosted checks are green for this PR, with product builds skipped by eligibility.
MarcZX10 commented 2026-10-24 14:12:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T14:12:40Z.

Review: APPROVED


Follow-up on exact head 412c3cd91f3aa7563417fc512813527cb3535646. The overlap with #10628 is now explicitly ordered: #10572 lands first and #10628 declares Depends on: #10572 and will rebase to retain both debt entries. #6044 remains closed without merging, so it creates no dependency. My prior review of the implementation and CheckUsleep regression still applies; the author reports the focused checks and WSL full suite, with the unrelated /dev/udmabuf failure identified. Hosted eligibility/conventions/intake/labels/report pass; platform builds were skipped. The PR is ready for maintainer review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638552364 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10572#pullrequestreview-5638552364). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T14:12:40Z. **Review:** APPROVED --- Follow-up on exact head `412c3cd91f3aa7563417fc512813527cb3535646`. The overlap with #10628 is now explicitly ordered: #10572 lands first and #10628 declares `Depends on: #10572` and will rebase to retain both debt entries. #6044 remains closed without merging, so it creates no dependency. My prior review of the implementation and `CheckUsleep` regression still applies; the author reports the focused checks and WSL full suite, with the unrelated `/dev/udmabuf` failure identified. Hosted eligibility/conventions/intake/labels/report pass; platform builds were skipped. The PR is ready for maintainer review.
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!10572
No description provided.