Skip to content

Backport #108493 to 26.3: Fix crash on deeply nested expressions with raised max_parser_depth - #108897

Merged
Algunenano merged 3 commits into
26.3from
backport/26.3/108493
Jun 30, 2026
Merged

Algunenano merged 3 commits into
26.3from
backport/26.3/108493

Conversation

@robot-clickhouse

@robot-clickhouse robot-clickhouse commented Jun 30, 2026 •

Copy link
Copy Markdown
Member

Original pull-request #108493
Cherry-pick pull-request #108829

This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you intend to backport changes to the target branch, otherwise just close it.

The PR source

The PR is created in the CI job

Version info

  • Merged into: 26.3.17.7

@robot-clickhouse robot-clickhouse added pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-critical-bugfix labels Jun 30, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [BackportPR], commit [472b797]

Summary: ✅

alexey-milovidov and others added 2 commits June 30, 2026 08:36
`ParserCollectionOfLiterals::parseImpl` copied the just-finished nested
collection into its parent layer on every closing bracket, making the
parsing of a deeply nested literal such as `[[[ ... ]]]` quadratic in its
depth.

The new test `04412_deep_nested_literal_format` builds
`formatQuery([...20000...])`. The `Stress test (amd_tsan)` runner ignores
the test's `no-*` tags and runs it anyway, so the quadratic build never
finishes in time and trips the "Hung check failed, possible deadlock found"
check.

Move the value into the parent instead of copying it. `literal` is a local
that is discarded right after (only the outermost layer is kept as `node`),
so moving its value out is safe and produces an identical `Field`.

This mirrors the master change in #108892
and the 26.6 backport in #108832.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=108897&sha=cc66187446ca00eca7656b498616f904352d22eb&name_0=BackportPR&name_1=Stress%20test%20%28amd_tsan%29

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

Merged the latest 26.3 and pushed a fix for the only red check.

The sole CI failure was Stress test (amd_tsan) → "Hung check failed, possible deadlock found". This is deterministic and caused by this backport's own new test 04412_deep_nested_literal_format, which builds formatQuery([...20000...]). The stress runner ignores the test's no-fasttest/no-debug/no-sanitizers tags and runs it anyway. Parsing that literal was quadratic in its depth because ParserCollectionOfLiterals::parseImpl copied the just-finished nested collection into its parent layer on every closing bracket, so the build never finished in time and tripped the hung check.

The fix moves the value into the parent instead of copying it (push_back(std::move(literal->value))), making parsing linear. literal is a local that is discarded right after, so moving its value out is safe and produces an identical Field.

This mirrors the master change in #108892 and the 26.6 backport in #108832.

@Algunenano
Algunenano merged commit e940ceb into 26.3 Jun 30, 2026
34 checks passed
@Algunenano
Algunenano deleted the backport/26.3/108493 branch June 30, 2026 11:24
bytehalo-infra added a commit to sentioxyz/ClickHouse that referenced this pull request Sep 25, 2026
OTHER: deeply nested literal with a large max_parser_depth -> crash.
Effect in the production build a394e92: its upstream test(s) 04411_deep_nested_field_to_type, 04412_deep_nested_literal_format, 04413_set_param_deep_collection fail on it (the server process died in 04411_deep_nested_field_to_type) and pass on official 26.8.8.8, run on isolated servers (evidence/fix_ci_20260925/upstream_repro/server_triage_PROD263_vs_UP2688.tsv).
Upstream patch unchanged, with its test(s): 04411_deep_nested_field_to_type,04412_deep_nested_literal_format,04413_set_param_deep_collection.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-critical-bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants