Skip to content

Implement execution limits for wasmtime#510

Draft
leonm1 wants to merge 15 commits intoproxy-wasm:mainfrom
leonm1:limits/wasmtime
Draft

Implement execution limits for wasmtime#510
leonm1 wants to merge 15 commits intoproxy-wasm:mainfrom
leonm1:limits/wasmtime

Conversation

@leonm1
Copy link
Contributor

@leonm1 leonm1 commented Mar 2, 2026

Implements execution termination (with wasmtime epochs) as well as memory limits.

Based off of #503.

@leonm1 leonm1 force-pushed the limits/wasmtime branch 3 times, most recently from 7f75843 to 20f6d8c Compare March 12, 2026 02:36
@leonm1 leonm1 requested a review from PiotrSikora March 12, 2026 03:14
Comment on lines +105 to +109
if (engine_ == "v8") {
EXPECT_TRUE(host->isErrorLogged("TerminationException"));
} else if (engine_ == "wasmtime") {
EXPECT_TRUE(host->isErrorLogged("wasm trap: interrupt"));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker, but perhaps that's a good opportunity to unify error messages to make them engine-agnostic?

Copy link
Member

@PiotrSikora PiotrSikora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM otherwise.

leonm1 added 10 commits March 17, 2026 13:05
Signed-off-by: Matt Leon <mattleon@google.com>
Signed-off-by: Matt Leon <mattleon@google.com>
Signed-off-by: Matt Leon <mattleon@google.com>
Signed-off-by: Matt Leon <mattleon@google.com>
Signed-off-by: Matt Leon <mattleon@google.com>
There's enough test cases that this warrants being run in parallel via its own test target.

Signed-off-by: Matt Leon <mattleon@google.com>
Uses bswap64 by default to handle int64 and uint64 values.

For float and doubles, uses appropriate-size bswap operators by first
bit-casting floats and doubles to their same-size int types. Otherwise,
they will be coerced to an int type before conversion and be returned as
int values.

Signed-off-by: Matt Leon <mattleon@google.com>
Without first converting to uint32_t, the getters for wasm_val_t for
wamr, wasmtime, and wasmedge returned a signed integer type. For uint32
values high enough to be in the negative range, sign extension would be
applied when the value was coerced into proxy_wasm::Word. This resulted
in Word values that did not match the comment on Word

```
// Represents a Wasm-native word-sized datum. On 32-bit VMs, the high bits are always zero.
// The Wasm/VM API treats all bits as significant.
```

nor the exact value returned from the wasm plugin.

Signed-off-by: Matt Leon <mattleon@google.com>
Signed-off-by: Matt Leon <mattleon@google.com>
Signed-off-by: Matt Leon <mattleon@google.com>
leonm1 added 5 commits March 18, 2026 17:26
Signed-off-by: Matt Leon <mattleon@google.com>
Hides many of the implementation details of the wasm-c-api.

Note: adds `wat` feature to wasmtime c headers to fix the following build error, but note that `wat` support is not enabled in the wasmtime build, this just adds the headers to allow the cpp api to compile.

```
external/com_github_bytecodealliance_wasmtime/crates/c-api/include/wasmtime/module.hh:39:17: error: use of undeclared identifier 'wat2wasm'
   39 |     auto wasm = wat2wasm(wat);
      |                 ^
1 error generated.
```

Signed-off-by: Matt Leon <mattleon@google.com>
Signed-off-by: Matt Leon <mattleon@google.com>
Signed-off-by: Matt Leon <mattleon@google.com>
Implements execution termination (with [wasmtime
epochs](https://docs.wasmtime.dev/examples-interrupting-wasm.html)) as
well as memory limits.

Signed-off-by: Matt Leon <mattleon@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants