Skip to content

Fix NULL dereference in fetchSQLiteTableStructure() on error#84149

Merged
azat merged 1 commit intoClickHouse:masterfrom
azat:sqlite-fetch-struct-fix
Jul 21, 2025
Merged

Fix NULL dereference in fetchSQLiteTableStructure() on error#84149
azat merged 1 commit intoClickHouse:masterfrom
azat:sqlite-fetch-struct-fix

Conversation

@azat
Copy link
Copy Markdown
Member

@azat azat commented Jul 21, 2025

CI found 1:

BaseDaemon: Address: NULL pointer. Access: read. Address not mapped to object.
BaseDaemon: Stack trace: 0x00007f33b5ad70bd 0x000055ce7dfba161 0x000055ce89bb8061 0x000055ce8d2c1e18 0x000055ce8d2c1967 0x000055ce8d2c43a4 0x000055ce8d2c31e5 0x000055ce8d0434bb 0x000055ce8a883b5d 0x000055ce8a87c7b0 0x000055ce8a88971c 0x000055ce8ac3c88d 0x000055ce8ac3fd67 0x000055ce8a78351c 0x000055ce8a78160c 0x000055ce8a77ec62 0x000055ce8a777eff 0x000055ce8a793c26 0x000055ce84acc360 0x000055ce84ad217b 0x00007f33b59b9ac3 0x00007f33b5a4b850
BaseDaemon: 3. ? @ 0x00000000001b20bd
BaseDaemon: 4. String::basic_string[abi:ne190107]<0>(char const*) @ 0x0000000008e0b161
BaseDaemon: 5. ./ci/tmp/build/./src/Databases/SQLite/fetchSQLiteTableStructure.cpp:89: DB::fetchSQLiteTableStructure(sqlite3*, String const&) @ 0x0000000014a09061
BaseDaemon: 6. ./ci/tmp/build/./src/Storages/StorageSQLite.cpp:85: DB::StorageSQLite::getTableStructureFromData(std::shared_ptr<sqlite3> const&, String const&) @ 0x0000000018112e18
BaseDaemon: 7. ./ci/tmp/build/./src/Storages/StorageSQLite.cpp:69: DB::StorageSQLite::StorageSQLite(DB::StorageID const&, std::shared_ptr<sqlite3>, String const&, String const&, DB::ColumnsDescription const&, DB::ConstraintsDescription const&, String const&, std::shared_ptr<DB::Context const>) @ 0x0000000018112967

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

CI found [1]:

    BaseDaemon: Address: NULL pointer. Access: read. Address not mapped to object.
    BaseDaemon: Stack trace: 0x00007f33b5ad70bd 0x000055ce7dfba161 0x000055ce89bb8061 0x000055ce8d2c1e18 0x000055ce8d2c1967 0x000055ce8d2c43a4 0x000055ce8d2c31e5 0x000055ce8d0434bb 0x000055ce8a883b5d 0x000055ce8a87c7b0 0x000055ce8a88971c 0x000055ce8ac3c88d 0x000055ce8ac3fd67 0x000055ce8a78351c 0x000055ce8a78160c 0x000055ce8a77ec62 0x000055ce8a777eff 0x000055ce8a793c26 0x000055ce84acc360 0x000055ce84ad217b 0x00007f33b59b9ac3 0x00007f33b5a4b850
    BaseDaemon: 3. ? @ 0x00000000001b20bd
    BaseDaemon: 4. String::basic_string[abi:ne190107]<0>(char const*) @ 0x0000000008e0b161
    BaseDaemon: 5. ./ci/tmp/build/./src/Databases/SQLite/fetchSQLiteTableStructure.cpp:89: DB::fetchSQLiteTableStructure(sqlite3*, String const&) @ 0x0000000014a09061
    BaseDaemon: 6. ./ci/tmp/build/./src/Storages/StorageSQLite.cpp:85: DB::StorageSQLite::getTableStructureFromData(std::shared_ptr<sqlite3> const&, String const&) @ 0x0000000018112e18
    BaseDaemon: 7. ./ci/tmp/build/./src/Storages/StorageSQLite.cpp:69: DB::StorageSQLite::StorageSQLite(DB::StorageID const&, std::shared_ptr<sqlite3>, String const&, String const&, DB::ColumnsDescription const&, DB::ConstraintsDescription const&, String const&, std::shared_ptr<DB::Context const>) @ 0x0000000018112967

  [1]: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=84112&sha=d21d30e30689009ff84e4339423bac1dccf950a2&name_0=PR&name_1=Stateless%20tests%20%28amd_binary%2C%20old%20analyzer%2C%20s3%20storage%2C%20DatabaseReplicated%2C%20sequential%29
@azat azat added the 🍃 green ci 🌿 Fixing flaky tests in CI label Jul 21, 2025
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Jul 21, 2025

Workflow [PR], commit [ecdfcb0]

Summary:

job_name test_name status info comment
Stateless tests (amd_binary, ParallelReplicas, s3 storage, parallel) failure
03376_bloom_filter_has_const_array FAIL

@serxa serxa self-assigned this Jul 21, 2025
@clickhouse-gh clickhouse-gh bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Jul 21, 2025
@serxa serxa requested a review from Copilot July 21, 2025 15:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a critical NULL pointer dereference vulnerability in the fetchSQLiteTableStructure() function. The CI detected a segmentation fault where the code was attempting to construct a String object from a potentially NULL err_message pointer returned by SQLite operations.

  • Adds NULL pointer check before constructing error message string
  • Provides fallback error message when SQLite doesn't return specific error details

@azat azat enabled auto-merge July 21, 2025 15:27
@azat
Copy link
Copy Markdown
Member Author

azat commented Jul 21, 2025

Stateless tests (amd_binary, ParallelReplicas, s3 storage, parallel) — Failed: 1, Passed: 6725, Skipped: 758

  • 03376_bloom_filter_has_const_array - will be reverted

@azat azat added this pull request to the merge queue Jul 21, 2025
Merged via the queue into ClickHouse:master with commit f92a35a Jul 21, 2025
122 of 124 checks passed
@azat azat deleted the sqlite-fetch-struct-fix branch July 21, 2025 19:48
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🍃 green ci 🌿 Fixing flaky tests in CI pr-not-for-changelog This PR should not be mentioned in the changelog 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.

4 participants