Repository navigation
mod_ldap: Fix a memory leak in util_ald_create_caches() (PR 70319) - #1048
Open
arturobernalg wants to merge 1 commit into
Open
arturobernalg wants to merge 1 commit into
arturobernalg wants to merge 1 commit into
Conversation
util_ald_create_caches() creates the search, compare and DN-compare caches for a URL and then inserts a node referring to them into the shared URL cache. When that insert returns NULL because the URL cache is full and the purge freed nothing (AH01323), the three freshly-created caches were never referenced anywhere and leaked. Capture the insert's result and destroy the three caches when it is NULL, same as the existing cleanup path for when one of them fails to allocate in the first place. Reproduced on a real server with an ASan build (static mod_ldap and mod_authnz_ldap, per the report): LeakSanitizer reports 13968 bytes leaked for the exact repro in the Bugzilla report; after this fix, zero leaks. Added test/modules/ldap/test_001_cache_leak.py, which measures the RSS growth of one pinned worker process over repeated alternating requests to two AuthLDAPURLs with LDAPCacheEntries 1; fails on trunk, passes with this fix. The test is skipped off Linux (it reads /proc) and under AddressSanitizer, whose own allocations dwarf the leak in RSS. PR: https://bz.apache.org/bugzilla/show_bug.cgi?id=70319
arturobernalg
force-pushed
the
fix/bz70319-ldap-cache-leak
branch
from
November 17, 2026 11:47
69eb12a to
97f63f4
Compare
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.
util_ald_create_caches() creates the search, compare and DN-compare caches for a URL and then inserts a node referring to them into the shared URL cache. When that insert returns NULL because the URL cache is full and the purge freed nothing (AH01323), the three freshly-created caches were never referenced anywhere and leaked.
Capture the insert's result and destroy the three caches when it is NULL, same as the existing cleanup path for when one of them fails to allocate in the first place.
Reproduced on a real server with an ASan build (static mod_ldap and mod_authnz_ldap, per the report): LeakSanitizer reports 13968 bytes leaked for the exact repro in the Bugzilla report; after this fix, zero leaks. Added test/modules/ldap/test_001_cache_leak.py, which measures the RSS growth of one pinned worker process over repeated alternating requests to two AuthLDAPURLs with LDAPCacheEntries 1; fails on trunk, passes with this fix.
PR: https://bz.apache.org/bugzilla/show_bug.cgi?id=70319
[x] This PR does not report or address a security vulnerability (see SECURITY.md).
[x] Code follows the httpd style guide.
[x] New log messages: N/A, no new log messages added.
[x] changes-entries/70319.txt is included.
[x] Test cases based on pyhttpd are included: test/modules/ldap/, verified locally with make check-pytest PYTEST_DIRS=test/modules/ldap.