mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-16 19:32:07 +00:00
93f876b58a
(cherry picked from commit 51e7c41883
)
v2: fix type check
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
34 lines
769 B
C++
34 lines
769 B
C++
#include <base/defines.h> // ADDRESS_SANITIZER
|
|
|
|
#ifdef ADDRESS_SANITIZER
|
|
|
|
#include <cstdlib>
|
|
#include <thread>
|
|
|
|
#include <gtest/gtest.h>
|
|
#include <sanitizer/lsan_interface.h>
|
|
|
|
/// Test that ensures that LSan works.
|
|
///
|
|
/// Regression test for the case when it may not work,
|
|
/// because of broken getauxval() [1].
|
|
///
|
|
/// [1]: https://github.com/ClickHouse/ClickHouse/pull/33957
|
|
TEST(Common, LSan)
|
|
{
|
|
int sanitizers_exit_code = 1;
|
|
|
|
ASSERT_EXIT({
|
|
std::thread leak_in_thread([]()
|
|
{
|
|
void * leak = malloc(4096);
|
|
ASSERT_NE(leak, nullptr);
|
|
});
|
|
leak_in_thread.join();
|
|
|
|
__lsan_do_leak_check();
|
|
}, ::testing::ExitedWithCode(sanitizers_exit_code), ".*LeakSanitizer: detected memory leaks.*");
|
|
}
|
|
|
|
#endif
|