-
Notifications
You must be signed in to change notification settings - Fork 285
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
eof: Fix CALLF runtime stack overflow check #677
Conversation
State tests have incorrect expectations https://github.com/ethereum/tests/pull/1238/files#r1279089894 Upd. Fixed in https://github.com/ipsilon/tests/tree/runtime-stackoverflow-fix |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #677 +/- ##
==========================================
+ Coverage 97.43% 97.45% +0.01%
==========================================
Files 83 83
Lines 8042 8065 +23
==========================================
+ Hits 7836 7860 +24
+ Misses 206 205 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix description should also go to the commit message.
lib/evmone/instructions.hpp
Outdated
@@ -1025,7 +1025,8 @@ inline code_iterator callf(StackTop stack, ExecutionState& state, code_iterator | |||
const auto index = read_uint16_be(&pos[1]); | |||
const auto& header = state.analysis.baseline->eof_header; | |||
const auto stack_size = &stack.top() - state.stack_space.bottom(); | |||
if (stack_size + header.types[index].max_stack_height > StackSpace::limit) | |||
if (stack_size + header.types[index].max_stack_height - header.types[index].inputs > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add variable const auto callee_required_stack_size = header.types[index].max_stack_height - header.types[index].inputs;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
Current stack height and callee's max_stack_height include inputs, we must not double-count them.
2b6f009
to
837ddea
Compare
We were double counting the callee's inputs (both current stack height and callee's max_stack_height include inputs)
(Similar fix is needed for validation-time check and for JUMPF, but those are not merged yet)