microsoft / microsoft/mimalloc

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
#1,000 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
13.4k
Forks
1.2k
Avg merge
4d 45m
Merged PRs (30d)
13

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Windows path in mimalloc-redirect that reports "unable to find target module," then reproduce the secure ASAN setup from the dev-slice branch using the listed minject import order. Compare behavior with the non-ASAN secure build; done means standard malloc/free is redirected without the warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.