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

Folding exponent can make the compiler crash #4078

Open
trocher opened this issue May 7, 2024 · 0 comments
Open

Folding exponent can make the compiler crash #4078

trocher opened this issue May 7, 2024 · 0 comments

Comments

@trocher
Copy link
Contributor

trocher commented May 7, 2024

Version Information

  • vyper Version (output of vyper --version OR linkable commit hash vyperlang/vyper@commitish): 0.4.0rc3+commit.6d4c09cd

Issue description

When having x ** y folded, if x == 0 or x == 1, the compiler will crash.

See:

vyper/vyper/ast/nodes.py

Lines 1105 to 1106 in 6d4c09c

if right > math.log(decimal.Decimal(2**257)) / math.log(decimal.Decimal(left)):
raise InvalidLiteral("Out of bounds", self)

POC

@external
def foo()->uint256:
   return 1**2
ZeroDivisionError: float division by zero
@external
def foo()->uint256:
   return 0**2
ValueError: math domain error
@trocher trocher changed the title Folding of literal exponent can make the compiler crash Folding exponent can make the compiler crash May 7, 2024
@cyberthirst cyberthirst transferred this issue from another repository May 31, 2024
@charles-cooper charles-cooper transferred this issue from another repository May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant