feat(libSceLibreSsl3): release BIO references through BIO_vfree #15599

Closed
MarrasFederico wants to merge 1 commit from upstream-pr/15599 into main
MarrasFederico commented 2026-11-03 21:04:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarrasFederico on 2026-11-03T21:04:48Z.


What

BIO_vfree previously threw unconditionally. LibreSSL 4.0.0 bio_lib.c defines it as a void wrapper around BIO_free.

The export now delegates once to the existing parent BIO_free, discarding its return value. Null is a no-op, retained references are decremented, and final release follows the parent's callback/destructor and allocation rules. Its dedicated source file retains the original notices.

  • This uses the 104-byte BIO representation already created by the parent's BIO_new/memory BIO APIs and forwarded into this library. No second BIO layout or lifetime table is introduced.
  • Callback veto and chained ownership retain the existing parent's behavior. Console ABI, layout and parent limitations remain unmeasured and are recorded in the library debt.
  • The callable-placeholder count drops from 76 to 75, excluding this now-known signature. Other placeholders remain.

Neither path was measured on a console.

Tested

Ubuntu 26.04.1, kernel 7.0.0-42-generic, GCC 15, Release, BUILD_TESTING=ON, on main 086c0686c8, then again after merging main 4741457fed. Windows and macOS were not compiled here. No title was run.

  • Rebuilt guest_libressl3_bio_lifetime_tests after every source change. It covers null, a memory BIO, retained references, callback veto, a custom destructor and chained ownership with recording guest allocators. It checks actual releases, callback/destructor counts and errno preservation.
  • Main's unconditional implementation body with the new declaration/test aborts (CTest exit 8). The fix passes (exit 0). Removing the delegated free fails ownership assertions (exit 8); delegating only for the final reference fails reference-count assertions (exit 8). The restored implementation passes.
  • Complete LibreSSL3, relevant parent BIO and public-header suite: 79/79 pass. All required test targets were built with -j6. check_conventions.py --base origin/main and git diff --check pass.
  • After merging main 4741457fed: all 14 LibreSSL3 tests pass, including guest_libressl3_bio_lifetime. The only conflict was the pending-export count in the debt file, now 67 with BIO_vfree excluded.
  • pr_overlap.py examined 1777 open PRs. Reported shared debt-count/insertion hunks require reconciliation with other library PRs; none implements BIO_vfree. In particular, #12945 adds BIO_up_ref and uses a separate 112-byte model. This wrapper uses the current parent's 104-byte BIO; future retain/release interoperability between those models needs reconciliation before combining them.

I inspected every not-compared branch diff and confirmed that its BIO_vfree remains the unconditional placeholder. Their shared-file changes concern:

  • #10461: ASN1_OBJECT_free ownership.
  • #10631: OBJ_cmp comparison.
  • #11146: EC private-key support and retain/lifetime debt.
  • #12754: SSL/X509 retains, protocol bounds and random/version accessors.
  • #12928: BIO adapters in the parent; shared child changes concern error-loader/queue forwarding.
  • #13486: broader platform changes; shared child changes concern stack registration and export inventory.
  • #14212: debt spacing and count removal.
  • #14483: SSL_CIPHER_get_id.
  • #14499: EVP_PKEY_get0_EC_KEY.
  • #14612: AES_unwrap_key.

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:5144494297 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15599). Originally posted by [MarrasFederico](https://github.com/MarrasFederico) on 2026-11-03T21:04:48Z. --- ### What `BIO_vfree` previously threw unconditionally. [LibreSSL 4.0.0 bio_lib.c](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/bio/bio_lib.c#L192-L196) defines it as a void wrapper around `BIO_free`. The export now delegates once to the existing parent `BIO_free`, discarding its return value. Null is a no-op, retained references are decremented, and final release follows the parent's callback/destructor and allocation rules. Its dedicated source file retains the original notices. - This uses the 104-byte BIO representation already created by the parent's `BIO_new`/memory BIO APIs and forwarded into this library. No second BIO layout or lifetime table is introduced. - Callback veto and chained ownership retain the existing parent's behavior. Console ABI, layout and parent limitations remain unmeasured and are recorded in the library debt. - The callable-placeholder count drops from 76 to 75, excluding this now-known signature. Other placeholders remain. Neither path was measured on a console. ### 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. --> Ubuntu 26.04.1, kernel 7.0.0-42-generic, GCC 15, Release, `BUILD_TESTING=ON`, on main `086c0686c8`, then again after merging main `4741457fed`. Windows and macOS were not compiled here. No title was run. - Rebuilt `guest_libressl3_bio_lifetime_tests` after every source change. It covers null, a memory BIO, retained references, callback veto, a custom destructor and chained ownership with recording guest allocators. It checks actual releases, callback/destructor counts and errno preservation. - Main's unconditional implementation body with the new declaration/test aborts (CTest exit 8). The fix passes (exit 0). Removing the delegated free fails ownership assertions (exit 8); delegating only for the final reference fails reference-count assertions (exit 8). The restored implementation passes. - Complete LibreSSL3, relevant parent BIO and public-header suite: 79/79 pass. All required test targets were built with `-j6`. `check_conventions.py --base origin/main` and `git diff --check` pass. - After merging main `4741457fed`: all 14 LibreSSL3 tests pass, including `guest_libressl3_bio_lifetime`. The only conflict was the pending-export count in the debt file, now 67 with `BIO_vfree` excluded. - `pr_overlap.py` examined 1777 open PRs. Reported shared debt-count/insertion hunks require reconciliation with other library PRs; none implements `BIO_vfree`. In particular, [#12945](https://github.com/boykopovar/AnyPS5/pull/12945) adds `BIO_up_ref` and uses a separate 112-byte model. This wrapper uses the current parent's 104-byte BIO; future retain/release interoperability between those models needs reconciliation before combining them. I inspected every not-compared branch diff and confirmed that its `BIO_vfree` remains the unconditional placeholder. Their shared-file changes concern: - [#10461](https://github.com/boykopovar/AnyPS5/pull/10461): ASN1_OBJECT_free ownership. - [#10631](https://github.com/boykopovar/AnyPS5/pull/10631): OBJ_cmp comparison. - [#11146](https://github.com/boykopovar/AnyPS5/pull/11146): EC private-key support and retain/lifetime debt. - [#12754](https://github.com/boykopovar/AnyPS5/pull/12754): SSL/X509 retains, protocol bounds and random/version accessors. - [#12928](https://github.com/boykopovar/AnyPS5/pull/12928): BIO adapters in the parent; shared child changes concern error-loader/queue forwarding. - [#13486](https://github.com/boykopovar/AnyPS5/pull/13486): broader platform changes; shared child changes concern stack registration and export inventory. - [#14212](https://github.com/boykopovar/AnyPS5/pull/14212): debt spacing and count removal. - [#14483](https://github.com/boykopovar/AnyPS5/pull/14483): SSL_CIPHER_get_id. - [#14499](https://github.com/boykopovar/AnyPS5/pull/14499): EVP_PKEY_get0_EC_KEY. - [#14612](https://github.com/boykopovar/AnyPS5/pull/14612): AES_unwrap_key. ### 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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->

Pull request closed

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!15599
No description provided.