install: installed headers do not record the CH_* build options, so non-CMake programs get the wrong Int128 and GetCurrentEndpoint() declarations
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- cmake, cpp
- Lĩnh vực
- backend-api-design, build-system
Hướng nghiên cứu
Start with clickhouse/CMakeLists.txt:133-148 and the install rules at 184-271, then inspect clickhouse/types/bignum.h, clickhouse/client.h, and BUILD.bazel to trace how the options reach installed and in-tree consumers. Verify behavior by building and installing with the default and CH_USE_3X_API=ON settings, then compiling the issue’s standalone examples without extra flags; done means installed headers match the library declarations and Bazel and in-tree consumers retain their configured behavior.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Symptom
Two CH_* API options change declarations in public headers: CH_USE_ABSEIL_FOR_BIGNUM and CH_NON_OPTIONAL_CURRENT_ENDPOINT. cmake --install installs the headers and the libraries, but no installed file records the option values of the library.
A program that compiles against the installed headers without CMake (plain compiler, Homebrew, distro package) always sees the declarations for CH_USE_ABSEIL_FOR_BIGNUM=0 and CH_NON_OPTIONAL_CURRENT_ENDPOINT=0, whatever values the library was built with.
- Default build (
CH_USE_ABSEIL_FOR_BIGNUM=ON): every API that hasInt128/UInt128in its parameters does not link (ColumnInt128,ColumnUInt128,ColumnDecimal::Append(const Int128&),Bignum::Int128ToString, ...). - Build with
CH_USE_3X_API=ON(the build thatREADME.mdrecommends): a call toClient::GetCurrentEndpoint()compiles and links with no warning, and then crashes with a segmentation fault.
v2.6.2 does not have these options, so packages built from it are not affected. The first release that has them is affected.
Reproduction
master at 58453c2, clang 18.1, Linux x86-64, ClickHouse server 26.10.4.207 on localhost:9000.
Default build:
cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/tmp/inst
cmake --build build && cmake --install build
Reproduction program `int128.cpp` (C++, 18 lines)
#include <clickhouse/client.h>
#include <iostream>
using namespace clickhouse;
int main() {
Client client(ClientOptions().SetHost("localhost"));
client.Execute("DROP TABLE IF EXISTS t_i128");
client.Execute("CREATE TABLE t_i128 (x Int128) ENGINE = Memory");
auto col = std::make_shared<ColumnInt128>();
col->Append(Bignum::MakeInt128(1, 2)); // 2^64 + 2
col->Append(Bignum::MakeInt128(-1, 0xFFFFFFFFFFFFFFFFULL)); // -1
Block b;
b.AppendColumn("x", col);
client.Insert("t_i128", b);
client.Select("SELECT x FROM t_i128", [](const Block& blk) {
for (size_t i = 0; i < blk.GetRowCount(); ++i)
std::cout << "read: " << Bignum::Int128ToString(blk[0]->As<ColumnInt128>()->At(i)) << "\n";
});
}
clang++ -std=c++17 -I/tmp/inst/include int128.cpp \
-L/tmp/inst/lib -lclickhouse-cpp-lib -lcityhash -llz4 -lzstdstatic -labsl_int128
undefined reference to `clickhouse::ColumnVector<clickhouse::Int128>::Append(clickhouse::Int128 const&)'
undefined reference to `clickhouse::ColumnVector<clickhouse::Int128>::At(unsigned long) const'
undefined reference to `clickhouse::Bignum::Int128ToString[abi:cxx11](clickhouse::Int128)'
undefined reference to `clickhouse::ColumnVector<clickhouse::Int128>::ColumnVector()'
The library defines these functions for absl::int128; the program asks for the non-Abseil struct clickhouse::Int128.
Build with the 3.x API:
cmake -G Ninja -S . -B build-3x -DCMAKE_BUILD_TYPE=Release -DCH_USE_3X_API=ON -DCMAKE_INSTALL_PREFIX=/tmp/inst-3x
cmake --build build-3x && cmake --install build-3x
endpoint.cpp:
#include <clickhouse/client.h>
#include <iostream>
using namespace clickhouse;
int main() {
Client client(ClientOptions().SetHost("localhost").SetPort(9000));
const auto& ep = client.GetCurrentEndpoint();
std::cout << "has_value=" << ep.has_value() << std::endl;
if (ep) std::cout << "endpoint=" << ep->host << ":" << ep->port << std::endl;
}
clang++ -std=c++17 -I/tmp/inst-3x/include endpoint.cpp \
-L/tmp/inst-3x/lib -lclickhouse-cpp-lib -lcityhash -llz4 -lzstdstatic
./a.out # Segmentation fault (core dumped), exit code 139
Expected vs actual
Expected: the installed headers give the same declarations that the installed library was built with, with no extra flags. At a minimum, a mismatch must fail at build time and not at run time.
| Library build | Program | Program flags | Result |
|---|---|---|---|
| default | int128.cpp |
none | link errors (above) |
| default | int128.cpp |
-DCH_USE_ABSEIL_FOR_BIGNUM=1 + Abseil headers on the include path |
links, prints 18446744073709551618 and -1 (the server returns the same values for SELECT x FROM t_i128) |
| default | endpoint.cpp |
none | prints has_value=1, endpoint=localhost:9000 |
CH_USE_3X_API=ON |
endpoint.cpp |
none | compiles, links, segmentation fault |
CH_USE_3X_API=ON |
same call written for 3.x (Endpoint ep = client.GetCurrentEndpoint();) |
-DCH_NON_OPTIONAL_CURRENT_ENDPOINT=1 |
prints endpoint=localhost:9000 |
nm -C on libclickhouse-cpp-lib.a of the 3.x build shows only one symbol, clickhouse::Client::GetCurrentEndpoint() const, for the two declarations.
Root cause
clickhouse/CMakeLists.txt:133-148: the options reach users only as PUBLIC compile definitions ofclickhouse-cpp-lib, so only a CMake consumer of the build tree (add_subdirectory,FetchContent) gets them.clickhouse/CMakeLists.txt:184-271: the install step installs no generated header, no CMake package config and no pkg-config file.- The headers test the macros with
#if(clickhouse/types/bignum.h:7,:36,:174,:236andclickhouse/client.h:343), and in#ifan undefined macro is 0. - For
GetCurrentEndpoint(), the return type is not part of the mangled name, so the 2.x declaration (const std::optional<Endpoint>&) links to the 3.x definition (Endpointby value).
CH_MAP_BOOL_TO_UINT8 is not affected: only clickhouse/types/type_parser.cpp:45 reads it.
The fix is an installed, generated header that records the option values (also for the Bazel build). Polyglot AI can open a fix PR if a maintainer assigns this issue to @polyglotAI-bot.
Related
- #105 and #418 (CMake package config files): a package config helps only
find_packageusers, not programs without CMake. - #284 (Abseil headers are not installed): a separate gap. With
-DCH_USE_ABSEIL_FOR_BIGNUM=1, the installedtypes/bignum.hincludesabsl/numeric/int128.h, which the install does not supply.
Classification: impact: Stability · area: Environment (install layout, CH_* options)
Found by automated analysis (Polyglot AI) while working on #597. Verified against a live server.
- Ngôn ngữ chính
- C
- Star
- 388
- Fork
- 220
- Merge trung bình
- 1 ngày 25 phút
- Pull request đã merge (30 ngày)
- 16
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ClickHouse/clickhouse-cpp
-
bug data-types
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
ClickHouse/clickhouse-cpp#645 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug queries
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
ClickHouse/clickhouse-cpp#644 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug data-types native-format
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
ClickHouse/clickhouse-cpp#643 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug connectivity native-protocol
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
ClickHouse/clickhouse-cpp#638 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Core SQL test harness: ParseSetAssignments does not skip comments inside SETCó thể đã có người làm @puretechteam đã nhận 12 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
ClickHouse/clickhouse-cpp#626 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của ClickHouse/clickhouse-cpp
Issue tương tự
-
CF_CFDP_S_SendFileData computes the file checksum from the SB buffer after CFE_SB_TransmitBufferĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
389ds/389-ds-base#8251 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100