Skip to content
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

Add stack overflow detection to sw-emulator #1785

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

clundin25
Copy link
Contributor

@clundin25 clundin25 commented Nov 12, 2024

Added stack monitoring and overflow detection to the SW emulator

If a stack overflow is detected, the emulator will panic and cause test failure.

This resolves #1735

/// Checks if the stack will overflow when pushed to `stack_address`.
///
/// Returns `true` if the stack will overflow, `false` if it will not overflow.
pub fn check_overflow(&mut self, stack_address: u32) -> bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The stack info is only based on one fw stage (i.e. ROM, FMC, or RT). It's not clear to me how the emulator should know that the stack is relevant for a given fw stage.

Idk if this is too convoluted, but one thing we could do is have the stack tied to a certain ICCM range.

e.g. If PC is in range [A, B], SP must be in range [X, Y]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll work on adding that change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to check multiple code ranges / stacks

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.

Add stack overflow detection to SW emulator
2 participants