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

A bunch of errors in CHC engine #15469

Open
haoyang9804 opened this issue Sep 30, 2024 · 0 comments
Open

A bunch of errors in CHC engine #15469

haoyang9804 opened this issue Sep 30, 2024 · 0 comments
Assignees

Comments

@haoyang9804
Copy link
Contributor

Description

  1. Given a global function such as
function f(uint8 b) {
  uint16 a = b;
  a = a / a;
}

or a member function such as

function f(uint256 b) private returns (uint256) {
    b = b / b;
  }

CHC cannot detect "divide by 0" counterexample.

  1. Given a public member function in a contract such as
contract C {
  function g(uint256 b) public returns (uint256) {
    return b = b / b;
  }
}

the output of CHC contains errors, such as

Warning: CHC: Division by zero happens here.
Counterexample:

b = 0
 = 0

Transaction trace:
C.constructor()
C.g(0)
  --> test2.sol:16:16:
   |
16 |     return b = b / b;
   |                ^^^^^

In the above warning message given by CHC, = 0 is misleading.

Environment

  • Compiler version:0.8.28
  • Operating system: macos

Steps to Reproduce

Here is a reproducible test program

function f(uint8 b) {
  uint16 a = b;
  a = a / a;
}

function g(uint8 b) {
  b = b / b;
}

contract C {
  function f(uint256 b) private returns (uint256) {
    b = b / b;
  }
  function g(uint256 b) public returns (uint256) {
    return b = b / b;
  }
}
@pgebal pgebal self-assigned this Oct 24, 2024
@pgebal pgebal added the smt label Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: To Do
Development

No branches or pull requests

2 participants