Fix use-after-free in EmbeddedBlobResolvingIterator when key() called before value()#14888
Fix use-after-free in EmbeddedBlobResolvingIterator when key() called before value()#14888anand1976 wants to merge 1 commit into
Conversation
… before value() Differential Revision: D109796428
|
@anand1976 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D109796428. |
✅ clang-tidy: No findings on changed linesCompleted in 178.4s. |
🟡 Codex Code ReviewAuto-triggered after CI passed — reviewing commit ad944dd ❌ Codex review failed before producing findings. ℹ️ About this responseGenerated by Codex CLI. Limitations:
Commands:
|
✅ Claude Code ReviewAuto-triggered after CI passed — reviewing commit ad944dd SummaryThis is a well-targeted, minimal fix for a real use-after-free bug in No high-severity findings. Full review (click to expand)Findings🟡 MEDIUMM1. Test does not exercise the wide-column entity path --
|
| Context | Does code execute? | Fix correct? | Notes |
|---|---|---|---|
| CompactionIterator | YES | YES | Primary trigger: key_ = input_.key(); value_ = input_.value(); at cc:710-711 |
| DBIter (user reads) | YES (via MergingIterator) | YES | key()-then-value() pattern possible |
| SstFileReader/sst_dump | Excluded (kSSTDumpTool check) | N/A | EmbeddedBlobResolvingIterator not created |
| ReadOnly DB | YES | YES | Same iterator path |
| WritePreparedTxnDB | YES | YES | No additional interaction with this code |
| Wide-column entities | YES | YES | key_resolved_ stays false, move still occurs correctly |
Assumption stress test results:
- key() then value(): Fix prevents the move.
key_resolved_is true, guard skips move. Correct. - value() only:
ResolveKeyType()called first (line 307), setskey_resolved_. Guard skips move.resolved_internal_key_already set byResolveKeyType()with identical key. Correct. - key() only:
ResolveKeyType()setsresolved_internal_key_.MaterializeValue()never called. Correct. - PrepareValue(): Calls
MaterializeValue(). Same as value()-only analysis. Correct. - Wide-column + key() then value():
ResolveKeyType()returns early (not kTypeBlobIndex).key_resolved_stays false. Move proceeds. Correct.
Positive Observations
- The fix is minimal and precisely targeted -- a single boolean guard that prevents the specific use-after-free without changing any other behavior.
- Both
ResolveKeyType()andMaybeResolveEmbeddedValue()produce byte-identical resolved keys (sameInternalKey(user_key, seq, kTypeValue)construction), making the skip-if-already-resolved semantics correct. - The regression test is well-structured: it mimics the actual
CompactionIteratorpattern, saves the key Slice, calls value(), then verifies the key Slice is still valid. Under ASAN, the original bug would be caught as heap-use-after-free. - The test exercises both entries (key1, key2) covering the Next() + re-resolution path.
ℹ️ About this response
Generated by Claude Code.
Review methodology: claude_md/code_review.md
Limitations:
- Claude may miss context from files not in the diff
- Large PRs may be truncated
- Always apply human judgment to AI suggestions
Commands:
/claude-review [context]— Request a code review/claude-query <question>— Ask about the PR or codebase
Differential Revision: D109796428