Fix crash happening due to invalid pointer to free() (#86868)
authorGiridhar Trivedi <giritrivedi@gmail.com>
Mon, 10 Jul 2023 14:17:11 +0000 (19:47 +0530)
committerGitHub <noreply@github.com>
Mon, 10 Jul 2023 14:17:11 +0000 (10:17 -0400)
While working on netcore debugger for mono,the crash was happening.
This crash was due to an invalid pointer to the free(). Valgrind
was showing the traces of mismatch between the new() and delete().
After debugging the issue, even though hidden flag was set on
shared library the objdump on the shared library showed that
the overloaded new() operator was taken from a local scoped library
but overloaded delete() operator was overidden by defaults setting
of underlying system libraries in which delete() was hosted.
Changed the fvisibility flag to ensure that clang picks up the
local new() and delete() overloaded operators.

Co-authored-by: Giridhar Trivedi <giridhar.trivedi@ibm.com>
src/mono/dlls/mscordbi/CMakeLists.txt

index 2cae447..52b4e62 100644 (file)
@@ -13,6 +13,9 @@ set(CMAKE_EXE_LINKER_FLAGS_CHECKED "")
 set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "")
 set(CLR_CMAKE_HOST_ARCH ${CMAKE_GENERATOR_PLATFORM})
 set(FEATURE_EVENT_TRACE 0)
+if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+  add_definitions(-fvisibility-global-new-delete-hidden)
+endif()
 
 if(HOST_WIN32)
     if(HOST_X86)