Skip to content

Manticore crashes if the contract to analyze produces no bytecode #1533

@gustavo-grieco

Description

@gustavo-grieco

Latest manticore revision fails to analyze this valid contract:

contract OnlyYou {

    address you;
    constructor (
        address _you
    )
        public
    {
        you = _you;
    }
    modifier OnlyYou(address from) {
       require(you == from); 
       _;
    }
}

contract Test is OnlyYou {
    constructor ()
    public
    OnlyYou(msg.sender)
    {}

}

If you try to analyze Test, manticore crashes:

$ manticore test.sol --contract Test 
2019-10-09 18:30:52,801: [4437] m.main:INFO: Registered plugins: DetectUninitializedMemory, DetectInvalid, DetectManipulableBalance, DetectIntegerOverflow, DetectSuicidal, DetectReentrancyAdvanced, DetectExternalCallAndLeak, DetectDelegatecall, DetectEnvInstruction, DetectReentrancySimple, DetectUninitializedStorage, <class 'manticore.ethereum.plugins.KeepOnlyIfStorageChanges'>, DetectUnusedRetVal
2019-10-09 18:30:52,802: [4437] m.main:INFO: Beginning analysis
2019-10-09 18:30:52,806: [4437] m.e.manticore:INFO: Starting symbolic create contract
--- Logging error ---
Traceback (most recent call last):
  File "/home/g/.local/lib/python3.6/site-packages/manticore-0.3.1-py3.6.egg/manticore/ethereum/manticore.py", line 741, in solidity_create_contract
    md = SolidityMetadata(*compile_results)
  File "/home/g/.local/lib/python3.6/site-packages/manticore-0.3.1-py3.6.egg/manticore/ethereum/solidity.py", line 90, in __init__
    self.srcmap_runtime = self.__build_source_map(self.runtime_bytecode, srcmap_runtime)
  File "/home/g/.local/lib/python3.6/site-packages/manticore-0.3.1-py3.6.egg/manticore/ethereum/solidity.py", line 118, in __build_source_map
    md.get(0, 0)
ValueError: invalid literal for int() with base 10: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/logging/__init__.py", line 994, in emit
    msg = self.format(record)
  File "/usr/lib/python3.6/logging/__init__.py", line 840, in format
    return fmt.format(record)
  File "/usr/lib/python3.6/logging/__init__.py", line 577, in format
    record.message = record.getMessage()
  File "/usr/lib/python3.6/logging/__init__.py", line 338, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "/home/g/.local/bin/manticore", line 11, in <module>
    load_entry_point('manticore==0.3.1', 'console_scripts', 'manticore')()
  File "/home/g/.local/lib/python3.6/site-packages/manticore-0.3.1-py3.6.egg/manticore/__main__.py", line 41, in main
    ethereum_main(args, logger)
  File "/home/g/.local/lib/python3.6/site-packages/manticore-0.3.1-py3.6.egg/manticore/ethereum/cli.py", line 111, in ethereum_main
    crytic_compile_args=vars(args),
  File "/home/g/.local/lib/python3.6/site-packages/manticore-0.3.1-py3.6.egg/manticore/ethereum/manticore.py", line 1181, in multi_tx_analysis
    crytic_compile_args=crytic_compile_args,
  File "/home/g/.local/lib/python3.6/site-packages/manticore-0.3.1-py3.6.egg/manticore/ethereum/manticore.py", line 792, in solidity_create_contract
    logger.info("Failed to compile contract", str(e))
Message: 'Failed to compile contract'
Arguments: ("invalid literal for int() with base 10: ''",)
2019-10-09 18:30:52,836: [4482] m.c.manticore:INFO: Generated testcase No. 0 - NO STATE RESULT (?)(0 txs)
2019-10-09 18:30:52,907: [4437] m.c.manticore:INFO: Results in /tmp/mcore_u96vav_e

However, if you specify the OnlyYou contract, it will work as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions