Stream: wasmtime

Topic: ✔ Module serialize/deserialize across runtime versions


view this post on Zulip anb (Oct 13 2023 at 20:36):

Hi, I wonder if it's possible to load a pre-compiled module which was serialized by a different version of wasmtime? The use case is to upgrade wasmtime runtime without re-generating all the AOTs. I'm aware there's the precompile_compatibility_hash function, but want to get a bit more details behind it. Thanks!

view this post on Zulip Pat Hickey (Oct 13 2023 at 20:36):

there is an option to ignore that hash that makes it possible, but its dangerous

view this post on Zulip Pat Hickey (Oct 13 2023 at 20:37):

the serialization format may change between versions, and we cant predict how that will invalidate the serialized artifacts

view this post on Zulip Pat Hickey (Oct 13 2023 at 20:38):

we left that escape hatch in to ignore the compatibility hash so that we had a way to roll out a patch to something we know doesnt make a difference to that serialization format (for example, fixing a buggy isle rule in cranelift) and send those modules to an unpatches runtime

view this post on Zulip Pat Hickey (Oct 13 2023 at 20:39):

but for anything besides that, i'd recommend not risking it unless you are willing to do a very careful audit of all the structures that get serialized into those cwasms and how they changed between versions.

view this post on Zulip anb (Oct 13 2023 at 20:42):

I see, that's a fair point. Thank you Pat!

view this post on Zulip Lann Martin (Oct 13 2023 at 20:42):

The precompile_compatibility_hash function just hashes the exact same data that the compiler uses to check compatibility, which consists primarily of the wasmtime version string and various CPU features.

view this post on Zulip anb (Oct 13 2023 at 20:45):

Guess I have to bundle multiple runtime versions into the host program, to make the upgrade smooth. Looks like 12.0 added support for that.

view this post on Zulip Notification Bot (Oct 13 2023 at 21:08):

anb has marked this topic as resolved.

view this post on Zulip fitzgen (he/him) (Oct 13 2023 at 21:56):

the thing I would be most scared of here is not a change to the way we package the compiled code into ELF sections (since that would probably fail pretty loudly when we tried to eg find a section with an old name that isn't in the file anymore)

the thing I would be really scared of is something like a change to the layout of the vmctx. in this scenario, we would load the code into a Module just fine, but you'd get UB as soon as you called into Wasm


Last updated: Nov 22 2024 at 16:03 UTC