mimalloc icon indicating copy to clipboard operation
mimalloc copied to clipboard

Malloc / Free redirect doesn't work on Windows when build mimalloc in secure mode with address sanitizer support (MI_SECURE and MI_TRACK_ASAN)

Open dimhotepus opened this issue 10 months ago • 0 comments

Branch: dev-slice.

I'm already using minject to place mimalloc first in exe import table, and non-asan secure builds work just fine.

But with enabled MI_SECURE and MI_TRACK_ASAN:

mimalloc: warning: cannot enable large OS page support, error 1300
mimalloc-redirect: error: unable to find target module.
mimalloc-redirect: warning: standard malloc is _not_ redirected! -- using regular malloc/free. (v1.3)

I also tried to inject mimalloc-secure-asan-debug first into exe import table via minject --force --inplace --postfix=secure-asan-debug <path-to-exe> and confirmed mimalloc-redirect and mimalloc-secure-asan-debug come first in import table:

minject.exe -l e:\github\whitebox\out\x86_64-pc-windows-msvc-debug\base\whitebox-base_tests.exe
original imported modules (14):
   0: mimalloc-redirect.dll
   1: mimalloc-secure-asan-debug.dll
   2: WINMM.dll
   3: whitebox-base.dll
   4: g3log.dll
   5: KERNEL32.dll
   6: ole32.dll
   7: OLEAUT32.dll
   8: MSVCP140D.dll
   9: MSVCP140D_ATOMIC_WAIT.dll
  10: clang_rt.asan_dynamic-x86_64.dll
  11: VCRUNTIME140D.dll
  12: VCRUNTIME140_1D.dll
  13: ucrtbased.dll

But error is the same. Note all non-system DLLs are build with mimalloc, too.

dimhotepus avatar Feb 02 '25 23:02 dimhotepus