Fix use-after-free in AvroConfluentRowInputFormat#104751
Merged
Merged
Conversation
`AvroConfluentRowInputFormat::getOrCreateDeserializer` built an `AvroDeserializer` on the stack and copied it into `deserializer_cache`. The deserializer holds `symbolic_skip_fn_map`, and skip lambdas in its action tree capture references into that map. Copying deep-copies the map to a new address while the lambdas still reference the original; once the stack local is destroyed those references dangle, and the next row deserialization invokes a `std::function` over freed memory. Move into the cache instead of copying. `std::map` move-construction transfers existing nodes without relocating them, so the captured references remain valid.
Contributor
|
Workflow [PR], commit [5448d84] Summary: ❌
AI ReviewSummaryThis PR fixes a use-after-free in Findings
Final VerdictStatus: Minimum required actions:
|
AvroConfluentRowInputFormat
Prevent reintroduction of the use-after-free fixed in the previous commit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Ergus
approved these changes
May 12, 2026
Member
Ergus
left a comment
There was a problem hiding this comment.
LGTM. I am just wondering if we can add a test for this somehow to ensure we exercise this path.
| AvroDeserializer(const AvroDeserializer &) = delete; | ||
| AvroDeserializer & operator=(const AvroDeserializer &) = delete; | ||
| AvroDeserializer(AvroDeserializer &&) = default; | ||
| AvroDeserializer & operator=(AvroDeserializer &&) = delete; |
Member
There was a problem hiding this comment.
I am a bit old school, I really like this part ;).
The previous schema's symbolic reference sat at the top level of a skipped field, so createAction resolved it before createSkipFn was called, never building the reference-capturing lambda. A recursive Node schema with `next: ["null", "Node"]` puts the symbolic node inside a union branch, which is one of the spots createSkipFn recurses into on its own. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
LLVM Coverage Report
Changed lines: 100.00% (6/6) · Uncovered code |
robot-clickhouse-ci-1
added a commit
that referenced
this pull request
May 13, 2026
Cherry pick #104751 to 25.8: Fix use-after-free in `AvroConfluentRowInputFormat`
robot-clickhouse
added a commit
that referenced
this pull request
May 13, 2026
This was referenced May 13, 2026
robot-clickhouse-ci-1
added a commit
that referenced
this pull request
May 13, 2026
Cherry pick #104751 to 26.2: Fix use-after-free in `AvroConfluentRowInputFormat`
robot-clickhouse
added a commit
that referenced
this pull request
May 13, 2026
This was referenced May 13, 2026
robot-clickhouse-ci-1
added a commit
that referenced
this pull request
May 13, 2026
Cherry pick #104751 to 26.3: Fix use-after-free in `AvroConfluentRowInputFormat`
robot-clickhouse
added a commit
that referenced
this pull request
May 13, 2026
This was referenced May 13, 2026
robot-clickhouse-ci-1
added a commit
that referenced
this pull request
May 13, 2026
Cherry pick #104751 to 26.4: Fix use-after-free in `AvroConfluentRowInputFormat`
robot-clickhouse
added a commit
that referenced
this pull request
May 13, 2026
mstetsyuk
added a commit
that referenced
this pull request
May 13, 2026
Backport #104751 to 26.2: Fix use-after-free in `AvroConfluentRowInputFormat`
mstetsyuk
added a commit
that referenced
this pull request
May 13, 2026
Backport #104751 to 26.3: Fix use-after-free in `AvroConfluentRowInputFormat`
mstetsyuk
added a commit
that referenced
this pull request
May 13, 2026
Backport #104751 to 26.4: Fix use-after-free in `AvroConfluentRowInputFormat`
mstetsyuk
added a commit
that referenced
this pull request
May 14, 2026
Backport #104751 to 25.8: Fix use-after-free in `AvroConfluentRowInputFormat`
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.
AvroConfluentRowInputFormat::getOrCreateDeserializerbuilt anAvroDeserializeron the stack and copied it intodeserializer_cache. The deserializer holds asymbolic_skip_fn_map, and a lambda inAvroDeserializer::row_actionwhich captures a reference into that map ([&skip_fn = it->second]). Copying deep-copies the map to a new address but leaves the lambda referencing the original. When the stack local is destroyed, those references dangle, and the next row deserialization invokes astd::functionover freed memory. We should usestd::moveinstead of copying.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix segfault due to a use-after-free bug in
AvroConfluentRowInputFormat.