Partially revert "Don't use sbrk(0) to determine the initial heap size"#386
Partially revert "Don't use sbrk(0) to determine the initial heap size"#386yamt wants to merge 1 commit intoWebAssembly:mainfrom
Conversation
sbc100
left a comment
There was a problem hiding this comment.
I tend to agree with this approach ..
dlmalloc/src/malloc.c
Outdated
| @@ -5228,22 +5228,10 @@ static void try_init_allocator(void) { | |||
| char *base = &__heap_base; | |||
| // Try to use the linker pseudo-symbol `__heap_end` for the initial size of | |||
| // the heap, but if that's not defined due to LLVM being too old perhaps then | |||
There was a problem hiding this comment.
can you remove perhaps here.
How about ".. but if that's not defined (due to LLVM being too old) ..."
dlmalloc/src/malloc.c
Outdated
| // correct if the we're the first to try to grow the heap. If the heap has | ||
| // grown elsewhere, such as a different allocator in place, then this would | ||
| // incorrectly claim such memroy as our own. | ||
| // fall back to `CALL_MORECORE(0)`. |
There was a problem hiding this comment.
"fall back to assuming the heap extends to end of linear memory (CALL_MORECORE(0))"
While the problem it addressed (`memory.grow` use outside of malloc) is real, it has been broken for long in this implementation. IMO, the fix doesn't warrant breaking other working use cases, (Pre-populating heap with `--init-memory`) especially when a better solution (`__heap_end`) is on the horizon.
|
From the perspective of wasi-sdk releases, this isn't needed. Wasi-sdk 18 never had any artifacts uploaded, and I've now downgraded it to a pre-release to discourage people from using it. So the main relevant releases are wasi-sdk 17, which has the old behavior, and wasi-sdk 19, which has the good We do have users who download just wasi-sysroot though, but I wonder if it would be enough for such users to package this PR as a special release. Part of my reason for hesitating here is that the old behavior of malloc claiming all the memory up to @yamt Would it work for your use case if we merged this PR onto a dedicated branch, rather than |
Sorry, I'm a little confused, which is the old behaviour you are talking about in wasi-sdk 17? Is the behaviour where malloc grabs all the memory up to So if once wants to build a binary that supports the polyfill one would need to download wasi-sdk 19? (Which contains the |
|
Another question: can you be clear about which users you imagine might be broken by landing this change? Are you worried about users using tip-of-tree wasi-libc but wanted to use it with and older versions of wam-ld? That seems conceivable but fairly unlikely. Or is there some other group of users that I'm not thinking of? |
Yes. wasi-sdk-17 will claim all memory up to
That is the current situation. It's not ideal. We're all doing the best we can within practical constraints.
I don't have any numbers, but anecdotally, we do occasionally get people asking how to download the wasi-sysroot separately from everything else, and bug reports from people using third-party clang builds (such as the clang provided by homebrew). |
Thanks, that does help clear things up for me. Now I understand that argument for not landing this. |
sorry, i don't understand your polyfill reasoning. with or without this revert,
am i missing something?
after thinking about this topic a bit more, i'm now feeling it might be simpler to just require |
I think that would be great solution, but it really depends how many of our users out there want to use their own (older) version llvm rather than the latest. |
right. my assumption here is that users who can't use newer llvm is rare. |
|
can we make a decision? a. do nothing my preference is c. >= b. > a. i don't like the current state because it will leave us something difficult to trouble shoot. |
|
I'd like to avoid applying this PR, as this PR would make it even more complex for users to determine whether they have a toolchain that has the bug fix. Could we make wasi-libc require |
ok. see #394 |
|
I think this is superseded by #394; now we always depend on the |
While the problem it addressed (
memory.growuse outside of malloc) is real, it has been broken for long in this implementation. IMO, the fix doesn't warrant breaking other working use cases, (Pre-populating heap with--init-memory) especially when a better solution (__heap_end) is on the horizon.