test(http2): guard allocation-free handle teardown #9598

Merged
Ondra97 merged 3 commits from upstream-pr/9598 into main 2026-10-27 14:51:01 +00:00
Ondra97 commented 2026-10-22 03:58:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-22T03:58:53Z.


What

Keep regression coverage for allocation-free HTTP2 handle teardown on the current transport backend. Main's synchronous transport implementation already replaced the temporary-vector cleanup and removed the old offline completion queue, so this rebased PR changes only the test and its CMake registration. Production Export.cpp is byte-identical to the base.

The fixture calls the canonical public header and compiles the current production Export.cpp and Cookies.cpp with the real transport dependency, allowing its replacement C++ allocator to observe teardown allocations. It checks request, template and context deletion under budgets 0–15: descendants disappear, neighboring templates and independent contexts survive, cookie boxes retain their separate ownership, and deletion makes no allocation attempt. The one-shot fault disarms before throwing so exception unwinding can allocate.

The 192 concurrent cases now race child creation against deletion and check that no created handle escapes its parent's teardown. The removed async completion model is not restored. The new fixture covers unsent handles; existing HTTP2 transport fixtures remain registered and are included in the validation selection.

Tested

Base ea048ce2c35e1fb65ea3331ed73bba35cb27e584; tested head 7a0dfeb79c3d440738cf87762eafe07c96ceb1cf. Windows 11 Pro 10.0.26300, Ryzen 9 7900X, 31.7 GiB RAM, RTX 4070 Ti SUPER; WinLibs MinGW-w64 GCC 15.2.0 r7 UCRT, CMake 4.3.1, Ninja 1.13.2, Release, BUILD_TESTING=ON, pinned bundled dependencies. CPU and local socket fixtures.

  • Built libs, patched_libraries_tests, guest_http2_tests, guest_http2_cookie_tests, guest_http2_transport_tests, guest_http2_teardown_tests, guest_http_tests, guest_http_response_header_tests, guest_http_options_tests, guest_ssl_tests, guest_ssl_load_tests, guest_ssl_transport_tests, guest_ssl_ps5_readers_tests and guest_sce_net_tests with cmake --build <build> --target <targets> --parallel 8.
  • ctest --test-dir <build> -R '^(guest_http2.*|guest_http(_response_header|_options)?|guest_ssl(_load|_transport_kernel|_transport_net|_ps5_readers)?|guest_sce_net|patched_libraries)$' -V --output-on-failure --no-tests=error --repeat until-fail:3: 16/16 passed in all three repetitions, zero skips, 19.56 s total, outside the sandbox so the local socket fixtures can run. Each library-load check loaded 368 patched libraries, zero failures.
  • Each teardown run completed 48 allocation-pressure lifecycles and 192 concurrent lifecycles with zero failures.
  • Mutation control: temporarily restored vector-based descendant collection in the current production helper, preserving transport shutdown. The same registered teardown test rejected it with 32 failing allocation-pressure cases and exit 1. I restored Export.cpp byte-for-byte, rebuilt, and reran the complete green selection. This is a deliberate mutation, not a claim that current main still contains the original bug.
  • ctest --test-dir <build> -R '^public_headers($|_compile_)' -j 4 --output-on-failure --no-tests=error: 65/65 passed, zero skips.
  • Conventions, strict main-sync, whitespace and registration checks pass. The registration audit counts 1,448 test executables, with none unregistered; the executed selection is the 16 tests above.
  • tools/pr_overlap.py completed. Its #9598 entries refer to this existing PR under its old branch head. #6044 is closed. The remaining uncomparable #11470 CMake edit adds libSceHttp to the production library's link dependencies, separately from this PR's new test target; I inspected that edit manually.

No full CTest suite, title or console run is claimed. Earlier offline-completion measurements and Linux reports apply to the old implementation and are not evidence for this rewritten fixture.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4961877540 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9598). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-22T03:58:53Z. --- ### What Keep regression coverage for allocation-free HTTP2 handle teardown on the current transport backend. Main's synchronous transport implementation already replaced the temporary-vector cleanup and removed the old offline completion queue, so this rebased PR changes only the test and its CMake registration. Production `Export.cpp` is byte-identical to the base. The fixture calls the canonical public header and compiles the current production `Export.cpp` and `Cookies.cpp` with the real transport dependency, allowing its replacement C++ allocator to observe teardown allocations. It checks request, template and context deletion under budgets 0–15: descendants disappear, neighboring templates and independent contexts survive, cookie boxes retain their separate ownership, and deletion makes no allocation attempt. The one-shot fault disarms before throwing so exception unwinding can allocate. The 192 concurrent cases now race child creation against deletion and check that no created handle escapes its parent's teardown. The removed async completion model is not restored. The new fixture covers unsent handles; existing HTTP2 transport fixtures remain registered and are included in the validation selection. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Base `ea048ce2c35e1fb65ea3331ed73bba35cb27e584`; tested head `7a0dfeb79c3d440738cf87762eafe07c96ceb1cf`. Windows 11 Pro 10.0.26300, Ryzen 9 7900X, 31.7 GiB RAM, RTX 4070 Ti SUPER; WinLibs MinGW-w64 GCC 15.2.0 r7 UCRT, CMake 4.3.1, Ninja 1.13.2, Release, `BUILD_TESTING=ON`, pinned bundled dependencies. CPU and local socket fixtures. - Built `libs`, `patched_libraries_tests`, `guest_http2_tests`, `guest_http2_cookie_tests`, `guest_http2_transport_tests`, `guest_http2_teardown_tests`, `guest_http_tests`, `guest_http_response_header_tests`, `guest_http_options_tests`, `guest_ssl_tests`, `guest_ssl_load_tests`, `guest_ssl_transport_tests`, `guest_ssl_ps5_readers_tests` and `guest_sce_net_tests` with `cmake --build <build> --target <targets> --parallel 8`. - `ctest --test-dir <build> -R '^(guest_http2.*|guest_http(_response_header|_options)?|guest_ssl(_load|_transport_kernel|_transport_net|_ps5_readers)?|guest_sce_net|patched_libraries)$' -V --output-on-failure --no-tests=error --repeat until-fail:3`: **16/16 passed in all three repetitions, zero skips**, 19.56 s total, outside the sandbox so the local socket fixtures can run. Each library-load check loaded 368 patched libraries, zero failures. - Each teardown run completed **48 allocation-pressure lifecycles and 192 concurrent lifecycles with zero failures**. - Mutation control: temporarily restored vector-based descendant collection in the current production helper, preserving transport shutdown. The same registered teardown test rejected it with **32 failing allocation-pressure cases** and exit 1. I restored `Export.cpp` byte-for-byte, rebuilt, and reran the complete green selection. This is a deliberate mutation, not a claim that current main still contains the original bug. - `ctest --test-dir <build> -R '^public_headers($|_compile_)' -j 4 --output-on-failure --no-tests=error`: **65/65 passed**, zero skips. - Conventions, strict main-sync, whitespace and registration checks pass. The registration audit counts 1,448 test executables, with none unregistered; the executed selection is the 16 tests above. - `tools/pr_overlap.py` completed. Its #9598 entries refer to this existing PR under its old branch head. #6044 is closed. The remaining uncomparable #11470 CMake edit adds `libSceHttp` to the production library's link dependencies, separately from this PR's new test target; I inspected that edit manually. No full CTest suite, title or console run is claimed. Earlier offline-completion measurements and Linux reports apply to the old implementation and are not evidence for this rewritten fixture. ### 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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes
MarcZX10 commented 2026-10-22 04:07:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:07:06Z.

Review: APPROVED


The teardown now erases descendants and queued completions while holding the existing handle-then-completion lock order, without allocating temporary vectors. I checked that submission uses the same lock order and WaitAsync takes only the completion lock; the new fault-injection and submission/deletion tests cover the main ownership paths. The PR report is unusually clear about synthetic scope, actual executed counts, the temporary #8310 build overlay, and unverified console/event behavior. The intervening commits since tested base d9c99c9 are documentation-only, so they do not affect this implementation or the reported focused tests. Hosted conventions, eligibility, intake, labels and report checks pass; hosted product/relinker jobs are skipped. The Windows build/tests are author-reported, with an independent test comment also present. I did not run tests locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5609136485 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9598#pullrequestreview-5609136485). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T04:07:06Z. **Review:** APPROVED --- The teardown now erases descendants and queued completions while holding the existing handle-then-completion lock order, without allocating temporary vectors. I checked that submission uses the same lock order and `WaitAsync` takes only the completion lock; the new fault-injection and submission/deletion tests cover the main ownership paths. The PR report is unusually clear about synthetic scope, actual executed counts, the temporary #8310 build overlay, and unverified console/event behavior. The intervening commits since tested base `d9c99c9` are documentation-only, so they do not affect this implementation or the reported focused tests. Hosted conventions, eligibility, intake, labels and report checks pass; hosted product/relinker jobs are skipped. The Windows build/tests are author-reported, with an independent test comment also present. I did not run tests locally.
jotitadev commented 2026-10-22 04:42:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T04:42:18Z.

Review: COMMENTED


Linux run, since the description lists only Windows 11. The fix passes, but on Linux the test cannot show its red: with the base Export.cpp it hangs until the 30 s ctest timeout instead of printing the failure counts.

Machine: Linux x86_64, i7-8700, Ubuntu 26.04 (kernel 7.0.0-38), GCC 15.2, Release, BUILD_TESTING=ON. Head fdd048978 merged --no-commit onto main ab347d144 (clean).

  • With the PR: guest_http2_teardown and guest_http2 pass, 3 of 3 runs.

  • Base Export.cpp plus this test: guest_http2_teardown is ***Timeout 30.04 sec, with no output. The process is single-threaded and parked in a futex. Backtrace (gdb, first lifecycle, DeleteRequest at budget 0):

    #1  pthread_mutex_lock
    #2  LibcUnwind::FindFrameFast(LibcUnwind::Lookup&)      libc.prx
    ...
    #6  _Unwind_RaiseException_nid_postfix                  libc.prx
    #7  __cxa_throw_nid_postfix                             libc.prx
    #8  operator new(unsigned long) [clone .cold]           test
    #9  LibcUnwind::FindFrameFast(LibcUnwind::Lookup&)      libc.prx
    ...
    #14 __cxa_throw_nid_postfix                             libc.prx
    #15 operator new(unsigned long) [clone .cold]           test
    #16 sceHttp2DeleteRequest
    #17 main
    

    On this build the test executable's throw goes through libc.prx's unwinder. FindFrameFast allocates while it holds its lock, the replaced operator new is still at budget 0 and throws again, and the nested throw blocks on the same lock. So any regression that allocates in teardown shows up on Linux as a timeout, not as the threw=… ownership=… lines.

  • Disarming the budget before the throw fixes that here:

    if (allocationBudget == 0) {
        allocationBudget = -1;
        throw std::bad_alloc();
    }
    

    With that change, base Export.cpp prints 48 failures (23 with threw=1), which matches the 23 bad_alloc in your table. With the PR it prints 0 failures (3 of 3 runs). The PR's own result doesn't change, because the fixed teardown never allocates under the budget.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5609350901 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9598#pullrequestreview-5609350901). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-22T04:42:18Z. **Review:** COMMENTED --- Linux run, since the description lists only Windows 11. The fix passes, but on Linux the test cannot show its red: with the base `Export.cpp` it hangs until the 30 s ctest timeout instead of printing the failure counts. Machine: Linux x86_64, i7-8700, Ubuntu 26.04 (kernel 7.0.0-38), GCC 15.2, Release, `BUILD_TESTING=ON`. Head `fdd048978` merged `--no-commit` onto `main` `ab347d144` (clean). - With the PR: `guest_http2_teardown` and `guest_http2` pass, 3 of 3 runs. - Base `Export.cpp` plus this test: `guest_http2_teardown` is `***Timeout 30.04 sec`, with no output. The process is single-threaded and parked in a futex. Backtrace (gdb, first lifecycle, `DeleteRequest` at budget 0): ```text #1 pthread_mutex_lock #2 LibcUnwind::FindFrameFast(LibcUnwind::Lookup&) libc.prx ... #6 _Unwind_RaiseException_nid_postfix libc.prx #7 __cxa_throw_nid_postfix libc.prx #8 operator new(unsigned long) [clone .cold] test #9 LibcUnwind::FindFrameFast(LibcUnwind::Lookup&) libc.prx ... #14 __cxa_throw_nid_postfix libc.prx #15 operator new(unsigned long) [clone .cold] test #16 sceHttp2DeleteRequest #17 main ``` On this build the test executable's throw goes through `libc.prx`'s unwinder. `FindFrameFast` allocates while it holds its lock, the replaced `operator new` is still at budget 0 and throws again, and the nested throw blocks on the same lock. So any regression that allocates in teardown shows up on Linux as a timeout, not as the `threw=… ownership=…` lines. - Disarming the budget before the throw fixes that here: ```cpp if (allocationBudget == 0) { allocationBudget = -1; throw std::bad_alloc(); } ``` With that change, base `Export.cpp` prints `48 failures` (23 with `threw=1`), which matches the 23 `bad_alloc` in your table. With the PR it prints `0 failures` (3 of 3 runs). The PR's own result doesn't change, because the fixed teardown never allocates under the budget. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
jotitadev commented 2026-10-22 07:09:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T07:09:16Z.

Review: COMMENTED


Re-ran on Linux after 99d261595 (budget disarmed before the throw).

Machine: Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release. Head 58e6b6b56 merged --no-commit onto main d6eafa54d (clean).

  • With the PR: guest_http2_teardown prints 48 allocation-pressure lifecycles, 192 concurrent lifecycles, 0 failures, 3 of 3 runs. guest_http, guest_http2, guest_http_options and guest_http_response_header also pass.
  • Base Export.cpp plus this test: no more timeout. It exits 1 in 0.02 s with 48 failures, 23 of them threw=1, which matches the Windows table.

So the red is now visible on Linux as well.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5610449833 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9598#pullrequestreview-5610449833). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-22T07:09:16Z. **Review:** COMMENTED --- Re-ran on Linux after `99d261595` (budget disarmed before the throw). Machine: Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release. Head `58e6b6b56` merged `--no-commit` onto `main` `d6eafa54d` (clean). - With the PR: `guest_http2_teardown` prints `48 allocation-pressure lifecycles, 192 concurrent lifecycles, 0 failures`, 3 of 3 runs. `guest_http`, `guest_http2`, `guest_http_options` and `guest_http_response_header` also pass. - Base `Export.cpp` plus this test: no more timeout. It exits 1 in 0.02 s with `48 failures`, 23 of them `threw=1`, which matches the Windows table. So the red is now visible on Linux as well. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
MarcZX10 commented 2026-10-22 09:31:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T09:31:47Z.


Rechecked the current head after the independent Linux follow-up: the approval still stands, and exact-head conventions plus whitespace checks pass. The Linux reviewer now reports 3/3 green runs and a visible 48-failure base control after the injector disarms before throwing. #6044 changes the broad CMake test naming/registration scheme but does not touch the HTTP2 implementation; please resolve/rebase the test-registration overlap and rerun registration/build checks after its merge if needed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6337505488 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9598#issuecomment-6337505488). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T09:31:47Z. --- Rechecked the current head after the independent Linux follow-up: the approval still stands, and exact-head conventions plus whitespace checks pass. The Linux reviewer now reports 3/3 green runs and a visible 48-failure base control after the injector disarms before throwing. #6044 changes the broad CMake test naming/registration scheme but does not touch the HTTP2 implementation; please resolve/rebase the test-registration overlap and rerun registration/build checks after its merge if needed.
MarcZX10 commented 2026-10-22 13:21:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T13:21:47Z.

Review: DISMISSED


The failure-atomic teardown fix still has strong Windows evidence and an independent Linux red/green run after the allocator injector was made unwinding-safe. Exact head 58e6b6b5653d888955b39924beaf17f1f1a4dc0f passes current-main whitespace and conventions checks; the current-main merge tree is clean. I also syntax-compiled Export.cpp and Http2TeardownFailure.cpp with GCC 12.2 (suppressing existing unused-parameter/missing-field warnings in Export.cpp). I did not run the runtime tests locally.

The branch is based on b27924d851696cafcb83152515f1c84d8804e1f3, behind current main 3ca07d086d5f44fbe3c00370e7f03953ab46ca1b. Please update to current main and refresh focused tests, conventions, and registration checks. #6044 remains open and its test reorganization overlaps the broad CMake changes; the direct merge reports no conflict in this PR's libSceHttp2/CMakeLists.txt, but please preserve the guest_http2_teardown registration and rerun its build/registration checks after either branch is rebased. This request is only for the current-main and test-registration update; the code approval stands and the obsolete intake hold is withdrawn.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5614883378 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9598#pullrequestreview-5614883378). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T13:21:47Z. **Review:** DISMISSED --- The failure-atomic teardown fix still has strong Windows evidence and an independent Linux red/green run after the allocator injector was made unwinding-safe. Exact head `58e6b6b5653d888955b39924beaf17f1f1a4dc0f` passes current-main whitespace and conventions checks; the current-main merge tree is clean. I also syntax-compiled `Export.cpp` and `Http2TeardownFailure.cpp` with GCC 12.2 (suppressing existing unused-parameter/missing-field warnings in `Export.cpp`). I did not run the runtime tests locally. The branch is based on `b27924d851696cafcb83152515f1c84d8804e1f3`, behind current main `3ca07d086d5f44fbe3c00370e7f03953ab46ca1b`. Please update to current main and refresh focused tests, conventions, and registration checks. #6044 remains open and its test reorganization overlaps the broad CMake changes; the direct merge reports no conflict in this PR's `libSceHttp2/CMakeLists.txt`, but please preserve the `guest_http2_teardown` registration and rerun its build/registration checks after either branch is rebased. This request is only for the current-main and test-registration update; the code approval stands and the obsolete intake hold is withdrawn.
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!9598
No description provided.