Skip to content

Commit

Permalink
[mimalloc] Error on mimalloc + ASan (#23314)
Browse files Browse the repository at this point in the history
mimalloc is not meant to be used with ASan in general, see

#23288 (comment)

Fixes #23288
  • Loading branch information
kripken authored Jan 7, 2025
1 parent 011cb0c commit 169c517
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 0 additions & 4 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8909,10 +8909,6 @@ def test_asan_no_error(self, name):
'vector': ('test_asan_vector.cpp', [
'AddressSanitizer: container-overflow on address'
]),
# some coverage for mimalloc as well
'use_after_free_c_mimalloc': ('test_asan_use_after_free.c', [
'AddressSanitizer: heap-use-after-free on address',
], ['-sMALLOC=mimalloc']),
})
def test_asan(self, name, expected_output, cflags=None):
if '-Oz' in self.emcc_args:
Expand Down
5 changes: 5 additions & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -15218,6 +15218,11 @@ def test_wasm64_no_asan(self):
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sMEMORY64', '-fsanitize=address'])
self.assertContained('error: MEMORY64 does not yet work with ASAN', err)

def test_mimalloc_no_asan(self):
# See https://github.com/emscripten-core/emscripten/issues/23288#issuecomment-2571648258
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sMALLOC=mimalloc', '-fsanitize=address'])
self.assertContained('error: mimalloc is not compatible with -fsanitize=address', err)

@crossplatform
def test_js_preprocess_pre_post(self):
create_file('pre.js', '''
Expand Down
3 changes: 3 additions & 0 deletions tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2369,6 +2369,9 @@ def add_sanitizer_libs():
add_library('libc')
if settings.MALLOC == 'mimalloc':
add_library('libmimalloc')
if settings.USE_ASAN:
# See https://github.com/emscripten-core/emscripten/issues/23288#issuecomment-2571648258
shared.exit_with_error('mimalloc is not compatible with -fsanitize=address')
elif settings.MALLOC != 'none':
add_library('libmalloc')
add_library('libcompiler_rt')
Expand Down

0 comments on commit 169c517

Please sign in to comment.