bytecodealliance / bytecodealliance/wasmtime
Different initialization fuel on Linux and macOS with CoW enabled
- Dominant language
- Rust
- Stars
- 18.6k
- Forks
- 1.8k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 126
Description
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:
```wat
(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](https://github.com/KontorProtocol/Kontor/actions/runs/34860140877/job/104029868058) | 0 |
| [macOS 26 / aarch64](https://github.com/KontorProtocol/Kontor/actions/runs/34860140877/job/104029867820) | 16,385 |
With a 1,000-fuel budget, Linux succeeds and macOS traps with `OutOfFuel`.
Here's the [test](https://github.com/KontorProtocol/Kontor/blob/df27a08adc6b810404f7a1b65baf573de9503700/core/indexer/src/runtime/fuel/profiling_tests.rs#L18-L50) and [engine configuration](https://github.com/KontorProtocol/Kontor/blob/df27a08adc6b810404f7a1b65baf573de9503700/core/indexer/src/runtime/mod.rs#L264-L276). 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.
Contributor guide
Research direction
Start with core/indexer/src/runtime/fuel/profiling_tests.rs and the engine configuration in core/indexer/src/runtime/mod.rs. Reproduce the module with fuel enabled on Linux and macOS, comparing the default CoW setting with memory_init_cow(false), and review the relationship to #14205. Done means determining whether the platform-dependent fuel usage is intended and identifying the expected behavior or required follow-up.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, wasm
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100