-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Description
According to valgrind, we still have mismatching issues on linux-musl-x64, which don't appear on linux-x64.
$ dotnet new console -n test1; cd test1
$ dotnet publish -c Release --use-current-runtime -p:PublishSingleFile=true --self-contained -o dist
$ dotnet-symbol dist/test1
$ valgrind --leak-check=full --show-leak-kinds=all dist/test1 >dump 2>&1The dump contains stuff like:
==15289== Mismatched free() / delete / delete []
==15289== at 0x48A4B0D: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==15289== by 0x4E0DD8: ClrFree (src/coreclr/utilcode/clrhost_nodependencies.cpp:304)
==15289== by 0x4E0DD8: operator delete(void*) (src/coreclr/utilcode/clrhost_nodependencies.cpp:398)
==15289== by 0x1E15D9: deallocate (new_allocator.h:133)
==15289== by 0x1E15D9: deallocate (alloc_traits.h:492)
==15289== by 0x1E15D9: _M_destroy (basic_string.h:237)
==15289== by 0x1E15D9: _M_dispose (basic_string.h:232)
==15289== by 0x1E15D9: ~basic_string (basic_string.h:658)
==15289== by 0x1E15D9: get_directory(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (src/native/corehost/hostmisc/utils.cpp:152)
==15289== by 0x1E76D3: exe_start(int, char const**) (src/native/corehost/corehost.cpp:128)
==15289== by 0x1E7DFF: main (src/native/corehost/corehost.cpp:301)
==15289== Address 0x4acdda0 is 0 bytes inside a block of size 23 alloc'd
==15289== at 0x48A2E63: operator new(unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==15289== by 0x1E139D: _M_construct<char *> (basic_string.tcc:219)
==15289== by 0x1E139D: _M_construct_aux<char *> (basic_string.h:247)
==15289== by 0x1E139D: _M_construct<char *> (basic_string.h:266)
==15289== by 0x1E139D: basic_string (basic_string.h:451)
==15289== by 0x1E139D: get_directory(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (src/native/corehost/hostmisc/utils.cpp:133)
==15289== by 0x1E76D3: exe_start(int, char const**) (src/native/corehost/corehost.cpp:128)
==15289== by 0x1E7DFF: main (src/native/corehost/corehost.cpp:301)with .NET 6 (70ae3df).
Daily build of .NET 7 also has this problem but unfortunately preview and daily build symbols are not being published so we get ??? instead of the names in dump: #71735.
The mismatch issue is because on Alpine Linux build machine, it is picking up #else branch here (which is unconditionally calling free, and there is no tracking how the object was originally allocated; new/new[]/malloc ....):
runtime/src/coreclr/utilcode/clrhost_nodependencies.cpp
Lines 388 to 392 in d9d6e82
| #if defined(HAS_ADDRESS_SANITIZER) || defined(DACCESS_COMPILE) | |
| // use standard heap functions for address sanitizer | |
| #else | |
| void __cdecl | |
| operator delete(void *p) NOEXCEPT |