Skip to content

fix: posbile incorrect reference to unintialized key_index variable - #77305

Merged
hanfei1991 merged 1 commit into
ClickHouse:masterfrom
wxybear:fix-use-uninitialized-key-index
Mar 10, 2025
Merged

hanfei1991 merged 1 commit into
ClickHouse:masterfrom
wxybear:fix-use-uninitialized-key-index

Conversation

@wxybear

@wxybear wxybear commented Mar 7, 2025

Copy link
Copy Markdown
Contributor

fix #77145

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 to CHANGELOG.md):

fix posbile incorrect reference to unintialized key_index variable, which may lead to crash in debug builds
(This uninitialized reference won't cause issues in release builds because subsequent code are likely to throw errors.)

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@wxybear

wxybear commented Mar 7, 2025

Copy link
Copy Markdown
Contributor Author

it's hard to test... because the crash is currently in debug builds, the behavior is the same before and after modifying the code in release mode

@hanfei1991 hanfei1991 self-assigned this Mar 7, 2025
@hanfei1991 hanfei1991 added pr-bugfix Pull request with bugfix, not backported by default can be tested Allows running workflows for external contributors labels Mar 10, 2025
@clickhouse-gh

clickhouse-gh Bot commented Mar 10, 2025

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [94196c5]

@hanfei1991

Copy link
Copy Markdown
Member

@wxybear why the behavior is the same before and after modifying the code in release mode? As I understand we will not return CANNOT_PARSE_INPUT_ASSERTION_FAILED error in this case.

@wxybear

wxybear commented Mar 10, 2025 •

Copy link
Copy Markdown
Contributor Author

@hanfei1991 When running SELECT 1 FROM t0 PREWHERE toNullable('V0') = c0 in release builds, this code(reference to unintialized key_index variable) is undefined behavior and does not hit the assert in optional lib. When the following code is run, it will try to convert the 'V0' to the type of c0 (Map), so an exception is thrown. Even if I fix this undefined behavior, the same exception will be thrown later.

@hanfei1991
hanfei1991 added this pull request to the merge queue Mar 10, 2025
Merged via the queue into ClickHouse:master with commit c1c53bb Mar 10, 2025
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 10, 2025
@PedroTadim

Copy link
Copy Markdown
Member

You forgot to add a test :/

@wxybear

wxybear commented Mar 13, 2025

Copy link
Copy Markdown
Contributor Author

@PedroTadim I'd like to clarify that this pr does not change the release builds' behaivior, it just removes undefined behavior so that debug builds will no longer crash due to assert.. So it's hard to test...

it's hard to test... because the crash is currently in debug builds, the behavior is the same before and after modifying the code in release mode

clickgapai pushed a commit to clickgapai/ClickHouse that referenced this pull request Apr 3, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

Hi @wxybear @hanfei1991 — while reviewing this PR I found the following:

Could you review the test PR and add the can be tested label if it looks good?
Happy to discuss — close anything that's wrong or already addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors 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.

Bloom filter assertion error

5 participants