Skip to content

fix(libressl): free lookup on insertion exceptions - #19820

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
DonRyuzaki:codex/x509-store-lookup-cleanup-20261113
Nov 14, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
DonRyuzaki:codex/x509-store-lookup-cleanup-20261113

Conversation

@DonRyuzaki

Copy link
Copy Markdown
Contributor

What

Release an accepted but unpublished X509 lookup when the existing malformed-stack insertion guard throws. Invoke method.free and the matching allocation release as the normal failed-insertion path does; do not call shutdown for a lookup never published to the store.

Keep new_item refusal, successful insertion, ordinary growth failure and free-callback exception behavior unchanged. Trim only the documented leaked-lookup clause from debt; the console-unverified behavior and malformed-stack exceptions remain documented.

Tested

Linux, Ubuntu 24.04 under WSL2, GCC 13.3, Release; base 6fd2999417948562be633aa71629bab45d0e8b81, head 91b8fe5e006bc3f922b2c9cb9f9063317f78ab5e, tree 4170ddd41f1782b2ba4ca7ceb1eef48929af07c4.

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

@JJenkx

JJenkx commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 91b8fe5e00, merged onto main 04631f5042 (32c36ac351, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.

  • guest_libressl_x509_lookup, guest_libressl_x509_lookup_allocator pass in 3 of 3 runs, none skipped.

AI-assisted: yes.

@github-actions

Copy link
Copy Markdown

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.

Pull request Shared files not compared
PR 11146 docs/dev/debt/libSceLibreSsl.md
PR 11176 docs/dev/debt/libSceLibreSsl.md
PR 11466 docs/dev/debt/libSceLibreSsl.md
PR 12730 core/libs/prx/libSceLibreSsl/src/X509Store.cpp
docs/dev/debt/libSceLibreSsl.md
PR 15279 docs/dev/debt/libSceLibreSsl.md
PR 15280 docs/dev/debt/libSceLibreSsl.md
PR 15737 docs/dev/debt/libSceLibreSsl.md
PR 17961 docs/dev/debt/libSceLibreSsl.md

@PrivacyOnion PrivacyOnion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 91b8fe5e00:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_libressl_x509_lookup_tests built cleanly.
  • CTest (guest_libressl_x509_lookup, guest_libressl_x509_lookup_allocator):
    1/2 Test #3772: guest_libressl_x509_lookup .............   Passed    0.01 sec
    2/2 Test #3773: guest_libressl_x509_lookup_allocator ...   Passed    0.00 sec
    100% tests passed, 0 tests failed out of 2
    
  • Negative control: with core/libs/prx/libSceLibreSsl/src/X509Store.cpp reverted to main and the new tests kept, the suite fails:
    1/2 Test #3772: guest_libressl_x509_lookup .............   Passed    0.01 sec
    2/2 Test #3773: guest_libressl_x509_lookup_allocator ...Subprocess aborted***Exception:   0.12 sec
    50% tests passed, 1 tests failed out of 2
    
    Restoring the change makes it pass again.
  • Code reading:
    • core/libs/prx/libSceLibreSsl/src/X509Store.cpp:246: Verified that X509_STORE_add_lookup_nid_postfix wraps Push in a try/catch block that invokes FreeLookup(lookup, false, func) and rethrows on insertion exceptions, correctly freeing the accepted lookup without invoking shutdown.
    • core/libs/prx/libSceLibreSsl/src/X509Store.cpp:243-255: Verified that lookup->storeContext initialization ordering, non-throwing Push failure handling, and method deduplication paths remain intact and leak-free.
    • core/libs/prx/libSceLibreSsl/tests/X509Lookup.cpp:205-232: Verified that MalformedStackCleanup tests both malformed stack conditions (numAlloc == 0 and num == -1), ensuring allocation and free counts balance (1 alloc, 1 free), callbacks run in expected order without shutdown, stack state is preserved, and seeded error queues remain undisturbed.
    • core/libs/prx/libSceLibreSsl/tests/X509Lookup.cpp:234-255: Verified that ThrowingFreeOnFailedPush confirms exception preservation when method->free throws upon failed push without corrupting the store stack.
    • docs/dev/debt/libSceLibreSsl.md:171: Verified that the technical debt document accurately trims only the resolved leaked-lookup clause while retaining existing documentation of malformed stack exceptions.
    • AGENTS.md: Verified strict compliance with all repository rules: zero code comments added, valid Conventional Commits PR title, and no unauthorized files introduced.
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

@oneandonlydean
oneandonlydean merged commit b0f9c3c into boykopovar:main Nov 14, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants