Skip to content

Fix exception in throwUnexpectedDataAfterParsedValue for empty Tuple() type - #102011

Merged
alexey-milovidov merged 2 commits into
masterfrom
fix-empty-tuple-popback-crash
Apr 9, 2026
Merged

alexey-milovidov merged 2 commits into
masterfrom
fix-empty-tuple-popback-crash

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Apr 8, 2026 •

Copy link
Copy Markdown
Member

throwUnexpectedDataAfterParsedValue calls popBack(1) assuming the parsed value is already committed to the column. For tuples, it is called from inside addElementSafe's impl lambda before addSize(1) commits the row. For Tuple() with no sub-columns, column.size() returns 0, so popBack(1) throws "Cannot pop 1 rows from Tuple(): there are only 0 rows".

Fix by calling addSize(1) to commit the row before throwUnexpectedDataAfterParsedValue, which will serialize it for the error message and then pop it back.

Found by the AST fuzzer: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=102000&sha=9190a5549402d12fff136f61209c5405f2aa896c&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%2C%20targeted%2C%20old_compatibility%29

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fix exception when casting a string with trailing data to empty Tuple() type.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.4.1.744

…le()` type

`throwUnexpectedDataAfterParsedValue` calls `popBack(1)` assuming the
parsed value is already committed to the column. For tuples, it is called
from inside `addElementSafe`'s impl lambda before `addSize(1)` commits
the row. For `Tuple()` with no sub-columns, `column.size()` returns 0,
so `popBack(1)` throws "Cannot pop 1 rows from Tuple(): there are only
0 rows".

Fix by calling `addSize(1)` to commit the row before
`throwUnexpectedDataAfterParsedValue`, which will serialize it for the
error message and then pop it back.

Found by the AST fuzzer:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=102000&sha=9190a5549402d12fff136f61209c5405f2aa896c&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%2C%20targeted%2C%20old_compatibility%29

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Apr 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [8ed7fb8]

Summary: ❌

job_name test_name status info comment
Stress test (arm_tsan) error

AI Review

Summary

This PR fixes an exception path in SerializationTuple::deserializeTextImpl for Tuple() when whole=true and trailing input exists. The change commits the parsed row with addSize(1) before calling throwUnexpectedDataAfterParsedValue, matching that helper’s contract (serializeText of last row, then popBack(1)). The added stateless test covers the reported reproducer (CAST('()+trash', 'Tuple()')). I found no correctness, safety, concurrency, or performance regressions in the touched code.

ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Apr 8, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

The test 02859_replicated_db_name_zookeeper is fixed in #101952

@clickhouse-gh

clickhouse-gh Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 83.90% 84.00% +0.10%
Functions 90.90% 90.90% +0.00%
Branches 76.40% 76.40% +0.00%

Changed lines: 100.00% (8/8) · Uncovered code

Full report · Diff report

alexey-milovidov added a commit that referenced this pull request Apr 8, 2026
The `stop_server` function retries `SYSTEM STOP DISTRIBUTED SENDS` up
to 30 times before calling `clickhouse stop`. When the server is
unresponsive (e.g. after a stress test), each attempt waits for the
default `receive_timeout` of 300 seconds. This means the loop can burn
30 × 300 = 9000 seconds (2.5 hours) before proceeding to actually stop
the server, consuming the entire CI job timeout.

Add `--receive_timeout=10` so each attempt fails within 10 seconds
when the server is unresponsive. Worst case the loop now takes
30 × 10 = 300 seconds instead of 9000.

Found in: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=102011&sha=8ed7fb8bcfdac4af8d2a062200b104281178981b&name_0=PR&name_1=Stress%20test%20%28arm_tsan%29
PR: #102011

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@evillique evillique self-assigned this Apr 9, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Needs #102149

@alexey-milovidov
alexey-milovidov merged commit ac4c6fc into master Apr 9, 2026
158 of 159 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-empty-tuple-popback-crash branch April 9, 2026 20:45
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants