Prevent some infinite recursion and loops - #352
Open
martin-hughes wants to merge 1 commit into
Open
martin-hughes wants to merge 1 commit into
martin-hughes wants to merge 1 commit into
Conversation
The motivation is to help stop AML causing a thread (or the system as a whole) to become deadlocked. The first protection adds a maximum method call stack depth. This has been chosen arbitrarily, for now. It does not protect against all possible ways of recursing infinitely. For example, it does not stop recursive table loads. (Although LoadTable is not currently supported) The second protection is a straightforward timeout for while loops, with associated tests. These are both based on the uACPI protections, although they differ in a key way: in uACPI, the method stack is unwound. If a table definition is reached, execution continues with the next statement, but the execution is still flagged as failed. In this crate, execution is stopped with an error.
martin-hughes
commented
Sep 14, 2026
Contributor
Author
There was a problem hiding this comment.
The actual tests are the same, but now the "shoulds" have become "musts".
martin-hughes
commented
Sep 14, 2026
| Panicked, | ||
| } | ||
|
|
||
| impl<T> std::fmt::Debug for RunTestResult<T> |
Contributor
Author
There was a problem hiding this comment.
Needed to allow RunTestResult to be checked in assert_matches
martin-hughes
commented
Sep 14, 2026
| kind: BlockKind::Method { method_scope: scope.clone() }, | ||
| }; | ||
| let block = | ||
| Block { stream: code.clone(), pc: 0, kind: BlockKind::Method { method_scope: scope.clone() } }; |
Contributor
Author
There was a problem hiding this comment.
This is a pure formatting change - I'm not sure why the previous version was unacceptable to rustfmt. Maybe it's a new-nightly thing?
Contributor
Author
|
Whoever merges this PR: it will interact with #345. The second of the two to be merged will need updating to handle the first. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The motivation is to help stop AML causing a thread (or the system as a whole) to become deadlocked.
The first protection adds a maximum method call stack depth. This has been chosen arbitrarily, for now. It does not protect against all possible ways of recursing infinitely. For example, it does not stop recursive table loads. (Although LoadTable is not currently supported)
The second protection is a straightforward timeout for while loops, with associated tests.
These are both based on the uACPI protections, although they differ in a key way: in uACPI, the method stack is unwound. If a table definition is reached, execution continues with the next statement, but the execution is still flagged as failed. In this crate, execution is stopped with an error.
Notes:
unwrap_methods, so I felt that was worth leaving for a separate PR.