Repository navigation
Fix UBSan null deref in ThreadStatus::flushUntrackedMemory - #104253
Conversation
`flushUntrackedMemory` is a member function of `ThreadStatus` and the existing logic on the surrounding lines accesses the member `untracked_memory` directly (line 238 reads it, line 243 zeroes it). Line 242 was reading `current_thread->untracked_memory` instead; in the typical case `current_thread == this` so the value is the same, but when `current_thread` is null (e.g. before TLS is set or inside paths where `this != current_thread`) UBSan flags a null pointer dereference. Use the member directly, matching the read/write of `untracked_memory` on the lines around it. Found by `function_prop_fuzzer` unit test in CI: /ClickHouse/src/Common/ThreadStatus.cpp:242:54: runtime error: member access within null pointer of type 'ThreadStatus' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /ClickHouse/src/Common/ThreadStatus.cpp:242:54 Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104136&sha=latest&name_0=PR&name_1=Unit+tests+%28asan_ubsan%2C+function_prop_fuzzer%29 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Workflow [PR], commit [a4ae04d] Summary: ❌
AI ReviewSummaryThis PR fixes undefined behavior in ClickHouse Rules
Final Verdict
|
LLVM Coverage Report
Changed lines: 100.00% (5/5) | lost baseline coverage: 1 line(s) · Uncovered code |
|
@groeneai, remove (or, optionally, fix) failed RabbitMQ tests and send a PR. Tag the author who tried to resurrect RabbitMQ tests recently, as it was a bad idea. |
|
@alexey-milovidov — fix PR up at #104273. Removed cc @fm4v (restored the |
Per the bot review on PR ClickHouse#104273, replaces the wholesale deletion of `tests/integration/test_storage_rabbitmq/test_shutdown.py` with `@pytest.mark.skip` decorators on the three flaky tests, preserving the test bodies for future stabilization or re-enable: - `test_shutdown_rabbitmq_with_materialized_view` - `test_idle_loop_shutdown_completes_promptly` - `test_rabbitmq_virtual_column_table` The fourth test in the file (`test_attach_detach_rabbitmq_with_materialized_view`) remains marked as `@pytest.mark.skip` for the existing data-race reason. This complies with the ClickHouse review rule that test coverage should not be removed; flaky tests should be quarantined with an explicit tracking link rather than deleted wholesale. Each skip reason links to PR ClickHouse#104253 (the source of @alexey-milovidov's directive) and PR ClickHouse#104273 (this fix) for context and traceability. Per directive on ClickHouse#104253 and bot review on ClickHouse#104273
16806ee
The three tests in `tests/integration/test_storage_rabbitmq/test_shutdown.py` have been failing in CI: - `test_shutdown_rabbitmq_with_materialized_view` - `test_idle_loop_shutdown_completes_promptly` - `test_rabbitmq_virtual_column_table` The fourth test in the file (`test_attach_detach_rabbitmq_with_materialized_view`) was already marked as `pytest.mark.skip` due to a known data race in `StorageRabbitMQ` shutdown. Per @alexey-milovidov's directive on PR ClickHouse#104253: > "remove (or, optionally, fix) failed RabbitMQ tests and send a PR. > Tag the author who tried to resurrect RabbitMQ tests recently, > as it was a bad idea." Removing the entire `test_shutdown.py` file rather than skipping its contents, since the only non-skipped tests in it are flaky and the remaining test was already non-runnable. Context: - The `test_storage_rabbitmq` suite was originally removed in PR ClickHouse#93107 due to chronic flakiness, then restored in PR ClickHouse#101967 (2026-04-07). - `test_shutdown.py` was added shortly after in PR ClickHouse#102711 (2026-04-21). cc @alexey-milovidov @fm4v @jaapieaapie1
…bucket Tests reading from https://clickhouse-public-datasets.s3.*.amazonaws.com/ can flake when AWS returns a transient retryable 5xx mid-stream: the request is retried successfully, but the <Error> line emitted by PocoHTTPClient is captured into *.stderr-fatal via --client_logs_file, and the runner fails the test with "having stderror". Worst-affected is 03988_cached_read_big_at, which streams a 14 GiB parquet with max_download_threads = 1. Raise send_logs_level to fatal for the four tests that read this bucket and have no other guard. Mirrors the precedent in 03271_s3_table_function_asterisk_glob.sql and ~130 other stateless tests. Sample failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104253&sha=a4ae04d39170c4d2d821aedb448667867bea5497&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20sequential%29 PR: #104253 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
flushUntrackedMemoryis a member function ofThreadStatusand the surrounding lines access the memberuntracked_memorydirectly. The new local on line 242 was readingcurrent_thread->untracked_memoryinstead — in the typical casecurrent_thread == thisso the value is the same, but whencurrent_threadis null (e.g. before TLS is set or inside paths wherethis != current_thread) UBSan flags a null pointer dereference. Use the member directly, matching the read/write ofuntracked_memoryon the lines around it.Reported by the
function_prop_fuzzerunit test:CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104136&sha=latest&name_0=PR&name_1=Unit+tests+%28asan_ubsan%2C+function_prop_fuzzer%29
cc @azat
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Documentation entry for user-facing changes