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

Address sanitizer triggered by any C or C++ program #1384

Open
MeatBoy106 opened this issue Jan 19, 2023 · 0 comments
Open

Address sanitizer triggered by any C or C++ program #1384

MeatBoy106 opened this issue Jan 19, 2023 · 0 comments

Comments

@MeatBoy106
Copy link

A memory leak is reported by the address sanitizer (g++ & clang) in ubuntu 22.04 when linking a C or a C++ program with libtcmalloc 4.5.9 installed via google-perftools. Linking with libtcmalloc_minimal does not trigger the issue.

Steps to reproduce:
In ubuntu 22.04 (reproduced via docker), run the following commands:

apt update
apt install -y build-essential google-perftools
echo 'int main(int, char**){return 0;}' > main.cc
# this line triggers the bug
g++ -g -fsanitize=address /usr/lib/x86_64-linux-gnu/libtcmalloc.so.4 main.cc && ./a.out
# this line does not
g++ -g -fsanitize=address /usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4 main.cc && ./a.out

Reported error:

=================================================================
==4473==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 45 byte(s) in 1 object(s) allocated from:
    #0 0x7f0d37bd21c7 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:99
    #1 0x7f0d3783cf3d in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned long, unsigned long, char const*, unsigned long) (/lib/x86_64-linux-gnu/libstdc++.so.6+0x14bf3d)

SUMMARY: AddressSanitizer: 45 byte(s) leaked in 1 allocation(s).

When linking with libtcmalloc_debug.so in an attempt to get a better backtrace, the following segfault is reported alongside with the memory leak:

AddressSanitizer:DEADLYSIGNAL
=================================================================
==4467==ERROR: AddressSanitizer: SEGV on unknown address 0x603ffffffff8 (pc 0x7f96e7dd264f bp 0x603ffffffff0 sp 0x7ffc9dce44b0 T0)
==4467==The signal is caused by a READ memory access.
    #0 0x7f96e7dd264f  (/lib/x86_64-linux-gnu/libtcmalloc_debug.so.4+0x1864f)
    #1 0x7f96e7df59f4 in operator delete(void*, unsigned long) (/lib/x86_64-linux-gnu/libtcmalloc_debug.so.4+0x3b9f4)
    #2 0x7f96e7de91bc in MallocExtension::Initialize() (/lib/x86_64-linux-gnu/libtcmalloc_debug.so.4+0x2f1bc)
    #3 0x7f96e7dcf936  (/lib/x86_64-linux-gnu/libtcmalloc_debug.so.4+0x15936)
    #4 0x7f96e89b647d  (/lib64/ld-linux-x86-64.so.2+0x647d)
    #5 0x7f96e89b6567  (/lib64/ld-linux-x86-64.so.2+0x6567)
    #6 0x7f96e89d02e9  (/lib64/ld-linux-x86-64.so.2+0x202e9)

AddressSanitizer can not provide additional info.

SUMMARY: AddressSanitizer: SEGV (/lib/x86_64-linux-gnu/libtcmalloc_debug.so.4+0x1864f)
==4467==ABORTING
root@101d64eec628:/hello# g++ -g -fsanitize=address /usr/lib/x86_64-linux-gnu/libtcmalloc.so.4 main.cc && ./a.out

=================================================================
==4473==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 45 byte(s) in 1 object(s) allocated from:
    #0 0x7f0d37bd21c7 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:99
    #1 0x7f0d3783cf3d in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned long, unsigned long, char const*, unsigned long) (/lib/x86_64-linux-gnu/libstdc++.so.6+0x14bf3d)

SUMMARY: AddressSanitizer: 45 byte(s) leaked in 1 allocation(s).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant