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.68k stars 472 forks source link

Support for Python >3.10 #2577

Open anudit opened 2 years ago

anudit commented 2 years ago

Summary of the problem

Running Manticore on Python 3.10.4 runs into the following error,

Traceback (most recent call last):
  File "/home/codespace/.python/current/bin/manticore", line 5, in <module>
    from manticore.__main__ import main
  File "/opt/python/latest/lib/python3.10/site-packages/manticore/__main__.py", line 13, in <module>
    from .wasm.cli import wasm_main
  File "/opt/python/latest/lib/python3.10/site-packages/manticore/wasm/__init__.py", line 1, in <module>
    from .manticore import ManticoreWASM
  File "/opt/python/latest/lib/python3.10/site-packages/manticore/wasm/manticore.py", line 9, in <module>
    from .types import I32, I64, F32, F64
  File "/opt/python/latest/lib/python3.10/site-packages/manticore/wasm/types.py", line 5, in <module>
    import wasm
  File "/opt/python/latest/lib/python3.10/site-packages/wasm/__init__.py", line 5, in <module>
    from .decode import (
  File "/opt/python/latest/lib/python3.10/site-packages/wasm/decode.py", line 5, in <module>
    from .modtypes import ModuleHeader, Section, SEC_UNK, SEC_NAME, NameSubSection
  File "/opt/python/latest/lib/python3.10/site-packages/wasm/modtypes.py", line 4, in <module>
    from .wasmtypes import *
  File "/opt/python/latest/lib/python3.10/site-packages/wasm/wasmtypes.py", line 4, in <module>
    from .types import UIntNField, UnsignedLeb128Field, SignedLeb128Field
  File "/opt/python/latest/lib/python3.10/site-packages/wasm/types.py", line 296, in <module>
    class Structure(WasmField):
  File "/opt/python/latest/lib/python3.10/site-packages/wasm/compat.py", line 26, in wrapper
    return metaclass(cls.__name__, cls.__bases__, orig_vars)
  File "/opt/python/latest/lib/python3.10/site-packages/wasm/types.py", line 264, in __new__
    isinstance(cur_field, collections.Callable) or
AttributeError: module 'collections' has no attribute 'Callable'

Error seems reasonable as Callable was removed from the collections module and moved to collections.abc.Callable in 3.10 https://docs.python.org/3/whatsnew/3.10.html#collections-abc

Manticore version

Version: 0.3.7

Python version

Python 3.10.4

OS / Environment

No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.4 LTS Release: 20.04 Codename: focal

Step to reproduce the behavior

Expected behavior

Manticore runs.

Actual behavior

Manticore fails with error.

ekilmer commented 2 years ago

Thank you for the report and details. Unfortunately, it looks like that dependency is no longer maintained https://github.com/athre0z/wasm

We'll need to find a new dependency for web assembly to fix this issue.

bhoomishah20 commented 2 years ago

@ekilmer @anudit Hi do you guys have any way that could solve this issue? Do I need to install older version of python to install manticore and run sol file? Since I tried with version 2.7 and getting same errors.

ekilmer commented 2 years ago

@bhoomishah20 Please use any Python version 3.7, 3.8, or 3.9. We test Manticore in CI with Python 3.7.

Rajatrs96 commented 1 year ago

@ekilmer I am also getting same error, infact I am using Python version 3.9 still getting below error. Any idea how to resolve this and execute the manticore using sol file?

(base)MacBook-Air-2 contracts % manticore imp.sol 2022-10-10 23:41:59,710: [94266] m.c.manticore:WARNING: Manticore is only supported on Linux. Proceed at your own risk! 2022-10-10 23:42:00,239: [94266] m.main:INFO: Registered plugins: IntrospectionAPIPlugin, <class 'manticore.ethereum.plugins.SkipRevertBasicBlocks'>, <class 'manticore.ethereum.plugins.FilterFunctions'> 2022-10-10 23:42:00,239: [94266] m.main:INFO: Beginning analysis 2022-10-10 23:42:00,243: [94266] m.e.manticore:INFO: Starting symbolic create contract 2022-10-10 23:42:00,561: [94266] m.e.manticore:INFO: Starting symbolic transaction: 0 2022-10-10 23:42:00,608: [94266] m.e.manticore:INFO: 0 alive states, 2 terminated states Traceback (most recent call last): File "/Users/opt/anaconda3/bin/manticore", line 8, in sys.exit(main()) File "/Users/opt/anaconda3/lib/python3.9/site-packages/manticore/main.py", line 42, in main ethereum_main(args, logger) File "/Users/opt/anaconda3/lib/python3.9/site-packages/manticore/ethereum/cli.py", line 145, in ethereum_main m.finalize(only_alive_states=args.only_alive_testcases) File "/Users/opt/anaconda3/lib/python3.9/site-packages/manticore/core/manticore.py", line 177, in newFunction return func(self, *args, **kw) File "/Users/opt/anaconda3/lib/python3.9/site-packages/manticore/ethereum/manticore.py", line 1778, in finalize proc.start() File "/Users/opt/anaconda3/lib/python3.9/multiprocessing/process.py", line 121, in start self._popen = self._Popen(self) File "/Users/opt/anaconda3/lib/python3.9/multiprocessing/context.py", line 224, in _Popen return _default_context.get_context().Process._Popen(process_obj) File "/Users/opt/anaconda3/lib/python3.9/multiprocessing/context.py", line 284, in _Popen return Popen(process_obj) File "/Users/opt/anaconda3/lib/python3.9/multiprocessing/popen_spawn_posix.py", line 32, in init super().init(process_obj) File "/Users/opt/anaconda3/lib/python3.9/multiprocessing/popen_fork.py", line 19, in init self._launch(process_obj) File "/Users/opt/anaconda3/lib/python3.9/multiprocessing/popen_spawn_posix.py", line 47, in _launch reduction.dump(process_obj, fp) File "/Users/opt/anaconda3/lib/python3.9/multiprocessing/reduction.py", line 60, in dump ForkingPickler(file, protocol).dump(obj) AttributeError: Can't pickle local object 'ManticoreEVM.finalize..worker_finalize'

ekilmer commented 1 year ago

@Rajatrs96 Your error is different. I mention in https://github.com/trailofbits/manticore/issues/2496#issuecomment-1263567766 that this error does not appear when running with Python 3.7.

mbaraniak-doyensec commented 1 year ago

There is a work around here: https://stackoverflow.com/questions/69515086/error-attributeerror-collections-has-no-attribute-callable-using-beautifu (just line number should be 264)

`

Change lib/python3.10/site-packages/wasm/types.py:264

isinstance(cur_field, collections.Callable) to isinstance(cur_field, collections.abc.Callable) `

balqaasem commented 1 year ago

Still having the same issue

There is a work around here: https://stackoverflow.com/questions/69515086/error-attributeerror-collections-has-no-attribute-callable-using-beautifu (just line number should be 264)

#Change lib/python3.10/site-packages/wasm/types.py:264 isinstance(cur_field, collections.Callable) to isinstance(cur_field, collections.abc.Callable)

Still having the same issue.