google / atheris

Apache License 2.0
1.38k stars 111 forks source link

Unable to cast Python instance to C++ #49

Closed aduquet closed 1 year ago

aduquet commented 1 year ago

Hi,

I am exploring Atheris; I followed all the steps described in the Repo. However, when executing: python3 example_fuzzers/custom_mutator_example.py appears:

Traceback (most recent call last):
  File "/Users/alduck/Documents/GitHub/Exploring-atheris/example_fuzzers/custom_mutator_example.py", line 75, in <module>
    atheris.Setup(sys.argv, TestOneInput, custom_mutator='CustomMutator')
RuntimeError: Unable to cast Python instance to C++ type (#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for details)

I googled around and found one answer . It suggests pinning the Atheris version OSS-Fuzz to the latest; however, I am not using OSS-Fuzz. I am just running the example from the Atheris repo.

TheShiftedBit commented 1 year ago

Can you confirm which version you have installed?

aduquet commented 1 year ago

I have installed the version 2.1.1

volpino commented 1 year ago

Can you please provide the steps you took?

On a clean debian-like machine I did:

sudo apt install clang git
git clone https://github.com/google/atheris.git
cd atheris
pip3 install .
python3 example_fuzzers/custom_mutator_example.py

The example worked fine. I wonder if the issue could be related to macOS (which I think could be the differentiating factor between my test and yours, by looking at the path in your stacktrace).

aduquet commented 1 year ago

Well, I was thinking the same, it could be related to macOS...

I followed the steps provided by macOS

# Building LLVM
git clone https://github.com/llvm/llvm-project.git
cd llvm-project
mkdir build
cd build
cmake -DLLVM_ENABLE_PROJECTS='clang;compiler-rt' -G "Unix Makefiles" ../llvm
make -j 10  # This step is very slow

# Installing Atheris
CLANG_BIN="$(pwd)/bin/clang" pip3 install atheris
TheShiftedBit commented 1 year ago

I'm investigating mac.

TheShiftedBit commented 1 year ago

Hmmm, I can't reproduce on Mac either. Ran with Python 3.10, clang 15.0.0, and the latest release of pybind11.

TheShiftedBit commented 1 year ago

Back from vacation, I made prebuilt releases of the latest version for Mac.

TheShiftedBit commented 1 year ago

Closing this issue as not reproducible. Please comment if you have more information that might help me reproduce it.