Skip to content

Commit

Permalink
Merge pull request #154 from ipsilon/fix-backwards-jump-stack-validation
Browse files Browse the repository at this point in the history
Fix stack validation check for backwards jumps
  • Loading branch information
gumb0 committed Aug 21, 2024
2 parents 329fd8b + c3a798a commit b21e986
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion spec/eof.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ During scanning, for each instruction:
2. If the successor is reached via forwards jump or sequential flow from previous instruction:
1. If the instruction does not have stack heights recorded (visited for the first time), record the instruction `stack_height_min` and `stack_height_max` equal to the value computed in 2.3.
2. Otherwise instruction was already visited (by previously seen forward jump). Update this instruction's recorded stack height bounds so that they contain the bounds computed in 2.3, i.e. `target_stack_min = min(target_stack_min, current_stack_min)` and `target_stack_max = max(target_stack_max, current_stack_max)`, where `(target_stack_min, target_stack_max)` are successor bounds and `(current_stack_min, current_stack_max)` are bounds computed in 2.3.
3. If the successor is reached via backwards jump, check if target bounds equal the value computed in 2.3, i.e. `target_stack_min == target_stack_max == current_stack_min`. Validation fails if they are not equal, i.e. we see backwards jump to a different stack height.
3. If the successor is reached via backwards jump, check if target bounds equal the value computed in 2.3, i.e. `target_stack_min == current_stack_min && target_stack_max == current_stack_max`. Validation fails if they are not equal, i.e. we see backwards jump to a different stack height.

- maximum data stack of a function must not exceed 1023
- `types[current_code_index].max_stack_height` must match the maximum stack height observed during validation
Expand Down

0 comments on commit b21e986

Please sign in to comment.