How to properly use AddressSanitizer with GDNative?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Flone

I’m compiling my GDNative library with -fsanitize=address and it produces the output like so:

=================================================================
==88516==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 882048 byte(s) in 1752 object(s) allocated from:
   #0 0x7f267f0a0652 in __interceptor_realloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:164
   #1 0x2c7f99d  (/home/flone/CustomApps/Godot_v3.4-stable_x11.64+0x2c7f99d)

but it’s not really helpful as you can see (it only shows Godot’s executable path).
I then built the engine from source with this:

env.Append(CCFLAGS=["-fno-omit-frame-pointer", "-fsanitize=address"])
env.Append(CXXFLAGS=["-fno-omit-frame-pointer", "-fsanitize=address"])
env.Append(LINKFLAGS=["-fno-omit-frame-pointer", "-fsanitize=address"])

And same for my GDNative lib. Before the project is started I can now see full path like so:

Direct leak of 120 byte(s) in 1 object(s) allocated from:
    #0 0x7fb88c1ad279 in __interceptor_malloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x8a725c6 in Memory::alloc_static(unsigned long, bool) core/os/memory.cpp:75
    #2 0x8a724e4 in operator new(unsigned long, char const*) core/os/memory.cpp:40
    #3 etc...

After the project is started (so after all “Loading resource…” stuff) I see this output:

=================================================================
==22728==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 882048 byte(s) in 1752 object(s) allocated from:
    #0 0x7fb88c1ad652 in __interceptor_realloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:164
    #1 0x8a72e32 in Memory::realloc_static(void*, unsigned long, bool) core/os/memory.cpp:129
    #2 0x1d00765 in CowData<wchar_t>::resize(int) core/cowdata.h:293
    #3 0x4596d4d in String::resize(int) core/ustring.h:153
    #4 0x885fe54 in String::operator+=(String const&) core/ustring.cpp:325
    #5 0x885fcb0 in String::operator+(String const&) const core/ustring.cpp:309
    #6 0x2db995d in godot_string_operator_plus modules/gdnative/gdnative/string.cpp:112
    #7 0x7fb842178353  (<unknown module>)

So as you can see I still have “unknown module” here. I’ve made an intentional leak in my lib but I don’t see anything related to it in the whole output.
It’s my first time trying something like this and I’m most likely doing something wrong. Anybody tried using ASan with GDNative?