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.

Mythril terminates with AttributeError

See original GitHub issue

Description

Mythril crashes with an AttributeError exception on a certain byte code input.

How to Reproduce

$ myth -x -c "60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063ca5d088014610051578063eedc966a14610068575b600080fd5b34801561005d57600080fd5b506100666100bf565b005b34801561007457600080fd5b506100a9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506102b0565b6040518082815260200191505060405180910390f35b60008060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414151561010c57600080fd5b3373ffffffffffffffffffffffffffffffffffffffff16634d5f327c6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15801561017057600080fd5b505af1158015610184573d6000803e3d6000fd5b505050506040513d602081101561019a57600080fd5b81019080805190602001909291905050506000191660405160200180807f4e7520546f6b656e00000000000000000000000000000000000000000000000081525060080190506040516020818303038152906040526040518082805190602001908083835b60208310151561022457805182526020820191506020810190506020830392506101ff565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390206000191614151561026157600080fd5b60146000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550565b600060205280600052604060002060009150905054815600a165627a7a7230582010fa64b549bd7ca2c32d19c93cd7595a8bf2bd309f325440d18102a85181b6400029"
Traceback (most recent call last):
  File "/Users/bernhardmueller/.pyenv/versions/mythril/bin/myth", line 11, in <module>
    load_entry_point('mythril==0.19.7', 'console_scripts', 'myth')()
  File "/Users/bernhardmueller/.pyenv/versions/3.6.3/envs/mythril/lib/python3.6/site-packages/mythril/interfaces/cli.py", line 413, in main
    transaction_count=args.transaction_count,
  File "/Users/bernhardmueller/.pyenv/versions/3.6.3/envs/mythril/lib/python3.6/site-packages/mythril/mythril.py", line 503, in fire_lasers
    transaction_count=transaction_count,
  File "/Users/bernhardmueller/.pyenv/versions/3.6.3/envs/mythril/lib/python3.6/site-packages/mythril/analysis/symbolic.py", line 73, in __init__
    creation_code=contract.creation_code, contract_name=contract.name
  File "/Users/bernhardmueller/.pyenv/versions/3.6.3/envs/mythril/lib/python3.6/site-packages/mythril/laser/ethereum/svm.py", line 113, in sym_exec
    self, creation_code, contract_name
  File "/Users/bernhardmueller/.pyenv/versions/3.6.3/envs/mythril/lib/python3.6/site-packages/mythril/laser/ethereum/transaction/symbolic.py", line 74, in execute_contract_creation
    laser_evm.exec(True)
  File "/Users/bernhardmueller/.pyenv/versions/3.6.3/envs/mythril/lib/python3.6/site-packages/mythril/laser/ethereum/svm.py", line 188, in exec
    new_states, op_code = self.execute_state(global_state)
  File "/Users/bernhardmueller/.pyenv/versions/3.6.3/envs/mythril/lib/python3.6/site-packages/mythril/laser/ethereum/svm.py", line 215, in execute_state
    global_state
  File "/Users/bernhardmueller/.pyenv/versions/3.6.3/envs/mythril/lib/python3.6/site-packages/mythril/laser/ethereum/instructions.py", line 154, in evaluate
    return instruction_mutator(global_state)
  File "/Users/bernhardmueller/.pyenv/versions/3.6.3/envs/mythril/lib/python3.6/site-packages/mythril/laser/ethereum/instructions.py", line 113, in wrapper
    new_global_states = self.call_on_state_copy(func, func_obj, global_state)
  File "/Users/bernhardmueller/.pyenv/versions/3.6.3/envs/mythril/lib/python3.6/site-packages/mythril/laser/ethereum/instructions.py", line 76, in call_on_state_copy
    return func(func_obj, global_state_copy)
  File "/Users/bernhardmueller/.pyenv/versions/3.6.3/envs/mythril/lib/python3.6/site-packages/mythril/laser/ethereum/instructions.py", line 472, in calldatasize_
    state.stack.append(environment.calldata.calldatasize)
AttributeError: 'NoneType' object has no attribute 'calldatasize'
  • Mythril version: v0.19.7
  • Solidity compiler and version: 0.4.24+commit.e67f0147.Darwin.appleclang
  • Python version: 3.6.4
  • OS and Version: Mac OS Mojave

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
s0b0levcommented, Nov 21, 2018

@norhh got it, with the previous version I try to run bin bytecode, but I noticed that bin-runtime return right issues, when bin sometimes returns empty issues.

I check some of SWC now, looks like it works well now with bytecode from bin key.

Looks like we can close this issue, sorry for confusing. I will change the way I send swc samples to myth.

0reactions
norhhcommented, Dec 12, 2018

As calldata for contract creation transaction should be empty, added it as [] instead of None.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Crash caused by dynamic loader #1168 - ConsenSys/mythril
eth.eth_getCode(dependency_address) AttributeError: 'NoneType' object has no attribute 'eth_getCode' The analysis was completed successfully. No ...
Read more >
How to Fix AttributeError in Python
The Python AttributeError is an exception that occurs when an attribute reference or assignment fails. Learn how to fix it.
Read more >
I am stuck with an attribute error in Brownie Python
I wrote a simple code in brownie python but getting an Attribute error from brownie import accounts def deploy_simple_storage(): ...
Read more >
The AttributeError: __enter__ Python Error Solved
A Python error object (or exception) in is a problem in the code that causes the program to not work as intended and...
Read more >
[MOD] Fall from Heaven | Page 205
AttributeError : CvPediaMain instance has no attribute 'X_PEDIA_PAGE' ERR: Call function onEvent failed. Can't find module CvEventInterface
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