Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@andrewmd5
Copy link
Contributor

This fixes an issue I found where a host function calling back into WASM would cause the stack to get into an unrecoverable state.

Detect nested calls via operand stack, save/restore instruction pointer, and preserve results.

Detect nested CreateInvoker calls by checking the operand stack height. Save the current instruction pointer for nested calls and restore it on success or exceptions instead of unconditionally flushing the call stack. For nested calls push results back onto the operand stack so callers can consume them; for top-level calls keep the previous behavior of clearing remaining stack values.

…ave/restore instruction pointer, and preserve results

Detect nested CreateInvoker calls by checking the operand stack height. Save the current instruction pointer for nested calls and restore it on success or exceptions instead of unconditionally flushing the call stack. For nested calls push results back onto the operand stack so callers can consume them; for top-level calls keep the previous behavior of clearing remaining stack values.
Copilot AI review requested due to automatic review settings October 30, 2025 08:50
Copy link
Contributor

Copilot AI left a 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 support for nested function calls in the WebAssembly runtime by introducing special handling to distinguish between top-level and nested function invocations.

  • Adds nested call detection based on operand stack state
  • Preserves and restores instruction pointer for nested calls
  • Implements different cleanup strategies for top-level vs. nested calls

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kelnishi kelnishi merged commit 444a777 into kelnishi:main Nov 3, 2025
1 check passed
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