Skip to content

Validate correct gas accounting on segfault #393

@Stebalien

Description

@Stebalien

Wasmtime accounts for "gas" by aborting once some amount of "fuel" has been consumed. It (likely?) tracks fuel by deducting the amount of fuel used by some "uninterruptible" block of code, then executes that "uninterruptible" block of code.

  • In the case where we exit normally (or even explicitly abort), this works fine.
  • In the case where we run out of gas, this also works fine because we'll simply record that all gas has been used.
  • In the case where some instruction in the middle of that block isn't quite uninterruptible, we may have issues.

Specifically:

  1. Charge gas for the entire block.
  2. Load A.
  3. Load B -> Trap due to out-of-bounds access.
  4. Load C

If this happens, we'll charge the wrong amount of gas. We need to:

  1. Better understand what wasm does here.
  2. Consider charging all remaining gas on out-of-bounds accesses like this. Callers could set hard limits on the amount of gas that can be charged if they need this to be recoverable.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions