wilfreddenton opened issue #14331:
I ran into a difference in initialization fuel on Wasmtime 48.0.2, using the same Wasm and engine settings on Linux and macOS.
This module just initializes five bytes of memory. There are no imports or start function:
(module (memory (export "memory") 1) (data (i32.const 0) "hello"))With a 1,000,000-fuel budget, the GitHub Actions runners report:
Runner Fuel consumed Ubuntu 24.04 / x86_64 0 macOS 26 / aarch64 16,385 With a 1,000-fuel budget, Linux succeeds and macOS traps with
OutOfFuel.Here's the test and engine configuration. I compile the module in memory, with fuel enabled and CoW left at its default of enabled.
Looking at the code, it seems CoW availability determines whether the generated initialization code runs and charges fuel. My use case depends on nodes running on different platforms producing the same results, including fuel usage and whether execution succeeds or runs out of fuel.
Is this an unintended consequence of moving initialization into compiled code? Would
memory_init_cow(false)be the right temporary workaround? Possibly related to #14205.
alexcrichton added the wasmtime:fuel label to Issue #14331.
alexcrichton commented on issue #14331:
Fuel in Wasmtime right now is generally "make sure everything contributes to fuel" and then after that don't try to intentionally make fuel confusing to use. In that sense we don't have a current and/or prior use case (that I'm aware of) strictly requiring exactly the same fuel consumption across platforms (or other various scenarios). What you describe is on one hand intended, but on the other hand I would agree that it'd be nice to have a way of having deterministic fuel consumption across environments.
For this particular issue, yes, this is related to CoW how on Linux there's a memfd to map into memory but this isn't present on macOS. This means that macOS executes the initialization function while Linux does not, hence the difference in fuel.
IMO the best way to solve this at this time might be some extra documentation on
Config::consume_fuel. For example that could mention thatmemory_init_cowshould be disabled for cross-platform fuel consumption and we could use that as a location to put any other methods should they come up over time as well.
wilfreddenton commented on issue #14331:
Thanks for the reply! I originally followed the deterministic execution guide (source), which links to Deterministic Fuel. Would it make sense to mention the CoW setting there as well, and perhaps add a note on what determinism guarantees apply across platforms?
alexcrichton commented on issue #14331:
Oh perfect yeah, I forgot we already had docs for that! And yeah adding CoW bits would go well there too
Last updated: Sep 20 2026 at 18:08 UTC