Skip to content

Cherry pick #125505 to 26.3: Fix a possible segmentation fault in AvroConfluent when reading an Avro map into a Map column - #125932

Merged
robot-ch-test-poll3 merged 5 commits into
backport/26.3/125505from
cherrypick/26.3/125505
Oct 15, 2026
Merged

robot-ch-test-poll3 merged 5 commits into
backport/26.3/125505from
cherrypick/26.3/125505

Conversation

@robot-clickhouse-ci-2

Copy link
Copy Markdown
Contributor

Original pull-request #125505

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Before you resolve anything

Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

groeneai and others added 4 commits October 12, 2026 20:17
AvroConfluentRowInputFormat::getOrCreateDeserializer built a stack-local
AvroDeserializer and moved it into deserializer_cache. The AVRO_MAP key
closure created while constructing it captures `this` (#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.

#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 #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]>
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]>
…cached-deserializer

Fix a possible segmentation fault in `AvroConfluent` when reading an Avro `map` into a `Map` column
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Oct 15, 2026
…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]>
@groeneai

Copy link
Copy Markdown
Collaborator

Conflict resolved; the resolution is on my fork

The only conflict is in AvroConfluentRowInputFormat::getOrCreateDeserializer. On master, getSchema also takes the schema registry timeout and retry settings added by #101935, which is not on 26.3. I kept 26.3's schema_registry->getSchema(schema_id) and took #125505's try_emplace as is. Compared with backport/26.3/125505, the diff touches exactly #125505's four files (+74/-4), and the header change and the test are identical to the PR.

Checked on a local 26.3 ASan build (clang-21): 05385_avro_confluent_map_datetime_key passes 13/13. Without the fix it fails 3/3 with stack-use-after-return in the map key deserializer (AvroRowInputFormat.cpp:687), which reads the destroyed local deserializer of getOrCreateDeserializer, so 26.3 is affected. The resolution is a fast-forward of the current head 39e872eb40c2.

I have triage but not push, so applying it needs someone with push access:

git fetch https://github.com/groeneai/ClickHouse groeneai/resolve-26.3-cherrypick-125505 && git push origin FETCH_HEAD:cherrypick/26.3/125505

Tip d0e4f3d819f4 (merge of backport/26.3/125505 into the cherry-pick head), tree a0bfee8857bf.

@robot-ch-test-poll3
robot-ch-test-poll3 merged commit c4de015 into backport/26.3/125505 Oct 15, 2026
1 check passed
@robot-ch-test-poll3
robot-ch-test-poll3 deleted the cherrypick/26.3/125505 branch October 15, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants