mirror of https://github.com/WebAssembly/wasi-libc
Browse Source
* Don't use sbrk(0) to determine the initial heap size This commit changes the `try_init_allocator` function as part of dlmalloc to not use `sbrk(0)` to determine the initial heap size. The purpose of this function is to use the extra memory at the end of linear memory for the initial allocation heap before `memory.grow` is used to allocate more memory. To learn the extent of this region the code previously would use `sbrk(0)` to find the current size of linear memory. This does not work, however, when other systems have called `memory.grow` before this function is called. For example if another allocator is used or if another component of a wasm binary grows memory for its own purposes then that memory will be incorrectly claimed to be owned by dlmalloc. Instead this commit rounds up the `__heap_base` address to the nearest page size, since that must be allocatable. Otherwise anything above this rounded address is assumed to be used by something else, even if it's addressable. * Use `__heap_end` if defined * Move mstate initialization earliersunfishcode/update-emmalloc
Alex Crichton
2 years ago
committed by
GitHub
1 changed files with 25 additions and 8 deletions
Loading…
Reference in new issue