Repository navigation
provider: free the child libctx on teardown - #519
Open
ColtonWilley wants to merge 2 commits into
Open
ColtonWilley wants to merge 2 commits into
ColtonWilley wants to merge 2 commits into
Conversation
wolfssl_provider_init creates a child library context with OSSL_LIB_CTX_new_child() that the provider owns, but teardown never freed it, leaking ~37 KB per explicitly loaded or config-activated instance. Free it first in teardown, as OpenSSL's legacy provider does.
The test binaries link libasan, so drop the preload after env-setup and run make test with detect_leaks=1. make and the shell tools stay unchecked.
There was a problem hiding this comment.
🟢 Approval recommended
The focused cleanup matches context ownership, the sanitizer changes align with test linking, and no blocking issues remain.
No open issues 🎉
What changed in this PR
Fixes a provider-instance memory leak by freeing the owned child OpenSSL library context during teardown, and enables leak detection for sanitizer unit tests.
Changes:
- Free the child library context before other provider resources.
- Clarify library-context ownership in internal comments.
- Enable LeakSanitizer for
make testand update sanitizer documentation.
| File | Description |
|---|---|
src/wp_wolfprov.c |
Free the child context during teardown and clarify ownership. |
include/wolfprovider/internal.h |
Document that the library context is owned and nullable. |
.github/workflows/sanitizers.yml |
Enable unit-test leak detection without preloading the sanitizer runtime. |
.github/workflows/README.md |
Document leak checks and sanitizer runtime loading. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
wolfssl_provider_initcreates a child library context withOSSL_LIB_CTX_new_child()that the provider owns, but teardown never freed it: ~37 KB leaks per explicitly loaded or config-activated instance, growing in apps that repeatedly create a libctx and load a provider (e.g. OpenSC in replace-default mode). It is now freed first in teardown, as OpenSSL's legacy provider does. The ASan unit-test step now runs with leak detection, which fails on master.