Skip to content
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

Don't use sbrk(0) to determine the initial heap size #377

Merged
merged 4 commits into from
Jan 9, 2023

Commits on Jan 7, 2023

  1. 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.
    alexcrichton committed Jan 7, 2023
    Configuration menu
    Copy the full SHA
    594c328 View commit details
    Browse the repository at this point in the history

Commits on Jan 9, 2023

  1. Configuration menu
    Copy the full SHA
    ed9588d View commit details
    Browse the repository at this point in the history
  2. Review comments

    alexcrichton committed Jan 9, 2023
    Configuration menu
    Copy the full SHA
    a4f5c73 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    e8bd80a View commit details
    Browse the repository at this point in the history