fix(logstorage): decrement g_logstorage_cache_size on filter config free#838
Open
aki1770-del wants to merge 1 commit into
Open
fix(logstorage): decrement g_logstorage_cache_size on filter config free#838aki1770-del wants to merge 1 commit into
aki1770-del wants to merge 1 commit into
Conversation
When dlt_logstorage_filter_config_free() frees data->cache it never decremented the global g_logstorage_cache_size counter. This caused the counter to grow unboundedly across disable/re-enable cycles, eventually preventing any new cache allocation even when physical memory is available. Compute the same cache_size value used during allocation (specific_size or file_size plus footer) and subtract it from g_logstorage_cache_size before freeing the buffer, clamping to zero to guard against any bookkeeping inconsistency. Fixes COVESA#778
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.
Problem
dlt_logstorage_filter_config_free()callsfree(data->cache)but never decrements the globalg_logstorage_cache_sizecounter.The counter is incremented during cache allocation in
dlt_logstorage_create_cache():But on the free path the decrement is missing, so the counter grows unboundedly across disable/re-enable cycles. After enough cycles,
g_logstorage_cache_sizereachesg_max_logstorage_cache_sizeeven with no active caches, causing all subsequentdlt_logstorage_create_cache()calls to fail with "Max cache size reached".Reported in #778.
Fix
Before
free(data->cache), compute the samecache_sizevalue that was used during allocation and subtract it fromg_logstorage_cache_size. Clamp to zero to guard against any bookkeeping inconsistency.Testing
Verified manually: repeated logstorage enable/disable cycles no longer exhaust the cache counter.