trailofbits / manticore

Symbolic execution tool
https://blog.trailofbits.com/2017/04/27/manticore-symbolic-execution-for-humans/
GNU Affero General Public License v3.0
3.69k stars 472 forks source link

NotImplementedError: __bool__ for Bool #1005

Open evanpjensen opened 6 years ago

evanpjensen commented 6 years ago

OS / Environment

Distributor ID: Ubuntu Description: Ubuntu 18.04.1 LTS Release: 18.04 Codename: bionic

Manticore version

59a5ff0ba335d3c0409dbac7dfed3a6a225943bf

Python version

Python 3.6.5

Summary of the problem

A shift where the right operand is symbolic can cause Manticore to error.

Step to reproduce the behavior

Run Manticore with no arguments on the following contract:

contract Contract {
  function shift(uint8 s) public pure returns(uint){
    return uint(1) << s;
  }
}

Expected behavior

No error

Actual behavior

Error

Any relevant logs

2018-07-31 00:17:33,471: [34152] m.main:INFO: Beginning analysis
2018-07-31 00:17:33,475: [34152] m.ethereum:INFO: Starting symbolic create contract
2018-07-31 00:17:33,707: [34152] m.ethereum:INFO: Starting symbolic transaction: 0
2018-07-31 00:17:34,780: [34152] m.c.executor:ERROR: Exception: __bool__ for Bool
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/manticore-0.1.10-py3.6.egg/manticore/core/executor.py", line 467, in run
    if not current_state.execute():
  File "/usr/local/lib/python3.6/dist-packages/manticore-0.1.10-py3.6.egg/manticore/core/state.py", line 127, in execute
    result = self._platform.execute()
  File "/usr/local/lib/python3.6/dist-packages/manticore-0.1.10-py3.6.egg/manticore/platforms/evm.py", line 1862, in execute
    self.current_vm.execute()
  File "/usr/local/lib/python3.6/dist-packages/manticore-0.1.10-py3.6.egg/manticore/platforms/evm.py", line 659, in execute
    result = self._handler(*arguments)
  File "/usr/local/lib/python3.6/dist-packages/manticore-0.1.10-py3.6.egg/manticore/platforms/evm.py", line 627, in _handler
    return implementation(*arguments)
  File "/usr/local/lib/python3.6/dist-packages/manticore-0.1.10-py3.6.egg/manticore/platforms/evm.py", line 827, in EXP
    self._consume(EXP_SUPPLEMENTAL_GAS * nbytes(exponent))
  File "/usr/local/lib/python3.6/dist-packages/manticore-0.1.10-py3.6.egg/manticore/platforms/evm.py", line 824, in nbytes
    if e >> (i * 8) == 0:
  File "/usr/local/lib/python3.6/dist-packages/manticore-0.1.10-py3.6.egg/manticore/core/smtlib/expression.py", line 131, in __bool__
    raise NotImplementedError("__bool__ for Bool")
NotImplementedError: __bool__ for Bool
feliam commented 6 years ago

Related to https://github.com/trailofbits/manticore/issues/921, https://github.com/trailofbits/manticore/issues/727