Skip to content

Conversation

walkie
Copy link
Contributor

@walkie walkie commented Oct 1, 2021

Interface method calls must be treated specially since they may transition.

Previously, interface method calls would trigger runtime ownership violations in state machines that make use of state contexts, if the called method triggers a transition.

More generally, if an interface method call transitions, we should not continue to execute the handler that called the method for the same reasons that we determined simple transition statements should terminate a handler. Namely, because the state machine will be in an inconsistent state (i.e. no longer the state that the handler exists in), and because it opens up the door for double transitions.

The current solution resolves the ownership issue and conservatively terminates the current handler after any interface method call.

It would be possible to adopt a more liberal approach by tracking the execution of a handler more precisely, but this would require embedding some logic in the generated code and would make handlers harder to reason about.

This PR also fixes a naming issue related to interface method calls, and adds several tests of interface method calls.

However, this revealed an ownership bug related to interface calls and state contexts!
Interface method calls must be treated specially since they may transition.

The current approach is conservative, essentially assuming that an interface method call always transitions. This assumption imposes the following restrictions:

 * Interface method calls cannot occur in a chain (they must be a standalone call).

 * Interface method calls terminate the execution of their handler (like transitions).

It would be possible to lift these restrictions and track the execution of a handler more precisely, but this would require embedding some logic in the generated code and would make handlers harder to reason about. The conservative approach has the advantage of both simplifying the implementation and reasoning about Frame programs.
@walkie walkie merged commit 2014035 into v0.7.0 Oct 1, 2021
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.

1 participant