microsoft / microsoft/mimalloc
mimalloc override + valgrind
- Dominant language
- C
- Stars
- 13.4k
- Forks
- 1.2k
- Avg merge
- 4d 45m
- Merged PRs (30d)
- 13
Description
Hi,
if you use valgrind for debugging (which is often very useful), this works ok with mimalloc and override beside that for the free's (if you use C++), you will get a lot of warnings about mismatching delete/delete[]/free usage.
Example:
==171393== Mismatched free() / delete / delete []
==171393== at 0x483A9AB: free (vg_replace_malloc.c:540)
==171393== by 0x317E26: Ur::MessageHandler::~MessageHandler() (in /home/cullmann/projects/build/libur.default.release/libur/test/test_gcallocator_exe)
==171393== by 0x2FF2FC: Ur::StaticInitializer::~StaticInitializer() (in /home/cullmann/projects/build/libur.default.release/libur/test/test_gcallocator_exe)
==171393== by 0x4A53536: __run_exit_handlers (in /usr/lib/libc-2.31.so)
==171393== by 0x4A536ED: exit (in /usr/lib/libc-2.31.so)
==171393== by 0x4A3C029: (below main) (in /usr/lib/libc-2.31.so)
==171393== Address 0x4be0420 is 0 bytes inside a block of size 64 alloc'd
==171393== at 0x483A50F: operator new[](unsigned long) (vg_replace_malloc.c:433)
==171393== by 0x3174D6: Ur::MessageHandler::MessageHandler() (in /home/cullmann/projects/build/libur.default.release/libur/test/test_gcallocator_exe)
==171393== by 0x2FF170: Ur::StaticInitializer::StaticInitializer() (in /home/cullmann/projects/build/libur.default.release/libur/test/test_gcallocator_exe)
==171393== by 0x2C4CFD: _GLOBAL__sub_I_test_gcallocator.cpp (in /home/cullmann/projects/build/libur.default.release/libur/test/test_gcallocator_exe)
==171393== by 0x48189C: __libc_csu_init (in /home/cullmann/projects/build/libur.default.release/libur/test/test_gcallocator_exe)
==171393== by 0x4A3BFAF: (below main) (in /usr/lib/libc-2.31.so)
This can be avoided, if one doesn't redirect directly but still do an extra call inside the overriding by enforcing to use the
#define MI_FORWARD1(fun,x) { return fun(x); }
variant of forwarding.
Would it be possible to have this as a cmake option? I can patch that file to always use this variant, but I assume other people will stumble over this sooner or later, too.
(or is there some more appropriate way to handle this?)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the CMake options and the override-forwarding definitions that use MI_FORWARD1, then reproduce the mismatched free/delete warnings with Valgrind. Done means a CMake-selectable forwarding mode uses the extra call for overrides and the reported warnings are resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cmake
- Domain
- backend, build-system
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100