Skip to content

Commit 169c517

Browse files
authored
[mimalloc] Error on mimalloc + ASan (emscripten-core#23314)
mimalloc is not meant to be used with ASan in general, see emscripten-core#23288 (comment) Fixes emscripten-core#23288
1 parent 011cb0c commit 169c517

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

test/test_core.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8909,10 +8909,6 @@ def test_asan_no_error(self, name):
89098909
'vector': ('test_asan_vector.cpp', [
89108910
'AddressSanitizer: container-overflow on address'
89118911
]),
8912-
# some coverage for mimalloc as well
8913-
'use_after_free_c_mimalloc': ('test_asan_use_after_free.c', [
8914-
'AddressSanitizer: heap-use-after-free on address',
8915-
], ['-sMALLOC=mimalloc']),
89168912
})
89178913
def test_asan(self, name, expected_output, cflags=None):
89188914
if '-Oz' in self.emcc_args:

test/test_other.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15218,6 +15218,11 @@ def test_wasm64_no_asan(self):
1521815218
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sMEMORY64', '-fsanitize=address'])
1521915219
self.assertContained('error: MEMORY64 does not yet work with ASAN', err)
1522015220

15221+
def test_mimalloc_no_asan(self):
15222+
# See https://github.com/emscripten-core/emscripten/issues/23288#issuecomment-2571648258
15223+
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sMALLOC=mimalloc', '-fsanitize=address'])
15224+
self.assertContained('error: mimalloc is not compatible with -fsanitize=address', err)
15225+
1522115226
@crossplatform
1522215227
def test_js_preprocess_pre_post(self):
1522315228
create_file('pre.js', '''

tools/system_libs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2369,6 +2369,9 @@ def add_sanitizer_libs():
23692369
add_library('libc')
23702370
if settings.MALLOC == 'mimalloc':
23712371
add_library('libmimalloc')
2372+
if settings.USE_ASAN:
2373+
# See https://github.com/emscripten-core/emscripten/issues/23288#issuecomment-2571648258
2374+
shared.exit_with_error('mimalloc is not compatible with -fsanitize=address')
23722375
elif settings.MALLOC != 'none':
23732376
add_library('libmalloc')
23742377
add_library('libcompiler_rt')

0 commit comments

Comments
 (0)