question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: 'BitVecRef' object has no attribute 'as_long'

See original GitHub issue

Description

How to Reproduce

$ myth -x Tokensale.sol 
Traceback (most recent call last):
  File "/home/pierce403/.local/lib/python3.6/site-packages/mythril/laser/ethereum/util.py", line 86, in get_concrete_int
    return simplify(item).as_long()
AttributeError: 'BitVecRef' object has no attribute 'as_long'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/myth", line 11, in <module>
    sys.exit(main())
  File "/home/pierce403/.local/lib/python3.6/site-packages/mythril/interfaces/cli.py", line 397, in main
    max_transaction_count=args.max_transaction_count,
  File "/home/pierce403/.local/lib/python3.6/site-packages/mythril/mythril.py", line 470, in fire_lasers
    issues = fire_lasers(sym, modules)
  File "/home/pierce403/.local/lib/python3.6/site-packages/mythril/analysis/security.py", line 20, in fire_lasers
    issues += module.execute(statespace)
  File "/home/pierce403/.local/lib/python3.6/site-packages/mythril/analysis/modules/transaction_order_independence.py", line 26, in execute
    changing_sstores = list(_get_influencing_sstores(statespace, interesting_storages))
  File "/home/pierce403/.local/lib/python3.6/site-packages/mythril/analysis/modules/transaction_order_independence.py", line 114, in _get_influencing_sstores
    index = util.get_concrete_int(index)
  File "/home/pierce403/.local/lib/python3.6/site-packages/mythril/laser/ethereum/util.py", line 88, in get_concrete_int
    raise TypeError("Got a symbolic BitVecRef")
TypeError: Got a symbolic BitVecRef

From https://github.com/ConsenSys/devcon4-playground/blob/master/exercise2/contracts/Tokensale.sol

Expected behavior

Should output solidity bugs rather than python bugs.

Environment

pierce403@penguin:~$ myth --version
Mythril version v0.19.3
pierce403@penguin:~$ solc --version
solc, the solidity compiler commandline interface
Version: 0.4.24+commit.e67f0147.Linux.g++
pierce403@penguin:~$ python -V
Python 2.7.13
pierce403@penguin:~$ uname -a
Linux penguin 4.14.65-05969-g6f2926628697 #1 SMP PREEMPT Tue Sep 4 16:08:40 PDT 2018 x86_64 GNU/Linux

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
norhhcommented, Dec 4, 2018

@elopio, Cool, When they become public can you raise a new issue in mythril?

0reactions
come-maizcommented, Dec 4, 2018

I tried with that PR and it doesn’t crash with type error. Instead it takes a long time and eventually crashes with AssertionError:

$ sudo docker run -v $(pwd):/tmp -w "/tmp/" mythril:latest --truffle
exception in tactic canceled
# Analysis result for ECDSA

No issues found.
# Analysis result for SafeMath

No issues found.
# Analysis result for Roles

No issues found.
Traceback (most recent call last):
  File "/usr/local/bin/myth", line 11, in <module>
    load_entry_point('mythril==0.19.8', 'console_scripts', 'myth')()
  File "/usr/local/lib/python3.6/dist-packages/mythril-0.19.8-py3.6.egg/mythril/interfaces/cli.py", line 316, in main
    mythril.analyze_truffle_project(args)
  File "/usr/local/lib/python3.6/dist-packages/mythril-0.19.8-py3.6.egg/mythril/mythril.py", line 202, in analyze_truffle_project
    self.sigs, *args, **kwargs
  File "/usr/local/lib/python3.6/dist-packages/mythril-0.19.8-py3.6.egg/mythril/support/truffle.py", line 58, in analyze_truffle_project
    issues = fire_lasers(sym)
  File "/usr/local/lib/python3.6/dist-packages/mythril-0.19.8-py3.6.egg/mythril/analysis/security.py", line 69, in fire_lasers
    issues += module.detector.execute(statespace)
  File "/usr/local/lib/python3.6/dist-packages/mythril-0.19.8-py3.6.egg/mythril/analysis/modules/integer.py", line 41, in execute
    issues += self._check_integer_underflow(statespace, state, node)
  File "/usr/local/lib/python3.6/dist-packages/mythril-0.19.8-py3.6.egg/mythril/analysis/modules/integer.py", line 190, in _check_integer_underflow
    statespace, node, (op0 - op1), index=node.states.index(state)
  File "/usr/local/lib/python3.6/dist-packages/mythril-0.19.8-py3.6.egg/mythril/analysis/modules/integer.py", line 276, in _search_children
    statespace, node, state, initial_stack=taint_stack
  File "/usr/local/lib/python3.6/dist-packages/mythril-0.19.8-py3.6.egg/mythril/laser/ethereum/taint_analysis.py", line 118, in execute
    records = TaintRunner.execute_node(node, record, index)
  File "/usr/local/lib/python3.6/dist-packages/mythril-0.19.8-py3.6.egg/mythril/laser/ethereum/taint_analysis.py", line 172, in execute_node
    records.append(TaintRunner.execute_state(records[-1], current_state))
  File "/usr/local/lib/python3.6/dist-packages/mythril-0.19.8-py3.6.egg/mythril/laser/ethereum/taint_analysis.py", line 177, in execute_state
    assert len(state.mstate.stack) == len(record.stack)
AssertionError

I can’t share these contracts yet, but I think they will be public soon and then I can report a new issue.

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: 'BitVecRef' object has no attribute 'as_long ...
AttributeError : 'BitVecRef' object has no attribute 'as_long' #661 ... a symbolic BitVecRef") TypeError: Got a symbolic BitVecRef.
Read more >
z3py error when converting int to bitvec - Stack Overflow
but I always get an error saying " 'Ast' object has no attribute 'ref' ", it seems this function can only convert integer...
Read more >
Why am I getting AttributeError: Object has no attribute?
PYTHON : Why am I getting AttributeError : Object has no attribute ? [ Gift : Animated Search Engine ...
Read more >
Python AttributeError — What is it and how do you fix it?
AttributeError : '***' object has no attribute '***'What is an AttributeError in Python? What can you do to fix it? When does it...
Read more >
AttributeError: 'module' object has no attribute and ImportError
This video covers the AttributeError : 'module' object has no attribute and ImportError: No module name errors in Python.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found