From 30c0b0d5325b158ab0930b9e7821ff6c2ffc0ac0 Mon Sep 17 00:00:00 2001 From: Boris Tyshkevich Date: Mon, 27 Apr 2026 23:55:54 +0200 Subject: [PATCH] Fix Client::login segfault on empty hosts_and_ports (#103603) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Client::login dereferenced hosts_and_ports.front() unconditionally, but that vector is populated only from explicit --host. When the host comes from --connection or top-level in the client config, the vector stays empty and the front() call SIGSEGVs in Client::main before any OAuth round-trip happens. Fall back to getClientConfiguration().getString("host", "") when the vector is empty; that value is always set by this point because initialize() resolves it from --host / --connection / config / env. This is the upstream issue reported at https://github.com/ClickHouse/ClickHouse/issues/103603 — same crash, same fix. Co-Authored-By: Claude Opus 4.7 (1M context) Signed-off-by: Boris Tyshkevich --- programs/client/Client.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/programs/client/Client.cpp b/programs/client/Client.cpp index e8b22071f43f..83ad7c7addf7 100644 --- a/programs/client/Client.cpp +++ b/programs/client/Client.cpp @@ -451,7 +451,14 @@ catch (...) #if USE_JWT_CPP && USE_SSL void Client::login() { - std::string host = hosts_and_ports.front().host; + /// hosts_and_ports is populated only from explicit --host. When the host + /// came from --connection or top-level in config, it stays empty, + /// and hosts_and_ports.front() dereferences a null vector slot → SIGSEGV + /// in Client::main (upstream issue #103603). Fall back to the + /// config-derived value, which always exists by this point. + std::string host = !hosts_and_ports.empty() + ? hosts_and_ports.front().host + : getClientConfiguration().getString("host", ""); std::string auth_url = getClientConfiguration().getString("oauth-url", ""); std::string client_id = getClientConfiguration().getString("oauth-client-id", ""); std::string audience = getClientConfiguration().getString("oauth-audience", "");