Skip to content

Fix heap-use-after-free in GraphiteRollupSortedAlgorithm - #98609

Merged
Algunenano merged 1 commit into
ClickHouse:masterfrom
Algunenano:fix-graphite-rollup-uaf
Mar 6, 2026
Merged

Algunenano merged 1 commit into
ClickHouse:masterfrom
Algunenano:fix-graphite-rollup-uaf

Conversation

@Algunenano

@Algunenano Algunenano commented Mar 3, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

Fix heap-use-after-free in GraphiteRollupSortedAlgorithm

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

When an exception occurs during mergeBlock with a GraphiteMergeTree table (e.g. fuzzed column types like Int128 for the Time column), the aggregate state in GraphiteRollupMergedData can be left active. On destruction, the derived class member params (owning the patterns vector with AggregateFunctionPtr) is destroyed before the base class member merged_data, whose destructor then dereferences dangling pointers into the already-freed patterns.

Fix by resetting merged_data in the derived destructor, ensuring ~GraphiteRollupMergedData runs while params is still alive.

ASan report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=98204&sha=b003cfb861b70b7461035f2ac3d5438cffefdc24&name_0=PR&name_1=AST%20fuzzer%20%28arm_asan%29
#98204

Closes #98523

Version info

  • Merged into: 26.3.1.482

When an exception occurs during `mergeBlock` with a `GraphiteMergeTree`
table (e.g. fuzzed column types like `Int128` for the `Time` column),
the aggregate state in `GraphiteRollupMergedData` can be left active.
On destruction, the derived class member `params` (owning the patterns
vector with `AggregateFunctionPtr`) is destroyed before the base class
member `merged_data`, whose destructor then dereferences dangling
pointers into the already-freed patterns.

Fix by resetting `merged_data` in the derived destructor, ensuring
`~GraphiteRollupMergedData` runs while `params` is still alive.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=98204&sha=b003cfb861b70b7461035f2ac3d5438cffefdc24&name_0=PR&name_1=AST%20fuzzer%20%28arm_asan%29

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

clickhouse-gh Bot commented Mar 3, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [bb3e34e]

Summary: ❌

job_name test_name status info comment
Integration tests (amd_msan, 1/6) failure
test_keeper_max_append_byte_size/test.py::test_keeper_max_append_byte_size FAIL cidb IGNORED

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Mar 3, 2026
@KochetovNicolai KochetovNicolai self-assigned this Mar 6, 2026
@Algunenano
Algunenano added this pull request to the merge queue Mar 6, 2026
Merged via the queue into ClickHouse:master with commit 66d5008 Mar 6, 2026
144 of 145 checks passed
@Algunenano
Algunenano deleted the fix-graphite-rollup-uaf branch March 6, 2026 18:02
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci 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.

AddressSanitizer: heap-use-after-free (STID: 1003-358c) in GraphiteRollupSortedAlgorithm

3 participants