From af9910b5183cab129a77d3ff603817cca879dbdc Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Thu, 27 Jan 2022 13:45:20 +0300 Subject: [PATCH] Fix leak of demangle result (for opentelementry) LSan found [1]: Direct leak of 5170176 byte(s) in 5049 object(s) allocated from: 0 0xc598edd in malloc (/usr/bin/clickhouse+0xc598edd) 1 0x39679739 in (anonymous namespace)::itanium_demangle::initializeOutputStream(char*, unsigned long*, (anonymous namespace)::itanium_demangle::OutputStream&, unsigned long) obj-x86_64-linux-gnu/../contrib/libcxxabi/src/demangle/Utility.h:178:31 2 0x39679739 in __cxa_demangle obj-x86_64-linux-gnu/../contrib/libcxxabi/src/cxa_demangle.cpp:351:13 3 0x28f6f3ed in DB::executeQueryImpl(char const*, char const*, std::__1::shared_ptr, bool, DB::QueryProcessingStage::Enum, DB::ReadBuffer*) obj-x86_64-linux-gnu/../src/Interpreters/executeQuery.cpp:662:44 [1]: https://s3.amazonaws.com/clickhouse-test-reports/33957/08f4f45fd9da923ae3e3fdd8a527c297d35247eb/stress_test__address__actions_.html Signed-off-by: Azat Khuzhin --- src/Interpreters/executeQuery.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Interpreters/executeQuery.cpp b/src/Interpreters/executeQuery.cpp index 870e01d3b5c..f40d35e970b 100644 --- a/src/Interpreters/executeQuery.cpp +++ b/src/Interpreters/executeQuery.cpp @@ -61,6 +61,7 @@ #include #include +#include #include @@ -659,7 +660,7 @@ static std::tuple executeQueryImpl( if (context->query_trace_context.trace_id != UUID()) { auto * raw_interpreter_ptr = interpreter.get(); - std::string class_name(abi::__cxa_demangle(typeid(*raw_interpreter_ptr).name(), nullptr, nullptr, nullptr)); + std::string class_name(demangle(typeid(*raw_interpreter_ptr).name())); span = std::make_unique(class_name + "::execute()"); } res = interpreter->execute();