Segfault caused by outputstream being null.
rtcote opened this issue · 4 comments
It appears that the output stream is getting set to a nullptr. Was running v2.5.0 of the client. When I rolled-back to v2.4.0 of the client, the issue is no longer present. This issue shows up the first time I call Client::Insert() for each client instance. It's not clear what I am doing on the application side to cause this. Any thoughts as to how I can debug this?
My client is configured in the following manner:
m_client = std::make_shared<clickhouse::Client>(
clickhouse::ClientOptions().SetHost(host) // a hostname
.SetPingBeforeQuery(client_config.ping_before_query) // true
.SetSendRetries(client_config.send_retries) // 0
.SetCompressionMethod(compression_method) // None
.SetRetryTimeout(std::chrono::seconds(client_config.retry_timeout_sec)) // 0
.TcpKeepAlive(client_config.tcp_keep_alive) // true
.SetConnectionConnectTimeout(std::chrono::seconds(client_config.connect_timeout_sec)) // 5
.SetConnectionRecvTimeout(std::chrono::milliseconds(client_config.recv_timeout_ms)) // 1000000
.SetConnectionSendTimeout(std::chrono::milliseconds(client_config.send_timeout_ms)) // 60000
);
Stack trace and gdb debugging
Thread 5 "rte-worker-8" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffc5c87000 (LWP 136)]
clickhouse::WireFormat::WriteAll (output=..., buf=<optimized out>, len=1) at /git/submodules/clickhouse-cpp/clickhouse/base/wire_format.cpp:36
36 /git/submodules/clickhouse-cpp/clickhouse/base/wire_format.cpp: No such file or directory.
(gdb) bt
#0 clickhouse::WireFormat::WriteAll (output=..., buf=<optimized out>, len=1) at /git/submodules/clickhouse-cpp/clickhouse/base/wire_format.cpp:36
#1 0x0000555559dce5c1 in clickhouse::WireFormat::WriteVarint64 (output=..., value=<optimized out>, value@entry=1) at /git/submodules/clickhouse-cpp/clickhouse/base/wire_format.cpp:86
#2 0x0000555559dc7fcf in clickhouse::WireFormat::WriteUInt64 (value=1, output=...) at /git/submodules/clickhouse-cpp/clickhouse/base/wire_format.h:74
#3 clickhouse::Client::Impl::SendQuery (this=0x7fffb8001460, query=...) at /git/submodules/clickhouse-cpp/clickhouse/client.cpp:720
#4 0x0000555559dc9477 in clickhouse::Client::Impl::Insert (this=0x7fffb8001460, table_name=..., query_id="", block=...) at /git/submodules/clickhouse-cpp/clickhouse/client.cpp:311
(gdb) frame 0
#0 clickhouse::WireFormat::WriteAll (output=..., buf=<optimized out>, len=1) at /git/submodules/clickhouse-cpp/clickhouse/base/wire_format.cpp:36
36 /git/submodules/clickhouse-cpp/clickhouse/base/wire_format.cpp: No such file or directory.
(gdb) info locals
original_len = 1
p = 0x7fffc5c2cb9e "\001"
written_previously = 1
(gdb) p output
$4 = (clickhouse::OutputStream &) <error reading variable>
(gdb) p &output
$5 = (clickhouse::OutputStream *) 0x0
Hi @rtcote ! Thank you for a report, investigating. In the mean time, could you please provide a minimal viable example of the query that causes this?
Also, please provide the following deatils:
- OS
- ClickHouse server version
- build options of the clickhouse-cpp (specifically, what are cmake-configure-time options:
BUILD_SHARED_LIBS
,WITH_OPENSSL
,WITH_SYSTEM_ABSEIL
,WITH_SYSTEM_LZ4
,WITH_SYSTEM_CITYHASH
)
Hi @Enmk,
Info below:
- OS: Ubuntu 20.04.6 LTS
- Clickhouse version: 22.8.15 revision 54460
- build options: are the defaults without options being added or modified
Insert statement from debugger with 5921 rows at the time of the crash. The data tends to have low cardinality for these tests.
"INSERT INTO databasename.tablename ( `f1`,`f2`,`f3`,`f4`,`f5`,`f6`,`f7`,`f8`,`f9`,`f10`,`f11`,`f12`,`f13`,`f14`,`f15`,`f16`,`f17`,`f18`,`f19`,`f20`,`f21`,`f22`,`f23`,`f24` ) VALUES"
Table schema
┌─name────────────────────┬─type─────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐
│ f01 │ UInt8 │ │ │ │ T64, LZ4 │ │
│ f02 │ UInt16 │ │ │ │ T64, LZ4 │ │
│ f03 │ UInt64 │ │ │ │ DoubleDelta, LZ4 │ │
│ f04 │ UInt8 │ │ │ │ T64, LZ4 │ │
│ f05 │ UInt64 │ │ │ │ DoubleDelta, LZ4 │ │
│ f06 │ UInt64 │ │ │ │ DoubleDelta, LZ4 │ │
│ f07 │ UInt8 │ │ │ │ T64, LZ4 │ │
│ f08 │ UInt16 │ │ │ │ T64, LZ4 │ │
│ f09 │ UInt64 │ │ │ │ DoubleDelta, LZ4 │ │
│ f10 │ UInt8 │ │ │ │ T64, LZ4 │ │
│ f11 │ Int64 │ │ │ │ T64, LZ4 │ │
│ f12 │ UInt16 │ │ │ │ T64, LZ4 │ │
│ f13 │ UInt64 │ │ │ │ T64, LZ4 │ │
│ f14 │ Int64 │ │ │ │ T64, LZ4 │ │
│ f15 │ UInt16 │ │ │ │ T64, LZ4 │ │
│ f16 │ UInt32 │ │ │ │ T64, LZ4 │ │
│ f17 │ Int64 │ │ │ │ T64, LZ4 │ │
│ f18 │ UInt32 │ │ │ │ T64, LZ4 │ │
│ f19 │ Int32 │ │ │ │ T64, LZ4 │ │
│ f20 │ UInt32 │ │ │ │ T64, LZ4 │ │
│ f21 │ UInt32 │ │ │ │ T64, LZ4 │ │
│ f22 │ UInt32 │ │ │ │ T64, LZ4 │ │
│ f23 │ DateTime │ │ │ │ DoubleDelta, LZ4 │ │
│ f24 │ DateTime │ │ │ │ DoubleDelta, LZ4 │ │
└─────────────────────────┴──────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘