wasi-libc icon indicating copy to clipboard operation
wasi-libc copied to clipboard

Fixed malloc with concurrent executions of memory.grow

Open MoritzS opened this issue 2 years ago • 1 comments

Other PRs have fixed issues with malloc not being the only code that may use the memory.grow instruction (#377, #394). This merge requests fixes some issues that can occur when running the WebAssembly module multi-threaded and other threads may call memory.grow concurrently while malloc is executed.

MoritzS avatar Apr 02 '23 20:04 MoritzS

Interesting. dlmalloc's documentation for MORECORE_CONTIGUOUS says that it should be correct in the presence of non-continuities, which I assumed would include non-continuities induced by other threads. But seeing code like this:

     br = (char*)(CALL_MORECORE(asize));
     end = (char*)(CALL_MORECORE(0));

It appears this is not the case. At an initial glance, this PR makes sense to me, though I'm not super familiar with dlmalloc internals.

sunfishcode avatar Apr 03 '23 20:04 sunfishcode