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

Do not emit a binary when a function access a stack offset outside its frame #1729

Closed
4 of 6 tasks
LucasSte opened this issue Jun 13, 2024 · 1 comment
Closed
4 of 6 tasks
Assignees

Comments

@LucasSte
Copy link

LucasSte commented Jun 13, 2024

Problem

The stack frame for each function in SBFv1 is limited to 4kb. Although there is a soft error telling people to minimize stack variables, we still emit binaries for those contracts that override their stack. This can lead to undefined behavior during execution.

Furthermore, the logic to emit the existing warnings is broken, because it does not detect all cases.

Proposed Solution

  • Fix the detection logic and improve it with a more meaningful message, informing the calculated frame size.
  • Detect when we write function call arguments over existing data on the stack.
  • Stop compilation in the above cases.
  • Check if there is a way to surface these error to rustc for better user experience.
  • Check if there are any passes on either rustc or LLVM that interferes with stack usage.
  • Assist Anchor in decreasing stack usage of their functions before a compiler release.
@LucasSte LucasSte self-assigned this Jun 13, 2024
@LucasSte LucasSte changed the title Do not emit a binary when a function access a stack offset outside its frame. Do not emit a binary when a function access a stack offset outside its frame Jun 13, 2024
@LucasSte
Copy link
Author

I opened an issue on the Anchor repository to explain about this: coral-xyz/anchor#3060

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

No branches or pull requests

1 participant