-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test_wrap_malloc currently failed under mimalloc #23090
Comments
Does increasing INITIAL_MEMORY fix this? It is expected that mimalloc take more memory than other allocators. |
IIRC I decreased the memory used in the test from 1mb for loop to just 10k per loop and it still failed. |
It seems to work without any issues when using --- a/test/test_core.py
+++ b/test/test_core.py
@@ -8597,8 +8597,7 @@ NODEFS is no longer included by default; build with -lnodefs.js
@parameterized({
'': ([],),
'emmalloc': (['-sMALLOC=emmalloc'],),
- # FIXME(https://github.com/emscripten-core/emscripten/issues/23090)
- # 'mimalloc': (['-sMALLOC=mimalloc'],),
+ 'mimalloc': (['-sMALLOC=mimalloc', '-sINITIAL_MEMORY=64MB'],),
})
def test_wrap_malloc(self, args):
self.do_runf('core/test_wrap_malloc.c', 'OK.', emcc_args=args) |
Any idea why mimalloc would need twice as much memory as the other allocators? Any idea why changing the test to do |
See #23091 |
The error seems to occur on the very first allocation... |
It appears that emscripten/system/lib/emmalloc.c Lines 765 to 780 in 44dc320
You would expect that emscripten/system/lib/emmalloc.c Lines 553 to 554 in 44dc320
With PR #23037, this test case also works with @@ -1,12 +1,12 @@
initialize_emmalloc_heap()
claim_more_memory(numBytes=48)
-claim_more_memory: claimed 0x0001d800 - 0x0001d830 (48 bytes) via sbrk()
+claim_more_memory: claimed 0x0001d840 - 0x0001d870 (48 bytes) via sbrk()
claim_more_memory: sbrk() returned a disjoint region to last root region, some external code must have sbrk()ed outside emmalloc(). Creating a new root region
-allocate_memory(align=4194304, size=33554432 bytes)
-claim_more_memory(numBytes=37748784)
-claim_more_memory: claimed 0x0001d830 - 0x0241d860 (37748784 bytes) via sbrk()
+allocate_memory(align=2097152, size=33554432 bytes)
+claim_more_memory(numBytes=35651632)
+claim_more_memory: claimed 0x0001d870 - 0x0221d8a0 (35651632 bytes) via sbrk()
claim_more_memory: sbrk() returned a region contiguous to last root region, expanding the existing root region
-allocate_memory(align=4194304, size=33554432 bytes)
-attempt_allocate(freeRegion=0x0001d810,alignment=4194304,size=33554432)
-attempt_allocate - succeeded allocating memory, region ptr=0x003ffffc, align=4194304, payload size=33554432 bytes)
+allocate_memory(align=2097152, size=33554432 bytes)
+attempt_allocate(freeRegion=0x0001d850,alignment=2097152,size=33554432)
+attempt_allocate - succeeded allocating memory, region ptr=0x001ffffc, align=2097152, payload size=33554432 bytes)
|
Even changing the test to only allocate 20k and the error seems to persist. i.e |
Actually that test frees the memory within the loop so the peak allocation should never be more than 1Mb or so. So this is certainly a bug in our mimalloc implementation and not something that should require the test to be updated. |
By default, mimalloc preallocates a 32MiB memory arena on wasm32 to ensure memory is reused more effectively.
emscripten/system/lib/mimalloc/src/arena.c Lines 360 to 362 in c08204e
|
But the default value for |
The text was updated successfully, but these errors were encountered: