Repository navigation
Fix crash in MsgPack schema inference for a map with a nil or empty key - #127281
alexey-milovidov merged 2 commits into
Conversation
…rst key
`MsgPackSchemaReader::getDataType` returns `nullptr` when it cannot infer a
type from a value (nil, an empty array or map, or a container of such values).
In the MAP case the key type was passed to `removeNullable` before the
`key_type && value_type` check, so a map whose first key is nil, an empty
array or an empty map (for example the 3-byte input `\x81\xc0\x01`, `{nil: 1}`)
dereferenced a null type and crashed the server during schema inference.
Apply `removeNullable` only after the null check, so an untypeable key follows
the same "cannot infer" path as an untypeable value: the column type is taken
from a later row, or schema inference fails with ONLY_NULLS_WHILE_READING_SCHEMA
(wrapped in CANNOT_EXTRACT_TABLE_STRUCTURE) and can be overridden with
`schema_inference_hints`.
Found by the AST fuzzer in Stress test (amd_msan), STID 1719-3b0f.
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; 0 findings). 1 nit total.
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261021-212600 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261021-205200 |
|
cc @vitlibar @al13n321, could you review this and add the |
|
Workflow [PR], commit [a8fba07] Summary: ✅
AI ReviewSummaryPR #127281 fixes a null pointer dereference in Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 10 s compile time in total, 7 of them have a recent master baseline. |
CI finish ledger - 95472ddEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
The two Session id: cron:our-pr-ci-monitor:20261022-023003 |
Backport #127281 to 26.10: Fix crash in MsgPack schema inference for a map with a nil or empty key
Backport #127281 to 26.9: Fix crash in MsgPack schema inference for a map with a nil or empty key
Backport #127281 to 26.8: Fix crash in MsgPack schema inference for a map with a nil or empty key
… map with a nil or empty key
Backport #127281 to 26.7: Fix crash in MsgPack schema inference for a map with a nil or empty key
Backport #127281 to 26.3: Fix crash in MsgPack schema inference for a map with a nil or empty key
… map with a nil or empty key
…ence for a map with a nil or empty key
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a crash in
MsgPackschema inference when the first key of a map isnil, an empty array or an empty map. Such a column is now reported as impossible to infer, like anilvalue, and its type can be given withschema_inference_hints.Description
On 26.3 and later, schema inference over a MsgPack map whose first key is
nilor an empty array/map (for exampleDESC format(MsgPack, '\x81\xc0\x01') SETTINGS input_format_msgpack_number_of_columns = 1) crashes the server with a null pointer dereference. Measured on the official 26.3.42.3 and 26.8.18.2 images and on master. Anyfile()/url()/s3()/format()inference over such data reaches it.Found by the AST fuzzer in Stress test (amd_msan), STID 1719-3b0f: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=214443bbdffd8fee15e5a6ad62b3e07602a2b437&name_0=MasterCI&name_1=Stress%20test%20%28amd_msan%29. No related open issue found.
Root cause:
MsgPackSchemaReader::getDataTypereturnsnullptrfor a value it cannot type. In theMAPcase the key type went throughremoveNullablebefore thekey_type && value_typecheck, andremoveNullabledereferences its argument.Change:
removeNullableis applied only after the null check, so an untypeable key behaves like an untypeable value: the type comes from a later row, or inference fails withCANNOT_EXTRACT_TABLE_STRUCTURE(ONLY_NULLS_WHILE_READING_SCHEMA). Inputs that worked before infer the same type.Validation: the new test
05441_msgpack_schema_inference_untypeable_map_keycovers{nil: 1},{[]: 1},{{}: 1},{{nil: 1}: 1}, inference from a later row and aschema_inference_hintsoverride. It kills an unfixed server and passes 50/50 with randomized settings on the fixed one.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/127281]
Version info
26.11.1.613-master(included in26.11and later)26.10.2.94,26.9.26.7,26.8.35.6,26.7.38.13,26.3.61.4