Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6193 +/- ##
==========================================
- Coverage 88.26% 88.25% -0.02%
==========================================
Files 223 227 +4
Lines 39610 39962 +352
Branches 2318 2592 +274
==========================================
+ Hits 34963 35267 +304
- Misses 4632 4680 +48
Partials 15 15
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| if (error.key != NA_rstr) { | ||
| RedisModule_Log(RSDummyContext, REDISMODULE_LOGLEVEL_WARNING, | ||
| "NA_rstr was re-allocated"); | ||
| } |
There was a problem hiding this comment.
Why here for example you chose not to assert it?
There was a problem hiding this comment.
because its a valid scenario
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin 2.8
git worktree add -d .worktree/backport-6193-to-2.8 origin/2.8
cd .worktree/backport-6193-to-2.8
git switch --create backport-6193-to-2.8
git cherry-pick -x d8b03130ef1c44a80c1f59c5a443358cc487755b |
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin 2.6
git worktree add -d .worktree/backport-6193-to-2.6 origin/2.6
cd .worktree/backport-6193-to-2.6
git switch --create backport-6193-to-2.6
git cherry-pick -x d8b03130ef1c44a80c1f59c5a443358cc487755b |
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin 2.10
git worktree add -d .worktree/backport-6193-to-2.10 origin/2.10
cd .worktree/backport-6193-to-2.10
git switch --create backport-6193-to-2.10
git cherry-pick -x d8b03130ef1c44a80c1f59c5a443358cc487755b |
* free and invalidate NA_rstr (expect saniztizer to fail * fix 1 should still leak on coordinator * fix final leak - override AggregatedFieldSpecInfo and lose ref * Change the number of issues * change to 1024 * move fields IndexError_Clear to main thread * remove rm_free(spec->fields); * fix * add header --------- Co-authored-by: Dor Forer <[email protected]> (cherry picked from commit d8b0313)
|
Successfully created backport PR for |
* free and invalidate NA_rstr (expect saniztizer to fail * fix 1 should still leak on coordinator * fix final leak - override AggregatedFieldSpecInfo and lose ref * Change the number of issues * change to 1024 * move fields IndexError_Clear to main thread * remove rm_free(spec->fields); * fix * add header --------- Co-authored-by: Dor Forer <[email protected]> (cherry picked from commit d8b0313)
* free and invalidate NA_rstr (expect saniztizer to fail * fix 1 should still leak on coordinator * fix final leak - override AggregatedFieldSpecInfo and lose ref * Change the number of issues * change to 1024 * move fields IndexError_Clear to main thread * remove rm_free(spec->fields); * fix * add header --------- Co-authored-by: Dor Forer <[email protected]> (cherry picked from commit d8b0313)
* [MOD-9396] Fix indexError leak (#6193) * free and invalidate NA_rstr (expect saniztizer to fail * fix 1 should still leak on coordinator * fix final leak - override AggregatedFieldSpecInfo and lose ref * Change the number of issues * change to 1024 * move fields IndexError_Clear to main thread * remove rm_free(spec->fields); * fix * add header --------- Co-authored-by: Dor Forer <[email protected]> (cherry picked from commit d8b0313) * move our of coord macro --------- Co-authored-by: Dor Forer <[email protected]>
[MOD-9396] Fix indexError leak (#6193) * free and invalidate NA_rstr (expect saniztizer to fail * fix 1 should still leak on coordinator * fix final leak - override AggregatedFieldSpecInfo and lose ref * Change the number of issues * change to 1024 * move fields IndexError_Clear to main thread * remove rm_free(spec->fields); * fix * add header --------- (cherry picked from commit d8b0313) Co-authored-by: meiravgri <[email protected]> Co-authored-by: Dor Forer <[email protected]>
* free and invalidate NA_rstr (expect saniztizer to fail * fix 1 should still leak on coordinator * fix final leak - override AggregatedFieldSpecInfo and lose ref * Change the number of issues * change to 1024 * move fields IndexError_Clear to main thread * remove rm_free(spec->fields); * fix * add header --------- Co-authored-by: Dor Forer <[email protected]> (cherry picked from commit d8b0313)
* free and invalidate NA_rstr (expect saniztizer to fail * fix 1 should still leak on coordinator * fix final leak - override AggregatedFieldSpecInfo and lose ref * Change the number of issues * change to 1024 * move fields IndexError_Clear to main thread * remove rm_free(spec->fields); * fix * add header --------- Co-authored-by: Dor Forer <[email protected]>
* free and invalidate NA_rstr (expect saniztizer to fail * fix 1 should still leak on coordinator * fix final leak - override AggregatedFieldSpecInfo and lose ref * Change the number of issues * change to 1024 * move fields IndexError_Clear to main thread * remove rm_free(spec->fields); * fix * add header --------- Co-authored-by: Dor Forer <[email protected]>
* [MOD-9396] Fix indexError leak (#6193) * free and invalidate NA_rstr (expect saniztizer to fail * fix 1 should still leak on coordinator * fix final leak - override AggregatedFieldSpecInfo and lose ref * Change the number of issues * change to 1024 * move fields IndexError_Clear to main thread * remove rm_free(spec->fields); * fix * add header --------- Co-authored-by: Dor Forer <[email protected]> (cherry picked from commit d8b0313) * move out of coord * move cleanup before auto memory --------- Co-authored-by: Dor Forer <[email protected]>
* [MOD-9396] Fix indexError leak (#6193) * free and invalidate NA_rstr (expect saniztizer to fail * fix 1 should still leak on coordinator * fix final leak - override AggregatedFieldSpecInfo and lose ref * Change the number of issues * change to 1024 * move fields IndexError_Clear to main thread * remove rm_free(spec->fields); * fix * add header --------- Co-authored-by: Dor Forer <[email protected]> (cherry picked from commit d8b0313) * add include * fix IndexError_GlobalCleanup * remove line --------- Co-authored-by: Dor Forer <[email protected]>
This PR fixes a memory leak in the IndexError object related to the handling of the global
NA_rstrthat is used for "N/A" responses in IndexError objects.The issue occurred because each new
IndexErrorobject incremented the reference count of theNA_rstrviaRedisModule_HoldString()but never decreased it. While not causing an immediate memory leak, this created a significant problem when the reference count reachedMAX_INT - 1.At this threshold, Redis would begin treating the string as stack-allocated and start duplicating it rather than incrementing its reference count. These duplicated strings were never freed, leading to a memory leak that grew over time.Fix
The fix is implemented in IndexError_Clear(), which now always releases the error->key.
additional changes and fixes:
then overriding it with new IndexError object
This leak was fixed by initialized info to an empty struct:
Testing
The first reference to the NA_rstr string is held by the global variable in IndexError.c.
IndexError_GlobalCleanup was introduced in this pr to release it and nullify the global variable holding it,
once a shutdown event notification is received
If the refcount is messed up, we expect the sanitizer to report a leak because the reference to the string allocation is lost.