-
Notifications
You must be signed in to change notification settings - Fork 1
feat: epoch-based interruption #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements epoch-based interruption for WebAssembly execution to prevent malicious or buggy WASM payloads from hanging the host system. The implementation uses Wasmtime's epoch interruption feature combined with a background timer to periodically check and interrupt long-running WASM code.
Key changes:
- Added epoch-based interruption with configurable tick times and timeout thresholds
- Implemented timeout handling for blocking operations in sync contexts
- Refactored test infrastructure to properly separate I/O and CPU runtimes
- Added comprehensive test coverage for various spin/hang scenarios
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| host/src/lib.rs | Implements epoch timer background task, adds timeout configuration to WasmPermissions, updates engine configuration to enable epoch interruption, and adds comprehensive documentation on async/blocking behavior |
| host/src/tokio_helpers.rs | Adds timeout support and runtime flavor validation to async_in_sync_context helper function |
| host/tests/integration_tests/rust.rs | Refactors tests to use helper functions for UDF creation, adds tests for runtime context validation |
| host/tests/integration_tests/evil/test_utils.rs | Adds dedicated I/O runtime for evil tests to properly test epoch-based interruption |
| host/tests/integration_tests/evil/spin.rs | New test suite verifying that spinning WASM payloads timeout correctly across different UDF operations |
| host/tests/integration_tests/evil/mod.rs | Adds spin module to test structure |
| guests/evil/src/lib.rs | Registers new spin test payloads for various UDF operations |
| guests/evil/src/common.rs | Adds common helper functions for empty root and UDF lists |
| guests/evil/src/spin/mod.rs | Implements spin function that creates CPU-intensive loop for testing interruption |
| guests/evil/src/spin/root.rs | Test payload that spins during root filesystem retrieval |
| guests/evil/src/spin/udf_invoke.rs | Test payload that spins during UDF invocation |
| guests/evil/src/spin/udf_name.rs | Test payload that spins during UDF name retrieval |
| guests/evil/src/spin/udf_return_type_exact.rs | Test payload that spins during return_type call with exact signature |
| guests/evil/src/spin/udf_return_type_other.rs | Test payload that spins during return_type call with non-exact signature |
| guests/evil/src/spin/udf_signature.rs | Test payload that spins during signature retrieval |
| guests/evil/src/spin/udfs.rs | Test payload that spins during UDF list retrieval |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Closes #15. Co-authored-by: Copilot <[email protected]>
d9f3e69 to
ddc6396
Compare
Closes #15.