Stream: git-wasmtime

Topic: wasmtime / issue #8556 wasi-preview1-component-adapter: A...


view this post on Zulip Wasmtime GitHub notifications bot (May 05 2024 at 22:40):

dfoxfranke added the bug label to Issue #8556.

view this post on Zulip Wasmtime GitHub notifications bot (May 05 2024 at 22:40):

dfoxfranke opened issue #8556:

The single 64KiB page available to BumpArena in wasi-preview1-component-adapter is not reliably sufficient for allocating environment variables during initialization. This problem manifested for me as a crash in jco when running it inside a NixOS shell with a lot of environment variables set.

view this post on Zulip Wasmtime GitHub notifications bot (May 07 2024 at 00:05):

pchickey assigned pchickey to issue #8556.

view this post on Zulip Wasmtime GitHub notifications bot (May 07 2024 at 00:07):

pchickey commented on issue #8556:

Thanks for the bug report. I'm not sure how easy this will be to fix, the component-adapter is a very change resistant bit of software, but I believe our original reasons for designing the long-lived BumpArena to have a capped size are no longer valid, so I'm going to see if I can change the design so that that it can grow unbounded.

view this post on Zulip Wasmtime GitHub notifications bot (May 07 2024 at 00:10):

dfoxfranke commented on issue #8556:

Could https://crates.io/crates/wee_alloc be a good fit for this?

view this post on Zulip Wasmtime GitHub notifications bot (May 07 2024 at 00:57):

alexcrichton commented on issue #8556:

@pchickey I was poking a bit at this today and wrote up a reproduction test case (ignore the commented out bits in the rest of Wasmtime).

Otherwise I _think_ it should be possible to call cabi_realloc from the adapter. The one downside of that is that a single allocation can't be larger than 64k due to this constraint, but we can probably lift that at the same time perhaps. Most modules export a cabi_realloc anyway so they should avoid that linked code there too since they'd actually use the language's normal cabi_realloc.

view this post on Zulip Wasmtime GitHub notifications bot (May 07 2024 at 05:48):

pchickey commented on issue #8556:

thanks! I made a reproducer as well today but i like yours better. i was going through trying to decode the history of why we didnt always call cabi_realloc directly and trying to figure out, when it became possible to do so, did we choose not to do it or did we just not think about it? anyway I think I'm going kayaking tomorrow but I will give it a try wednesday.

view this post on Zulip Wasmtime GitHub notifications bot (May 08 2024 at 15:32):

alexcrichton commented on issue #8556:

Originally we assumed we couldn't call cabi_realloc at all and even now the import of cabi_realloc is a bit of a lie, sometimes it's hooked up to memory.grow. Supporting cabi_realloc itself was added in due to other issues down the road at some point.

Otherwise though I think we just forgot to handle the case of >=64k env/arg blocks...

view this post on Zulip Wasmtime GitHub notifications bot (May 10 2024 at 16:22):

alexcrichton commented on issue #8556:

I think I've got an idea, albeit a bit nasty in the implementation, of how to solve this so I'm going to give it a stab

view this post on Zulip Wasmtime GitHub notifications bot (May 10 2024 at 18:59):

alexcrichton commented on issue #8556:

While it's very much a hack the idea ended up at least mostly working out

view this post on Zulip Wasmtime GitHub notifications bot (May 14 2024 at 16:10):

alexcrichton closed issue #8556:

The single 64KiB page available to BumpArena in wasi-preview1-component-adapter is not reliably sufficient for allocating environment variables during initialization. This problem manifested for me as a crash in jco when running it inside a NixOS shell with a lot of environment variables set.


Last updated: Dec 23 2024 at 13:07 UTC