Skip to content

Fix null pointer dereference in dictGetOrDefault with nullable key - #98460

Merged
alexey-milovidov merged 1 commit into
masterfrom
fix-dictgetordefault-nullable-short-circuit
Mar 2, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
fix-dictgetordefault-nullable-short-circuit

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Mar 2, 2026 •

Copy link
Copy Markdown
Member

Linked issues

Summary

  • Fixed UBSan error / assertion failure in dictGetOrDefault with nullable key and short-circuit evaluation
  • restoreShortCircuitColumn was passing a non-nullable dictionary result column with a Nullable type to the if function, causing executeForNullableThenElse to dereference a null pointer when extracting the null map
  • Changed to use attribute_type (non-nullable) instead of result_type (nullable) for the short-circuit merge; the nullable wrapping is already handled by the outer wrapInNullable call

Closes #97968

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=5a0a680930b0e1ff01cb47763825105938bad5b9&name_0=MasterCI&name_1=AST%20fuzzer%20%28amd_ubsan%29&name_1=AST%20fuzzer%20%28amd_ubsan%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 null pointer dereference in dictGetOrDefault when the key argument is Nullable.

🤖 Generated with Claude Code

Version info

  • Merged into: 26.3.1.258
  • Backported to: 26.2.19.32, 25.8.24.18

…and short-circuit evaluation

In `executeDictionaryRequest`, `restoreShortCircuitColumn` was using
`result_type` (Nullable) as the column type for the dictionary result,
but `dictionary->getColumn` returns a non-nullable column matching
`attribute_type`. This type/column mismatch caused the `if` function's
`executeForNullableThenElse` to call `recursiveGetNullMapFromNullable`
on a non-nullable column, which returned nullptr. The null pointer was
then passed as an argument to a recursive `executeImpl` call, triggering
UBSan error / assertion failure.

The fix uses `attribute_type` (non-nullable) instead of `result_type`
in both `getDefaultsShortCircuit` and `restoreShortCircuitColumn`.
The nullable wrapping is already handled by the outer `wrapInNullable`
call.

Closes #97968

https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=5a0a680930b0e1ff01cb47763825105938bad5b9&name_0=MasterCI&name_1=AST%20fuzzer%20%28amd_ubsan%29&name_1=AST%20fuzzer%20%28amd_ubsan%29

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Mar 2, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0e33143]

Summary: ✅

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Mar 2, 2026
-- caused UBSan error (member call on null pointer) in the `if` function because
-- restoreShortCircuitColumn passed a non-nullable column with a Nullable type to `if`.

DROP TABLE IF EXISTS regexp_dictionary_source_table;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it reproduces!

@alexey-milovidov
alexey-milovidov requested a review from nihalzp March 2, 2026 03:00
@nihalzp nihalzp self-assigned this Mar 2, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Mar 2, 2026
Merged via the queue into master with commit e06788d Mar 2, 2026
144 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-dictgetordefault-nullable-short-circuit branch March 2, 2026 06:32
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 2, 2026
@nihalzp nihalzp added the post-approved Approved, but after the PR is merged. label Mar 2, 2026
@mstetsyuk mstetsyuk added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label May 13, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label May 13, 2026
robot-ch-test-poll3 added a commit that referenced this pull request May 13, 2026
Cherry pick #98460 to 25.8: Fix null pointer dereference in dictGetOrDefault with nullable key
robot-clickhouse added a commit that referenced this pull request May 13, 2026
robot-ch-test-poll3 added a commit that referenced this pull request May 13, 2026
Cherry pick #98460 to 26.2: Fix null pointer dereference in dictGetOrDefault with nullable key
robot-clickhouse added a commit that referenced this pull request May 13, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label May 13, 2026
mstetsyuk added a commit that referenced this pull request May 18, 2026
Backport #98460 to 26.2: Fix null pointer dereference in dictGetOrDefault with nullable key
mstetsyuk added a commit that referenced this pull request May 18, 2026
Backport #98460 to 25.8: Fix null pointer dereference in dictGetOrDefault with nullable key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

post-approved Approved, but after the PR is merged. pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR 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.

Assertion `px != 0' failed (STID: 0250-2e6a)

6 participants