Stream: git-wasmtime

Topic: wasmtime / PR #14391 Fold buffered fuel charges when a fu...


view this post on Zulip Wasmtime GitHub notifications bot (Sep 23 2026 at 20:11):

xia-chao opened PR #14391 from xia-chao:fix-fuel-buffer-flush-on-exit to bytecodealliance:main:

Instantiation-time fuel is dropped for modules with no start function.

A module with a multi-op const-expr global initializer reports 1 unit of fuel
consumed instead of 4. Adding an empty start function to the same module makes it
report the expected 6.

Those charges accumulate in fuel_consumed. Wasm functions fold that buffer into
fuel_var through the trailing end operator, but the module startup function is
synthesized and has no end, and module_start, the other place that flushes the
buffer, is only emitted when start exists. So the buffer is dropped.

fuel_function_exit now folds the buffer before saving. For functions translated
from wasm this is a no-op.

<details>
<summary>Screenshots from a debugger session on main (5877086436)</summary>

Breakpoint in fuel_function_exit, where fuel_consumed is 3 but only fuel_var
gets saved:

![breakpoint in fuel_function_exit](https://raw.githubusercontent.com/xia-chao/bughunt-shots/main/wasmtime/14203/01-fuel-function-exit.webp)

Breakpoint in module_start, the only place that folds the buffer. The frame above
it is func_environ.rs:6015, the module_start call guarded by
if let Some(start_func):

![breakpoint in module_start](https://raw.githubusercontent.com/xia-chao/bughunt-shots/main/wasmtime/14203/02-module-start-flush.webp)

Same module, same initializer: fuel consumed = 1 without start, 6 with it.

![Debug Console](https://raw.githubusercontent.com/xia-chao/bughunt-shots/main/wasmtime/14203/03-debug-console.webp)

</details>

Fixes #14203.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 23 2026 at 20:11):

xia-chao requested wasmtime-compiler-reviewers for a review on PR #14391.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 23 2026 at 20:11):

xia-chao requested fitzgen for a review on PR #14391.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 23 2026 at 20:11):

xia-chao requested wasmtime-core-reviewers for a review on PR #14391.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 23 2026 at 22:23):

fitzgen commented on PR #14391:

FYI: screenshots are not, in general, good for including in bug reports / PRs / issues, since they have worse accessibility for screen readers and tend to include lots of superfluous information for people to visually parse.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 23 2026 at 22:27):

:memo: fitzgen submitted PR review:

Thanks! One thing below...

view this post on Zulip Wasmtime GitHub notifications bot (Sep 23 2026 at 22:27):

:speech_balloon: fitzgen created PR review comment:

Does this not emit an extra fuel increment? I think a better solution would be to make the synthesized start function update the fuel var before returning.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 23 2026 at 23:05):

xia-chao updated PR #14391.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 23 2026 at 23:18):

:memo: xia-chao submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 23 2026 at 23:18):

:speech_balloon: xia-chao created PR review comment:

No, what I am currently doing is completely equivalent to what you are saying
But I still made the modifications according to what you said

view this post on Zulip Wasmtime GitHub notifications bot (Sep 23 2026 at 23:19):

xia-chao commented on PR #14391:

This is just a patch with limited content. You can review it directly. It should not be included here, but for some larger fixes, you cannot distinguish them just by looking at the code. Next time, I will only include them in larger fixes

I think it's very helpful, breakpoint screenshots are the highest level of bug evidence

It is normal to have visual interference, and all the evidence is indicated on the graph. Perhaps it will be helpful when you combine LLM review

view this post on Zulip Wasmtime GitHub notifications bot (Sep 23 2026 at 23:20):

xia-chao edited a comment on PR #14391:

This is just a small patch; the content is minimal, and you can easily review it directly. Admittedly, it probably shouldn't have been posted here—I usually reserve posts for more significant fixes where the changes aren't immediately obvious just by looking at the code. I'll only post about major fixes in the future.

I think it’s very helpful, though; a screenshot at the breakpoint serves as the ultimate evidence of the bug.

The visual clutter is to be expected, but all the evidence is right there in the image—it might prove useful when you're reviewing the code in conjunction with an LLM.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 23 2026 at 23:21):

xia-chao edited a comment on PR #14391:

This is just a patch with minimal content—you could easily review it directly, and perhaps it shouldn't have been included here. However, for major fixes, the code alone often doesn't tell the whole story; I'll only include screenshots like this for significant fixes in the future.

I believe it’s very helpful; a screenshot of a breakpoint serves as the ultimate evidence of a bug.

It’s normal for there to be some visual clutter, as the image captures all the relevant evidence—it might prove useful when you're reviewing the code in conjunction with an LLM.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 24 2026 at 16:34):

xia-chao requested fitzgen for a review on PR #14391.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 24 2026 at 16:36):

xia-chao edited a comment on PR #14391:

This is just a patch with minimal content—you could easily review it directly, and perhaps it shouldn't have been included here. However, for major fixes, the code alone often doesn't tell the whole story; I'll only include screenshots like this for significant fixes in the future.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2026 at 15:05):

xia-chao updated PR #14391.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2026 at 15:10):

xia-chao updated PR #14391.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2026 at 16:31):

:thumbs_up: fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2026 at 16:31):

fitzgen added PR #14391 Fold buffered fuel charges when a function exits to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2026 at 16:57):

:check: fitzgen merged PR #14391.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 25 2026 at 16:57):

fitzgen removed PR #14391 Fold buffered fuel charges when a function exits from the merge queue.


Last updated: Oct 11 2026 at 04:10 UTC