Repository navigation
[MOD-17665] Fix sctx double free in _FT.DEBUG FT.HYBRID error paths - #10948
Merged
Merged
Conversation
HybridRequest_Debug_New freed the sctx through the hybrid request on its parse- and pipeline-build-failure paths (HybridRequest_Free frees hreq->sctx), yet the handler freed the same pointer again on the NULL return — a double free reachable with a malformed hybrid query and a valid DEBUG_PARAMS_COUNT under enable-debug-command. The comment claiming the inner call "doesn't free it on error" was wrong. The contract is now uniform: HybridRequest_Debug_New consumes sctx on every path — the one pre-container failure (invalid DEBUG_PARAMS_COUNT) frees it directly, the rest free it through the request — and the handler stops freeing on NULL. Fixes MOD-17665. Co-Authored-By: Claude Fable 5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #10948 +/- ##
==========================================
- Coverage 83.16% 82.19% -0.97%
==========================================
Files 611 635 +24
Lines 81150 82285 +1135
Branches 36388 37497 +1109
==========================================
+ Hits 67486 67637 +151
- Misses 13317 14301 +984
Partials 347 347
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
nafraf
approved these changes
Aug 16, 2026
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.



Describe the change
_FT.DEBUG FT.HYBRIDdouble-freed (and used-after-free) theRedisSearchCtxwhenHybridRequest_Debug_Newfailed after the hybrid request was built: the parse- and pipeline-build-failure paths free the sctx through the request (HybridRequest_Freefreeshreq->sctx), and the handler then freed the same pointer again on the NULL return, guided by a comment that wrongly claimed the inner call "doesn't free it on error".The ownership contract is now uniform —
HybridRequest_Debug_Newconsumessctxon every path: the one failure that precedes the container (invalidDEBUG_PARAMS_COUNT) frees it directly, the others free it through the request, and on success the request owns it. The handler's NULL branch only replies.Reachability is gated (admin
_FT.DEBUG,enable-debug-command, single shard), so this is not hit by production deployments with default config — master-only fix, no backports planned.Adds the missing regression test: a malformed SEARCH expression with a valid
DEBUG_PARAMS_COUNTis the only error shape that reaches the buggy path (all existing error tests fail either before the container exists or afterDebug_Newsucceeded). Deterministic; crashes pre-fix under ASAN.Which issues this PR fixes
MOD-17665
Main objects this PR modified
HybridRequest_Debug_New— consumessctxon every path (contract documented)DEBUG_hybridCommandHandler— no longer freessctxon the NULL returnMark if applicable
Release notes