Repository navigation
use page_size=1 for instrumented components - #15
Merged
Merged
Conversation
…the same talc arena
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Page size 1 memory is not supported with
-fPICand in the nativedlmalloc. There are two different code paths depending on the target:wasip2, the default allocator is thewasi-libc's malloc (dlmalloc). Rust's allocator callsmalloc/free. Inwasi-libc,sbrkis the only code that touchesmemory.growandmemory.size. We use our custom cratelibc-allocto replacesbrkwith a version that grows by bytes. Everything else stays stock.talcas the Rust#[global_allocator], with amalloc/freeshim on top of it. But it's not enough.cabi_realloccomes fromwasip2and allocates canonical ABI buffers through__rust_alloc.wasi-libcfrees some of those buffers withfree(), but two allocators disagree about the block layout, sofreetrapped with an out-of-bounds access.cabi_realloc. Rust's system allocator on wasi already callsmalloc. So the easiest fix is to keepwasi-libc's malloc and fixing onlysbrk.wasm-unknown-unknown, there is nowasi-libc. The default allocator is std's owndlmalloc. The built-in memory source hardcodes 64K pages.OneBytePageinassets/one_byte_page_alloc.rs. Itsalloc(size)callmemorry.grow(size).page_size()still reports 64K, whichdlmalloconly uses for rounding.talcas the global allocator, but it either requires a fixed-size arena, or the custom memory source has to grow memory by enough to covertalc's private per-heap overhead.