Repository navigation
Fix null-pointer dereference in canSkipConversionToNullable during mutation - #106654
alexey-milovidov wants to merge 2 commits into
Conversation
`canSkipConversionToNullable` dereferenced the result of
`metadata_snapshot->getColumns().tryGet(command.column_name)` without a null
check:
const auto * column_desc = metadata_snapshot->getColumns().tryGet(command.column_name);
if (!column_desc->statistics.empty())
return false;
`tryGet` returns `nullptr` when the column name is not present in the
metadata snapshot, so this segfaulted (`SIGSEGV`, access at offset `0x90`)
in `MutateTask::prepare` during a mutation. Add the missing null check,
conservatively refusing to skip the conversion when the column cannot be
found — matching the existing null-check at the other
`tryGet(command.column_name)` site in `MutateTask.cpp`.
Found by a stress test (`Stress test (arm_msan)`) on
#101039 :
the crash is in `ColumnStatisticsDescription::empty` ->
`canSkipConversionToNullable` -> `canSkipMutationCommandForPart` ->
`MutateTask::prepare`, unrelated to that PR's changes.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Workflow [PR], commit [be9e06c] Summary: ❌
AI ReviewSummaryThis PR adds a defensive null check in Final VerdictStatus: ✅ Approve |
|
@groeneai, fix |
|
Picked this up. Sent the fix in #106664 — gates the new |
|
This PR seems to be a duplicate of #105917 |
- src/.../MergingSortedAlgorithm.cpp: collapse the 6-line gate explanation next to `if (apply_virtual_row_conversions)` into a one-line invariant note. The full root-cause explanation (Union of read-in-order subtrees, per-source conversions, default-zero fallback in setVirtualRow) lives in the PR description and the original commit message of 28c0151. - tests/.../04323_virtual_row_two_shards_pk_alias.sql: collapse the 11-line header comment into a one-line "Regression test for STID 2651-3359 (debug assertion added in ClickHouse#106565)" - test name and the SET list make the purpose self-evident, full context lives in ClickHouse#106664. Also corrects the outdated test-file PR reference noted by clickhouse-gh inline (ClickHouse#106565 introduced the assertion; the test reproduces the assertion path covered by this PR, not ClickHouse#106654 which is unrelated). No code-behavior changes. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…-statistics-deref
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 5/5 (100.00%) | Lost baseline coverage: none · Uncovered code |
|
#105917 is going to be merged. Closing this PR as a duplicate |
canSkipConversionToNullableinMutateTask.cppdereferenced the result ofmetadata_snapshot->getColumns().tryGet(command.column_name)without checking fornullptr.tryGetreturnsnullptrwhen the column name is not present in the metadata snapshot, which segfaulted (SIGSEGV, access at offset0x90) insideColumnStatisticsDescription::emptyduringMutateTask::preparefor a mutation.Added the missing null check, conservatively refusing to skip the conversion when the column cannot be found — mirroring the existing null check at the other
tryGet(command.column_name)site a few hundred lines above in the same file.getColumns().tryGetis a top-level-only lookup (no subcolumns, seeColumnsDescription::tryGet), whilepart->tryGetColumn(command.column_name)resolves subcolumns and dynamic subcolumns. So aREAD_COLUMNcommand can legitimately reach this site with acolumn_namethat is present in the part (e.g. a subcolumn, or a column that has left the latest metadata snapshot while a part at an earlier mutation version still carries it) but absent frommetadata_snapshot. A deterministic single-session reproduction is impractical —DROP/RENAMEof a column with an unfinished mutation is explicitly rejected, so this only surfaced under the random-ALTERstress workload.Found by a stress test (
Stress test (arm_msan)) on #101039 — CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=101039&sha=243b4e230a2da217eab231b78ecc3ed985ffbcbe&name_0=PR&name_1=Stress%20test%20%28arm_msan%29 (the crash is unrelated to that PR's changes —MutateTask.cppis not touched there). Stack:ColumnStatisticsDescription::empty→canSkipConversionToNullable→canSkipMutationCommandForPart→MutateTask::prepare.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix a possible crash (null-pointer dereference) during a mutation when skipping the conversion of a column to
Nullable.Documentation entry for user-facing changes