Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SEGV with unsupported type #384

Open
PedroTadim opened this issue Aug 29, 2024 · 6 comments
Open

SEGV with unsupported type #384

PedroTadim opened this issue Aug 29, 2024 · 6 comments
Assignees
Labels
bug Something isn't working need-info Awaiting extra info from community/issue creator

Comments

@PedroTadim
Copy link

PedroTadim commented Aug 29, 2024

Compile, link and run this modified example program, while running the input from this file: issue.zip

#include <iostream>
#include <fstream>

#include <clickhouse/client.h>

using namespace clickhouse;

int main()
{
	Client client(ClientOptions().SetHost("localhost"));

	std::ifstream infile("<path to file>");
	std::string line;
	while (std::getline(infile, line))
	{
		try {
			client.Execute(line);
		} catch (const std::exception & e) {
		}
	}
	return 0;
}

A SEGV will happen:

Program received signal SIGSEGV, Segmentation fault.
0x00005555556c2a0c in clickhouse::TypeParser::Parse (this=0x7fffffffbf10, type=0x5555559b87c0) at contribs/clickhouse-cpp/clickhouse/types/type_parser.cpp:186
186	                type_ = open_elements_.top();
(gdb) bt
#0  0x00005555556c2a0c in clickhouse::TypeParser::Parse (this=0x7fffffffbf10, type=0x5555559b87c0) at contribs/clickhouse-cpp/clickhouse/types/type_parser.cpp:186
#1  0x00005555556c330c in clickhouse::ParseTypeName (type_name="es=16, max_dynamic_paths=256))", '\000' <repeats 16 times>, "\200\002\000\001\000\000\000\000\000\000\000 \002\026Array(Nullable(Int64))\\Tuple(Nullable(String), Nulla")
    at contribs/clickhouse-cpp/clickhouse/types/type_parser.cpp:305
#2  0x0000555555650305 in clickhouse::CreateColumnByType (
    type_name="es=16, max_dynamic_paths=256))", '\000' <repeats 16 times>, "\200\002\000\001\000\000\000\000\000\000\000 \002\026Array(Nullable(Int64))\\Tuple(Nullable(String), Nulla", settings=...)
    at contribs/clickhouse-cpp/clickhouse/columns/factory.cpp:268
#3  0x0000555555635184 in clickhouse::Client::Impl::ReadBlock (this=0x5555559b8d80, input=..., block=0x7fffffffc120) at contribs/clickhouse-cpp/clickhouse/client.cpp:639
#4  0x0000555555635642 in clickhouse::Client::Impl::ReceiveData (this=0x5555559b8d80) at contribs/clickhouse-cpp/clickhouse/client.cpp:668
#5  0x00005555556346c1 in clickhouse::Client::Impl::ReceivePacket (this=0x5555559b8d80, server_packet=0x0) at contribs/clickhouse-cpp/clickhouse/client.cpp:451
#6  0x0000555555633672 in clickhouse::Client::Impl::ExecuteQuery (this=0x5555559b8d80, query=...) at contribs/clickhouse-cpp/clickhouse/client.cpp:284
#7  0x0000555555637984 in clickhouse::Client::Execute (this=0x7fffffffcbd0, query=...) at contribs/clickhouse-cpp/clickhouse/client.cpp:1010

A proper error message should be thrown when a type is not supported instead of crashing

@PedroTadim PedroTadim added the bug Something isn't working label Aug 29, 2024
@Enmk
Copy link
Collaborator

Enmk commented Sep 2, 2024

Hi @PedroTadim, thank you for a report!

I can't reproduce the crash, what are the versions of the clickhouse-cpp and of the clickhouse server? How did you built the clickhouse-cpp?

@Enmk Enmk self-assigned this Sep 2, 2024
@Enmk Enmk added the need-info Awaiting extra info from community/issue creator label Sep 2, 2024
@PedroTadim
Copy link
Author

Hello, I built the latest clickhouse binaries from source with this cmake command:

cmake -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DENABLE_LIBRARIES=1 -DENABLE_TESTS=0 -DENABLE_UTILS=0 -DENABLE_THINLTO=0 -DENABLE_NURAFT=1 -DENABLE_SIMDJSON=1 -DENABLE_JEMALLOC=0 -DENABLE_LIBURING=1 -DENABLE_YAML_CPP=1 -DCMAKE_BUILD_TYPE=Debug -DSANITIZE=address

@Enmk
Copy link
Collaborator

Enmk commented Sep 2, 2024

Ok, latest means master ? hm... is there a reason why you haven't used an pre-existing release (official or alternative) ?
Also, what is the clickhouse-cpp version you are using and how did you build it?

I've tested clickhouse-cpp master against clickhouse/clickhouse-server docker images ver 23.8, 24.3, and 24.8 on x86_64 and wasn't able to reproduce the issue

@PedroTadim
Copy link
Author

I updated the example to read input from the given file

@PedroTadim
Copy link
Author

I compiled both clickhouse-cpp and clickhouse/clickhouse-server from master on debug

@PedroTadim
Copy link
Author

Updated example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working need-info Awaiting extra info from community/issue creator
Projects
None yet
Development

No branches or pull requests

2 participants