Repository navigation
Fix a possible segmentation fault in AvroConfluent when reading an Avro map into a Map column - #125505
Conversation
AvroConfluentRowInputFormat::getOrCreateDeserializer built a stack-local AvroDeserializer and moved it into deserializer_cache. The AVRO_MAP key closure created while constructing it captures `this` (ClickHouse#48119), and moving a std::function keeps that pointer, so every map key read `settings` through the frame of the returned function: stack-use-after-return under ASan for any key type, and a segfault for key types whose text parser dereferences FormatSettings (DateTime, Date, ...) on some builds. ClickHouse#104751 already replaced the copy into the cache by a move to keep the other self-reference (references into symbolic_skip_fn_map) valid. Finish it: delete the move constructor and construct the cache entry in place with try_emplace; unordered_map never relocates its nodes, so both self-references stay valid, and relocating the object no longer compiles. Closes ClickHouse#125457 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The test reserved a port by binding port 0 in one process, closing it and binding the same number again in the schema registry process; a parallel process could take the port in between. The registry now binds port 0 itself and writes the port it got to a file (atomically, via os.replace), and the test waits for that file. TCPServer binds and listens in its constructor, so the server accepts connections as soon as the file exists. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review: my own cold review plus an independent model (engine: codex); 5 findings;
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20261012-205200 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261012-192800 |
|
Workflow [PR], commit [f48bce5] Summary: ✅
AI ReviewSummaryThis PR fixes the Final Verdict
|
The port file name depended only on CLICKHOUSE_TEST_UNIQUE_NAME. Under a fixed `--database` (the stress test's odd workers loop tests that way) a file left by a SIGKILLed earlier run was read before the new registry published its port, so the query hit a dead port. mktemp makes the name unique per run, as in 04615_kill_query_url_function.sh. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units11 translation units recompiled, 54 s compile time in total, 11 of them have a recent master baseline. |
CI finish ledger - f48bce5Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
CIDB has no other Session id: cron:our-pr-ci-monitor:20261013-060009 |
Algunenano
left a comment
There was a problem hiding this comment.
The test is a bit complex, but it is what it is. Rest looks great
39e872e
Backport #125505 to 26.9: Fix a possible segmentation fault in `AvroConfluent` when reading an Avro `map` into a `Map` column
Backport #125505 to 26.8: Fix a possible segmentation fault in `AvroConfluent` when reading an Avro `map` into a `Map` column
Backport #125505 to 26.7: Fix a possible segmentation fault in `AvroConfluent` when reading an Avro `map` into a `Map` column
…onflict The only conflict is in `AvroConfluentRowInputFormat::getOrCreateDeserializer`. On master the `getSchema` call takes the registry timeouts and retry settings added by #101935 (AvroConfluent output format), which is not on 26.3. Resolution: keep 26.3's one-argument `schema_registry->getSchema(schema_id)` and take #125505's change as is: build the cached `AvroDeserializer` in place with `try_emplace` instead of moving a stack-local one into the cache. The header and the test are unchanged from the PR. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cherry pick #125505 to 26.3: Fix a possible segmentation fault in `AvroConfluent` when reading an Avro `map` into a `Map` column
…onfluent` when reading an Avro `map` into a `Map` column
Backport #125505 to 26.3: Fix a possible segmentation fault in `AvroConfluent` when reading an Avro `map` into a `Map` column
… in `AvroConfluent` when reading an Avro `map` into a `Map` column
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a possible segmentation fault when reading an Avro
mapinto aMapcolumn (for exampleMap(DateTime, String)) with theAvroConfluentformat, including Kafka tables. Closes #125457.Description
Closes: #125457
On 26.3, 26.8 and 26.9 (the same code as master), reading an Avro
mapinto aMap(K, V)column withAvroConfluentreads the format settings through a destroyed stack object for every map key. The issue reports a segfault on a 26.10 master build withMap(DateTime, String); the 26.3.42.3, 26.8.18.2 and 26.9.9.28 release images I tried returned correct rows, so whether it crashes depends on what is left in the dead stack slot.AvroConfluentRowInputFormat::getOrCreateDeserializerbuilt a localAvroDeserializerand moved it intodeserializer_cache. The map-key closure created during construction capturesthis, and moving astd::functionkeeps that pointer, so the cached closure later readssettingsthrough the returned frame. #104751 fixed the other self-reference of this object by switching the cache from a copy to a move; this PR makesAvroDeserializernon-movable and constructs the cache entry in place withtry_emplace(std::unordered_mapnever relocates its nodes). PlainAvroand the Iceberg manifest reader never move their deserializer and were not affected.Validation: the new test fails on master's ASan build (
stack-use-after-returnin the map-key lambda atAvroRowInputFormat.cpp:897, in the frame ofgetOrCreateDeserializer) and passes with the fix (ASan 10/10, debug 50/50). The oldemplace(schema_id, std::move(deserializer))no longer compiles.Workflow [PR]
Sync PR [sync-upstream/pr/125505]
Version info
26.10.1.2441-master(included in26.10and later)26.9.20.15,26.8.28.14,26.7.31.13,26.3.52.11