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

new(tests): EOF validation RETF stack overflow #1341

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

Conversation

hugo-dc
Copy link
Member

@hugo-dc hugo-dc commented Mar 23, 2025

πŸ—’οΈ Description

πŸ”— Related Issues

βœ… Checklist

@hugo-dc hugo-dc requested a review from chfast March 23, 2025 06:56
@hugo-dc hugo-dc marked this pull request as draft March 23, 2025 13:35
@hugo-dc hugo-dc marked this pull request as ready for review March 23, 2025 16:59
max_stack_height=2,
),
],
expected_bytecode="ef000101000802000200040003040000000080000200020002e30001005f5fe4",
Copy link
Contributor

Choose a reason for hiding this comment

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

@marioevz
the expected_bytecode was a temporary feature, this will require huge efforts of maintenance as eof format changes. consider disabling expected_bytecode verification in most of the EOF tests.

Copy link
Member

@marioevz marioevz left a comment

Choose a reason for hiding this comment

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

Looks great! Just a few comments, and I echo Dimitry's comment that expected_bytecode could be removed, specially when we already have PRs like #1339 where adding more tests that use this field would result in more rework.

sections=[
Section.Code(code=Op.CALLF[1] + Op.STOP, max_stack_height=5),
Section.Code(
code=Op.PUSH0 + Op.PUSH1[0] + Op.RJUMPI[2] + Op.PUSH0 * 2 + Op.RETF,
Copy link
Member

Choose a reason for hiding this comment

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

I think both branches underflow in this case, it would be nice to see:

  • Case where it only underflows in the jump branch (Edit: covered in case below)
  • Case where it only underflows in the no-jump branch (no-jump pops from the stack for example).

sections=[
Section.Code(code=Op.CALLF[1] + Op.STOP, max_stack_height=1),
Section.Code(
code=Op.PUSH0 + Op.PUSH1[0] + Op.RJUMPI[2] + Op.PUSH0 * 2 + Op.RETF,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
code=Op.PUSH0 + Op.PUSH1[0] + Op.RJUMPI[2] + Op.PUSH0 * 2 + Op.RETF,
code=Op.PUSH0 + Op.PUSH1[0] + Op.RJUMPI[1] + Op.PUSH0 + Op.RETF,

We should also include the case where it overflows by one stack item only.

Copy link
Member

Choose a reason for hiding this comment

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

Also similar comment to one in the previous test function, we should add a variant where it overflows in the jumping branch, for example:

Op.PUSH0 + Op.PUSH1[0] * 2 + Op.RJUMPI[1] + Op.POP + Op.RETF

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.

3 participants