Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a thread safety issue in CursorList_Empty that could lead to use-after-free errors. The fix ensures proper locking when freeing cursors and implements a safe cleanup strategy for active cursors.
- Adds proper locking around cursor cleanup operations
- Implements safe handling of active cursors by marking them for deletion instead of immediate freeing
- Adopts the same logic pattern used in
Cursors_Purgefor consistency
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6594 +/- ##
==========================================
- Coverage 87.48% 87.46% -0.02%
==========================================
Files 277 277
Lines 45554 44515 -1039
Branches 6989 7450 +461
==========================================
- Hits 39851 38934 -917
+ Misses 5611 5476 -135
- Partials 92 105 +13
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:
|
GuyAv46
reviewed
Aug 5, 2025
GuyAv46
reviewed
Aug 5, 2025
GuyAv46
reviewed
Aug 6, 2025
GuyAv46
approved these changes
Aug 6, 2025
redisearch-backport-pull-request bot
pushed a commit
that referenced
this pull request
Aug 6, 2025
* fix cursorList_Empty to mark delete instead of instant delete * remove redundant GC call * remove unused destroy * remove Destroy from h file * update owernship test * fix comments * expand test to multiple cursors * fix loop * use std::vector and std::find (cherry picked from commit 188a741)
Contributor
|
Successfully created backport PR for |
redisearch-backport-pull-request bot
pushed a commit
that referenced
this pull request
Aug 6, 2025
* fix cursorList_Empty to mark delete instead of instant delete * remove redundant GC call * remove unused destroy * remove Destroy from h file * update owernship test * fix comments * expand test to multiple cursors * fix loop * use std::vector and std::find (cherry picked from commit 188a741)
Contributor
|
Successfully created backport PR for |
redisearch-backport-pull-request bot
pushed a commit
that referenced
this pull request
Aug 6, 2025
* fix cursorList_Empty to mark delete instead of instant delete * remove redundant GC call * remove unused destroy * remove Destroy from h file * update owernship test * fix comments * expand test to multiple cursors * fix loop * use std::vector and std::find (cherry picked from commit 188a741)
Contributor
|
Successfully created backport PR for |
lerman25
added a commit
that referenced
this pull request
Aug 6, 2025
* fix cursorList_Empty to mark delete instead of instant delete * remove redundant GC call * remove unused destroy * remove Destroy from h file * update owernship test * fix comments * expand test to multiple cursors * fix loop * use std::vector and std::find
github-merge-queue bot
pushed a commit
that referenced
this pull request
Aug 6, 2025
[MOD-10681] Fix cursor list empty (#6594) * fix cursorList_Empty to mark delete instead of instant delete * remove redundant GC call * remove unused destroy * remove Destroy from h file * update owernship test * fix comments * expand test to multiple cursors * fix loop * use std::vector and std::find (cherry picked from commit 188a741) Co-authored-by: lerman25 <58445352+lerman25@users.noreply.github.com>
github-merge-queue bot
pushed a commit
that referenced
this pull request
Aug 6, 2025
* [MOD-10681] Fix cursor list empty (#6594) * fix cursorList_Empty to mark delete instead of instant delete * remove redundant GC call * remove unused destroy * remove Destroy from h file * update owernship test * fix comments * expand test to multiple cursors * fix loop * use std::vector and std::find (cherry picked from commit 188a741) * fix test --------- Co-authored-by: lerman25 <58445352+lerman25@users.noreply.github.com> Co-authored-by: lerman25 <lerman25@gmail.com>
github-merge-queue bot
pushed a commit
that referenced
this pull request
Aug 6, 2025
* [MOD-10681] Fix cursor list empty (#6594) * fix cursorList_Empty to mark delete instead of instant delete * remove redundant GC call * remove unused destroy * remove Destroy from h file * update owernship test * fix comments * expand test to multiple cursors * fix loop * use std::vector and std::find (cherry picked from commit 188a741) * fix test --------- Co-authored-by: lerman25 <58445352+lerman25@users.noreply.github.com> Co-authored-by: lerman25 <lerman25@gmail.com>
github-merge-queue bot
pushed a commit
that referenced
this pull request
Aug 6, 2025
* [MOD-10681] Fix cursor list empty (#6594) * fix cursorList_Empty to mark delete instead of instant delete * remove redundant GC call * remove unused destroy * remove Destroy from h file * update owernship test * fix comments * expand test to multiple cursors * fix loop * use std::vector and std::find * add missing includes * handle Dict * fix test * fix use after free
JoanFM
pushed a commit
that referenced
this pull request
Apr 13, 2026
* fix cursorList_Empty to mark delete instead of instant delete * remove redundant GC call * remove unused destroy * remove Destroy from h file * update owernship test * fix comments * expand test to multiple cursors * fix loop * use std::vector and std::find
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.
Currently,
CursorList_Emptydoes not acquire theCursorList_Lock, despite callingCursor_FreeInternal, which requires it. This can lead to a use-after-free error, as observed in MOD-10681.This PR addresses the issue by making
CursorList_Emptythread-safe. It adopts the same logic used inCursors_Purge:This ensures correctness and safety in multi-threaded environments where cursor usage and cleanup may occur concurrently.