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

Closed
MarrasFederico wants to merge 20 commits from upstream-pr/16654 into main
MarrasFederico commented 2026-11-07 13:24:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarrasFederico on 2026-11-07T13:24:42Z.


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. The dedicated source file retains the original notices.

  • It uses the parent's 104-byte BIO representation already created by the forwarded BIO_new and memory-BIO APIs. No second layout or lifetime table is introduced.
  • Callback veto and chained ownership retain the parent's behavior. Parent-library limitations and the unmeasured console ABI/layout remain recorded in the debt; this wrapper does not establish interoperability with the separate native BIO representation.
  • At head 183a7b6df3bb5495c75431121fb38d22646572c0, Export.cpp contains 6 remaining throwing placeholders. The debt fragment records the same count and excludes both BIO_vfree and PEM_read_RSAPrivateKey.

Supersedes #15599, which GitHub closed when the head fork was deleted. Earlier review comments and Windows test results remain there.

Tested

November 21 update: head 2cb308ae7c merges main at 9950ae309c. The inventory conflict in docs/dev/debt/changes/libressl3-20171-inventory.md was resolved by keeping both exclusions: BIO_vfree from this PR and d2i_PKCS7 from main, which leaves 5 pending exports. Linux: all 199 LibreSSL/LibreSSL3 tests passed, guest_libressl3_bio_lifetime passed three runs, and conventions passed. Windows was not rerun at this head.

Maintenance verification, November 16, 2026: 77b0c858391dc2b065b7614c9ec612c3bdc00d27 merges main 48d3ccecace42059931318e307617fa832fb83cf into cb8348822430e3fba282b05e7637350e7fa3a1a0 through a normal merge (--no-ff) with zero conflicts and an unchanged 7-file PR delta (+304/-6). No published history was rewritten.

  • Merging main 48d3ccecace4 brings in cc1c20e0dd181ac5410d99b28fe833cc323198c8 (revert #21244), which restores bytewise capacity truncation in core/libs/prx/libc/src/WideConversion.cpp and resolves the inherited hosted Windows guest_multibyte_locale (wcstombs fills the capacity mid-character) failure from baseline e4caa07950f8.
  • Release builds: Linux GCC 15.2 and Windows 11 UCRT64 GCC 16.2; targets compiled serially, parallelism 7, with nice -n 19 on Linux and Idle priority on Windows.
  • Focused results on exact head 77b0c858391dc2b065b7614c9ec612c3bdc00d27: guest_libressl3_bio_lifetime and guest_multibyte_locale, three runs each (--repeat until-fail:3) on Linux and three runs each on Windows, all passed.
  • Controlled Windows negative/positive proof: substituting historical cb8348822430 WideConversion.cpp reproduced the exact hosted failure (guest_multibyte_locale, failed: wcstombs fills the capacity mid-character, exit code 0xc0000409), and byte-exact restoration of the main source (SHA256 DBA2EB68D4CD2FFDBFA0723C258E2ED86BEC5DFB5EA5F3C9E77788676BF237DA) rebuilt and passed cleanly.
  • Source-counted inventory at the November 16 tested head: Export.cpp 12 throwing placeholders; AdditionalExports.cpp 52 (after #18760 on main); ParentExports.cpp 387 forwarders (after #18861 on main). The folded document has one pending-export entry.
  • Conventions (python3 tools/check_conventions.py --base refs/review/current-main) have zero errors (the existing long-inventory warning remains), public-header audit (413 libraries, 34650 exports) and diff checks pass.
  • Global debt folding still encounters main's pre-existing missing NKWebKit anchor (docs-nkwebkit-drop-readded-count-lines.md:5). With that unrelated fragment excluded in an isolated scratch simulation, debt_fold.py --check and --show libSceLibreSsl3 pass; no unrelated NKWebKit change is mixed into this SSL branch.
  • Socket/owner compatibility was checked against main's shutdownFlags and Forwards changes. No macOS, console or title execution was performed.

A pre-push merge-tree check against main be4613dd73785558bb3cda5ea5f917f983b7fbd1 was conflict-free. The exact tested head and merged baseline are recorded above; no zero-commits-behind claim is made.

Overlap was checked against open PRs with manual comparison of inconclusive old-baseline conflicts. Other reported overlaps concern adjacent declarations, inventories or test registrations. #16529 dropped its competing BIO_vfree implementation; this branch retains its own parent-BIO delegation.

November 18 merge verification: 183a7b6df3bb5495c75431121fb38d22646572c0 merges main at a0a9c65768bc8fbad8e714fc2eb64e8ecb31d8d6. The merge retains the PEM RSA reader from #23155 and brings in the stdio readiness fix from #23167. On Linux Release with GCC 15, guest_libressl3_bio_lifetime passed three consecutive runs. Conventions reported zero errors, the LibreSSL3 debt preview folded successfully, and git diff --check passed.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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:5202032121 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16654). Originally posted by [MarrasFederico](https://github.com/MarrasFederico) on 2026-11-07T13:24:42Z. --- ### 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. The dedicated source file retains the original notices. - It uses the parent's 104-byte BIO representation already created by the forwarded `BIO_new` and memory-BIO APIs. No second layout or lifetime table is introduced. - Callback veto and chained ownership retain the parent's behavior. Parent-library limitations and the unmeasured console ABI/layout remain recorded in the debt; this wrapper does not establish interoperability with the separate native BIO representation. - At head `183a7b6df3bb5495c75431121fb38d22646572c0`, `Export.cpp` contains 6 remaining throwing placeholders. The debt fragment records the same count and excludes both `BIO_vfree` and `PEM_read_RSAPrivateKey`. Supersedes #15599, which GitHub closed when the head fork was deleted. Earlier review comments and Windows test results remain there. ### 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. --> November 21 update: head `2cb308ae7c` merges main at `9950ae309c`. The inventory conflict in `docs/dev/debt/changes/libressl3-20171-inventory.md` was resolved by keeping both exclusions: `BIO_vfree` from this PR and `d2i_PKCS7` from main, which leaves 5 pending exports. Linux: all 199 LibreSSL/LibreSSL3 tests passed, `guest_libressl3_bio_lifetime` passed three runs, and conventions passed. Windows was not rerun at this head. Maintenance verification, November 16, 2026: `77b0c858391dc2b065b7614c9ec612c3bdc00d27` merges `main` `48d3ccecace42059931318e307617fa832fb83cf` into `cb8348822430e3fba282b05e7637350e7fa3a1a0` through a normal merge (`--no-ff`) with zero conflicts and an unchanged 7-file PR delta (`+304/-6`). No published history was rewritten. - Merging `main` `48d3ccecace4` brings in `cc1c20e0dd181ac5410d99b28fe833cc323198c8` (revert #21244), which restores bytewise capacity truncation in `core/libs/prx/libc/src/WideConversion.cpp` and resolves the inherited hosted Windows `guest_multibyte_locale` (`wcstombs fills the capacity mid-character`) failure from baseline `e4caa07950f8`. - Release builds: Linux GCC 15.2 and Windows 11 UCRT64 GCC 16.2; targets compiled serially, parallelism 7, with `nice -n 19` on Linux and `Idle` priority on Windows. - Focused results on exact head `77b0c858391dc2b065b7614c9ec612c3bdc00d27`: `guest_libressl3_bio_lifetime` and `guest_multibyte_locale`, three runs each (`--repeat until-fail:3`) on Linux and three runs each on Windows, all passed. - Controlled Windows negative/positive proof: substituting historical `cb8348822430` `WideConversion.cpp` reproduced the exact hosted failure (`guest_multibyte_locale`, `failed: wcstombs fills the capacity mid-character`, exit code `0xc0000409`), and byte-exact restoration of the `main` source (`SHA256 DBA2EB68D4CD2FFDBFA0723C258E2ED86BEC5DFB5EA5F3C9E77788676BF237DA`) rebuilt and passed cleanly. - Source-counted inventory at the November 16 tested head: `Export.cpp` 12 throwing placeholders; `AdditionalExports.cpp` 52 (after #18760 on `main`); `ParentExports.cpp` 387 forwarders (after #18861 on `main`). The folded document has one pending-export entry. - Conventions (`python3 tools/check_conventions.py --base refs/review/current-main`) have zero errors (the existing long-inventory warning remains), public-header audit (`413 libraries, 34650 exports`) and diff checks pass. - Global debt folding still encounters `main`'s pre-existing missing NKWebKit anchor (`docs-nkwebkit-drop-readded-count-lines.md:5`). With that unrelated fragment excluded in an isolated scratch simulation, `debt_fold.py --check` and `--show libSceLibreSsl3` pass; no unrelated NKWebKit change is mixed into this SSL branch. - Socket/owner compatibility was checked against `main`'s `shutdownFlags` and `Forwards` changes. No macOS, console or title execution was performed. A pre-push merge-tree check against `main` `be4613dd73785558bb3cda5ea5f917f983b7fbd1` was conflict-free. The exact tested head and merged baseline are recorded above; no zero-commits-behind claim is made. Overlap was checked against open PRs with manual comparison of inconclusive old-baseline conflicts. Other reported overlaps concern adjacent declarations, inventories or test registrations. #16529 dropped its competing `BIO_vfree` implementation; this branch retains its own parent-BIO delegation. November 18 merge verification: `183a7b6df3bb5495c75431121fb38d22646572c0` merges `main` at `a0a9c65768bc8fbad8e714fc2eb64e8ecb31d8d6`. The merge retains the PEM RSA reader from #23155 and brings in the stdio readiness fix from #23167. On Linux Release with GCC 15, `guest_libressl3_bio_lifetime` passed three consecutive runs. Conventions reported zero errors, the LibreSSL3 debt preview folded successfully, and `git diff --check` passed. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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 -->
MarcZX10 commented 2026-11-21 06:17:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T06:17:21Z.

Review: APPROVED


Reviewed — looks good

The BIO_vfree wrapper delegates to the existing BIO_free implementation, and the inspected source and test coverage support merging at head 183a7b6df3bb5495c75431121fb38d22646572c0.

What I ran

No commands or tests were run; I inspected the prepared diff and targeted source through repo_read.py.

Results

Check Result Note
Diff and changed files passed All seven changed files reviewed
Runtime tests not run PR description reports Linux test runs

Findings

Blocking

None.

Non-blocking

None.

Not verified

No tests were run during this review. Console ABI, BIO layout, and title execution are not verified, as recorded in the debt entry. No files were excluded from review; all seven changed files in the manifest were read.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6003443598 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16654#pullrequestreview-6003443598). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T06:17:21Z. **Review:** APPROVED --- # Reviewed — looks good The BIO_vfree wrapper delegates to the existing BIO_free implementation, and the inspected source and test coverage support merging at head `183a7b6df3bb5495c75431121fb38d22646572c0`. ## What I ran No commands or tests were run; I inspected the prepared diff and targeted source through `repo_read.py`. ## Results | Check | Result | Note | |---|---|---| | Diff and changed files | passed | All seven changed files reviewed | | Runtime tests | not run | PR description reports Linux test runs | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified No tests were run during this review. Console ABI, BIO layout, and title execution are not verified, as recorded in the debt entry. No files were excluded from review; all seven changed files in the manifest were read. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-21 12:30:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T12:30:20Z.

Review: APPROVED


Reviewed — looks good

The review covers head 2cb308ae7c2a7e9f595e4f81d7e198ff37288d9d; the adapter delegates BIO release to the parent implementation, and the inspected code supports the claimed reference-count, callback, and destructor behavior.

What I ran

No commands or tests were run in this review. The author reports Linux checks passed on this head; those results were not independently run here.

Results

Check Result Note
Code review passed Changed behavior and parent implementation inspected
Test execution not run Author reports Linux tests passed

Findings

Blocking

None.

Non-blocking

None.

Not verified

I read all changed files listed in the manifest: CMakeLists.txt, Export.cpp, include/Api.hpp, src/BioLifetime.cpp, tests/BioLifetime.cpp, and both debt documents. No changed files were excluded. I did not independently run tests or verify Windows, console ABI/layout, or console behavior.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6005190231 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16654#pullrequestreview-6005190231). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T12:30:20Z. **Review:** APPROVED --- # Reviewed — looks good The review covers head `2cb308ae7c2a7e9f595e4f81d7e198ff37288d9d`; the adapter delegates BIO release to the parent implementation, and the inspected code supports the claimed reference-count, callback, and destructor behavior. ## What I ran No commands or tests were run in this review. The author reports Linux checks passed on this head; those results were not independently run here. ## Results | Check | Result | Note | |---|---|---| | Code review | passed | Changed behavior and parent implementation inspected | | Test execution | not run | Author reports Linux tests passed | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I read all changed files listed in the manifest: `CMakeLists.txt`, `Export.cpp`, `include/Api.hpp`, `src/BioLifetime.cpp`, `tests/BioLifetime.cpp`, and both debt documents. No changed files were excluded. I did not independently run tests or verify Windows, console ABI/layout, or console behavior. ## To get this to a good state Nothing is required.

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