Repository navigation
feat(libSceHttp2): create WebSocket requests and answer them as a PS5 does before they connect - #11470
Conversation
… does before they connect
Progress report (492ed5c → 71749a8)📈 System libraries: 29.45% (+0.01%, +6 implemented functions) ✅ 6 implemented
Changed libraries (implemented exports)
|
MarcZX10
left a comment
There was a problem hiding this comment.
I reviewed the WebSocket request and pre-connect behavior on exact head 3d7e2d2dcb43d0d1dd4a9a6833ad6a31b36dec2c. I found no concrete implementation defect in the request-handle ownership, URI scheme check, ping range validation, or pre-connect return paths. The PR reports a focused Windows suite repeated three times and a control run that fails only the new WebSocket case before the change. I did not independently run the Windows suite; hosted Linux/Windows product jobs are skipped.
Before approval, please sync this branch to current main (b0f1183ca12b) as required by CONTRIBUTING.md. The current branch is based on bf77a9e9cba4; the intervening commits do not touch the changed HTTP2 implementation/test/debt paths, and the merge-tree preview is clean. Current-main conventions and git diff --check pass.
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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.
|
|
Thanks, the pre-connect errors, argument order/zeroing, scheme parsing and deletion coverage look good. One change, please: remove the new assertion in GuestHttp2.cpp that The branch also conflicts with main now (libSceHttp2 CMake, Export.cpp, GuestHttp2.cpp and the debt file), so it will need a rebase. |
MarcZX10
left a comment
There was a problem hiding this comment.
Re-review — changes requested
Two items remain before this PR is ready.
Findings
[P2] Do not pin a valid, unimplemented handshake to a throw
In GuestHttp2.cpp, the WebSocket request test expects sceHttp2SendRequestAsync(request, nullptr, 0, nullptr, &tag) to throw. This is a valid WebSocket request exercising the unimplemented handshake path. The production limitation and debt entry can remain, but the test should not require an unsupported path to throw. Please remove that assertion, as the reviewer requested, while retaining the supported pre-connect behavior tests.
[P2] Integrate current main and rerun the focused tests
The exact head 7231c2a2d66b95fda621ee713c3f4e661182213f is based on ca6e29e8363e3d10e9e6482bede3d19d6b9f0e6e. Current main is 4c7d275bef89d309313d16bc2bc05d37a1b50be2; the merge preview conflicts in libSceHttp2/CMakeLists.txt, Export.cpp, GuestHttp2.cpp, and docs/dev/debt/libSceHttp2.md. Please integrate current main, resolve those conflicts, and rerun the five focused CTest entries on the updated base and change.
Checks
git diff --check: clean.tools/check_conventions.py: passed against currentmain.- Hosted product Linux/Windows jobs are skipped; the prior author-reported 5/5 runs are on the older
ca6e29emerge.
I did not run a local build or CTest.
…requests # Conflicts: # core/libs/prx/libSceHttp2/CMakeLists.txt # core/libs/prx/libSceHttp2/Export.cpp # core/libs/tests/GuestHttp2.cpp # docs/dev/debt/libSceHttp2.md
|
@MarcZX10 @BunnyFl Thanks. Head da8fbc6 rejects a null Firmware 13.40: I read the same three functions in my own 13.40 Changes:
Windows 11, MinGW GCC 15.2 Release, RTX 4090 box. The 13 ctest entries of the libSceHttp2, libSceHttp and libSceHttpCache test executables (
AI-assisted: yes (Claude Code) |
|
@MarcZX10 @BunnyFl Follow-up: I measured the null checks on my 13.40 PS5 today, inside Gran Turismo 7 (PPSA01317) with the in-game remote-call harness. The console rejects a null Each call ran 3 times against four ids. 0x7777 and -1 are not ids. "Plain" is a non-WebSocket request and "WebSocket" a WebSocket request that never connected. The probe created both requests and deleted them afterwards, and it sent nothing to ids the game owns. 144 calls, all 3/3, no 0x817B1076:
Head da8fbc6 returns the same value for every row. Not measured: whether flags, data size or the async option are checked before 0x817B1065 when the message pointer is valid, since every control used flags 0, size 2 and no async option. That part is still from the disassembly only. AI-assisted: yes (Claude Code) |
|
#14236 appends a sentence to the AI-assisted (Claude Code). |
MarcZX10
left a comment
There was a problem hiding this comment.
Re-checked — new head, changes requested
The null text/data validation was added, but unsupported dataSize, flags, and async-option combinations still return ERROR_NOT_CONNECTED without evidence that firmware validates them that way.
What I ran
Reviewed head 324c6ddfe2e7439334de792f31110652e2f3bd2e against PR base 9f748f4d8e36ce3714f3b95f3386316e110a9b22; the merge preview against current main cf79276fee2f042feb6a7c71d0d6a27e9cfe2592 is clean. Environment: Debian Linux x86-64, Python 3.11.2; no local build or tests.
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 11470
git diff --check 9f748f4d8e36ce3714f3b95f3386316e110a9b22...324c6ddfe2e7439334de792f31110652e2f3bd2eResults
| Check | Result |
|---|---|
| Diff and conventions | Passed. |
| Current-main merge preview | Clean. |
| Hosted checks | Eligibility, conventions, portability, labels, report and Windows passed; Linux and specialized product jobs were skipped. |
| Focused tests | Author reports 13/13 HTTP/HTTP2 tests passing three times on Windows for the preceding code head; this latest head only updates the debt entry. I did not reproduce them locally. |
| Optional ABI/test-quality helpers | The isolated PR snapshot lacks these scripts, so those optional checks could not run. |
Findings
Blocking
Unmeasured validation before the pre-connect result. In sceHttp2WebSocketSendDataMessageAsync, dataSize, flags, and asyncOption are ignored; sceHttp2WebSocketSendTextMessageAsync ignores flags and asyncOption; sceHttp2WebSocketCloseAsync also ignores flags and asyncOption. For a live WebSocket handle, these calls return ERROR_NOT_CONNECTED even for combinations whose firmware validation order is not established in the report. The tests cover null message pointers, option, and selected status/reason cases, but do not pin these remaining inputs. Please add firmware/console evidence and tests for their precedence, or preserve the unverified input cases on the unimplemented/debt path.
Non-blocking
The declared #14236 ordering is documented; no source overlap issue was found on this head.
Sources
- Send and close implementations at the reviewed head
- WebSocket argument tests at the reviewed head
- Author’s firmware evidence for the newly measured null-pointer order
Not verified
I did not independently reproduce the firmware measurements or run a local build/CTest. Linux and specialized hosted jobs were skipped.
To get this to a good state
Establish and test the validation order for dataSize, flags, and async options, or leave those unmeasured combinations unimplemented with debt notes. I’ll rerun the same no-build checks and review the updated head.
|
I tested head
To test, I kept both sides of the test file and took Tests:
One thing for the rebase: after the merge,
Not tested: I have no new console evidence for the open review point (flags, data size and async option before 0x817B1065 with a valid message pointer). AI-assisted: yes (Claude Code) |
|
Hi frankea,
B-Howell's run above, with both sides of the test file kept and One thing to watch when you resolve the debt file: this PR deletes Could you rebase or merge |
✅ AMD GPU test: passedPR head
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (4, not counted against this PR)Validation IDs already present on main (4 IDs in 488 tests)Skipped (9)ReproduceAutomated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
…requests # Conflicts: # core/libs/prx/libSceHttp2/Export.cpp # core/libs/tests/GuestHttp2.cpp
|
@oneandonlydean thanks for merging @MarcZX10 on the flags, data size and async option: I have a probe ready that runs those inputs with a valid message on a WebSocket request that never connected, on 13.40 inside GT7 as before (non-zero flags, an async option, data sizes 0, 1, 0x7fffffff and -1, close with a NULL status and reason and with status 0, 999, 5000 and 0xffff). I'll post the results and adjust the code or the debt entry to them as soon as the console is back up. |
Answered on the live head 71749a8. The debt entry in docs/dev/debt/libSceHttp2.md gives the evidence asked for: read from libSceHttp2.sprx (firmware 13.40), a send does not check its flags, data size or async option before the connection check, and on a PS5 (13.40, inside PPSA01317) text and data sends and sceHttp2WebSocketCloseAsync return 0x817B1065 before the handshake. Export.cpp:453-473 follows that: only option, a null text/data and a reason without a status return INVALID_VALUE, then INVALID_ID or NOT_CONNECTED. Requests never connect, so every path is an error before connect and the open question is only which error code an unusual flag combination gets; that is recorded on the debt path, as the review offered.
What
Onimusha (PPSA27836) imports
sceHttp2WebSocketCreateRequest,sceHttp2WebSocketSetPingInterval,sceHttp2WebSocketSetPingTimeout,sceHttp2WebSocketSendTextMessageAsync,sceHttp2WebSocketSendDataMessageAsyncandsceHttp2WebSocketCloseAsync, and all six threw. They now answer as a PS5 does for a WebSocket request that has not connected, the only state this offline library has:sceHttp2WebSocketCreateRequestchecks its arguments, zeroes the receive buffer, checks the template and the URL, and returns a request id from the same registry assceHttp2CreateRequestWithURL, sosceHttp2DeleteRequestand template deletion handle it. Like that function onmain, the request takes the template's SSL context, capacity, version and settings, with method GET and the URL. The URL goes throughsceHttpUriParse, so libSceHttp2 now links libSceHttp; the scheme must be ws or wss.sceHttp2WebSocketSetPingIntervalandsceHttp2WebSocketSetPingTimeoutcheck their values and drop them (listed under Silent stubs).sceHttp2WebSocketCloseAsyncreturn 0x817B1065 (not connected) for a WebSocket request and 0x817B1100 for any other id. Before the id is looked up, a setoption, a null text or data, and a close reason without a status return 0x817B11FE.sceHttp2SendRequestAsyncthrows for every valid request onmain(its "asynchronous requests" debt entry), WebSocket requests included. On the PS5 the handshake fails offline like any other request, but the library also calls the request's error callback with the request id, from its own thread (measured below); the WebSocket debt entry records that.Measurement: PS5 on firmware 13.40, inside Gran Turismo 7 (PPSA01317), on 2026-10-26. A payload attached to the game with ptrace, created its own libnet pool, SSL context, Http2 context and template, called the game's
libSceHttp2exports, and deleted everything afterwards. Connections went to a closed port on a LAN host and to an unresolvable.invalidname.Second run on 2026-10-30, same console and harness, Gran Turismo 7 01.700.000: the three calls went to ids 0x7777 and -1, a plain request, and a WebSocket request that had not connected (the payload created both requests and deleted them afterwards). Each call ran three times on each id. All 144 calls returned the values below, and none returned the stack check's 0x817b1076.
The callback check used libc
srandas the error callback: after the wait, the game's nextrand()matched the firstrand()aftersrand(request id)and not the one after the seed set before the call.Read from
libSceHttp2.sprx(13.40, decrypted from the game's process; not shared) and not measured: null data and close callbacks are refused like the other two; the template is checked before the URL and a ping value before the request id; the sends do not check their flags, data size or async option before the connection check; the scheme comparison ignores case. The debt entry lists all but the first. The module tests a null text or data in the same branch as theoptioncheck (text0x27e80, data0x281e0, lookup0x4e90), so the order between those two cannot be observed. BunnyFl's read and native run of the 13.42 module found the same null text/data order that the second run measured.Tested
Windows 11 (build 26200), MinGW GCC (WinLibs 15.2) Release build with
BUILD_TESTING=ON, each test run three times (ctest --repeat until-fail:3).main9f748f4 merged, no conflicts): the 13 ctest entries of the libSceHttp2, libSceHttp and libSceHttpCache test executables (ctest -R ^guest_http) pass 13/13, each run three times, and so doesmain9f748f4. Control, this head with the two send functions' old checks:guest_http2aborts on a failedRequire, and the other 12 pass. Control,main9f748f4 with only this PR'sGuestHttp2.cpp:guest_http2aborts withsceHttp2WebSocketCreateRequest not implemented, and the other 12 pass.mainbb04a4f (head c1b635f). The merge takesmain's transport, request fields and asynchronous-request throws. It drops this PR's checks thatsceHttp2SendRequestAsyncthrows on a WebSocket request and completes on a plain one, since that is a valid path that is not implemented.guest_http2_teardown_tests, which buildsExport.cppitself, now links libSceHttp for the URL parse. The 13 ctest entries of the libSceHttp2 and libSceHttp test executables pass 13/13, each run three times, and so doesmainbb04a4f.mainca6e29e (head 7231c2a; no conflicts): the five ctest entries below pass 5/5, and so doesmainca6e29e.guest_http2_testsgains a WebSocket section: every argument check, with the receive buffer untouched or zeroed as on the console; bogus template and null URL; http and empty URLs;ws:/bad, wss and upper-caseWSaccepted; both ping ranges; ids 0, -1, 0x7777, a plain request, the template and the context; the value checked before the id; a null text or data refused before the id, for every one of those ids and for a WebSocket request that has not connected; sends and closes before connecting; deletion directly and through its template. One existing line, which expectedsceHttp2WebSocketSetPingInterval(0, 1000000)to throw, now checks that a plain POST request gets 0x817B1100.guest_http2,guest_http,guest_http_response_header,guest_http_options,guest_memory_pool_stats):mainbf77a9e; the pushed commit differs from it only in the debt text): 5/5.mainbf77a9e with only this PR'sGuestHttp2.cpp:guest_http2fails (sceHttp2WebSocketCreateRequest not implemented), the other four pass.mainbf77a9e: 5/5.tools/check_conventions.py --base origin/mainpasses.Overlap
No open PR implements these six functions. #9598, #10167, #10534, #10536 and #11145, which changed libSceHttp2 next to this branch, are in
mainnow, and this branch merges it.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)