fix: Fix memory leaks in HTTPClient - #6370
Merged
Merged
Conversation
Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
pratikmankawde
marked this pull request as ready for review
February 16, 2026 15:41
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #6370 +/- ##
=========================================
- Coverage 79.9% 79.8% -0.0%
=========================================
Files 878 878
Lines 67885 67887 +2
Branches 7547 7556 +9
=========================================
- Hits 54210 54194 -16
- Misses 13675 13693 +18
🚀 New features to boost your workflow:
|
Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
mathbunnyru
requested changes
Feb 17, 2026
Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
…ssues-in-rippled Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
mathbunnyru
reviewed
Feb 23, 2026
| { | ||
| break; | ||
| } | ||
| HTTPClient::initializeSSLContext("", "", false, j_); |
Contributor
There was a problem hiding this comment.
nit: Would be great if you added what these params mean (using inline comments)
Contributor
Author
There was a problem hiding this comment.
Will do, thanks for the quick review :)
mathbunnyru
approved these changes
Feb 23, 2026
Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
a1q123456
reviewed
Mar 11, 2026
Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
mathbunnyru
approved these changes
Mar 11, 2026
bthomee
enabled auto-merge (squash)
March 16, 2026 14:00
beartec-jpg
pushed a commit
to beartec-jpg/FalconLedger
that referenced
this pull request
Jun 1, 2026
The `HTTPClient` class initializes a global SSL context via `initializeSSLContext()`. However, it had no way to release it, which caused memory leaks flagged by the LeakSanitizer. Multiple LSAN suppressions in the sanitizers' suppressions file were masking these leaks. Our test code also manually called `initializeSSLContext()` in each test without guaranteed cleanup on failure paths. This change fixes these memory leaks by adding a `cleanupSSLContext()` method to properly release the global SSL context, and removes the corresponding LSAN suppressions. The change further refactors the `HTTPClient` tests to use a Google Test fixture (`HTTPClientTest`) that manages the SSL context lifecycle via RAII (SetUp/TearDown), making it impossible for tests to leak the context.
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.
High Level Overview of Change
Fix memory leaks in HTTPClient by adding a cleanupSSLContext() method to properly release the global SSL context, and remove the corresponding LSAN suppressions. Refactor the HTTPClient tests to use a Google Test fixture (HTTPClientTest) that manages the SSL context lifecycle via RAII (SetUp/TearDown), making it impossible for tests to leak the context.
Context of Change
The HTTPClient class initializes a global SSL context via initializeSSLContext() but had no way to release it, causing memory leaks flagged by LeakSanitizer. Multiple LSAN suppressions in sanitizers/suppressions/lsan.supp were masking these leaks. The test code also manually called initializeSSLContext() in each test without guaranteed cleanup on failure paths.
This change:
Adds HTTPClient::cleanupSSLContext() which resets the global std::optional.
Removes 11 LSAN suppression entries that are no longer needed.
Refactors tests from free-standing TEST() with manual init/cleanup to a TEST_F() fixture that handles context lifecycle automatically.
Type of Change
[x] Bug fix (non-breaking change which fixes an issue)