google / atheris

Apache License 2.0
1.38k stars 111 forks source link

Fails to import base64 #31

Closed ghost closed 2 years ago

ghost commented 2 years ago
INFO: Instrumenting base64
Traceback (most recent call last):
  File "/home/hex/fuzz/test.py", line 5, in <module>
    import base64
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 879, in exec_module
  File "/home/hex/.local/lib/python3.10/site-packages/atheris/import_hook.py", line 196, in get_code
    return patch_code(code, self._trace_dataflow)
  File "/home/hex/.local/lib/python3.10/site-packages/atheris/instrument_bytecode.py", line 756, in patch_code
    inst.consts[i] = patch_code(inst.consts[i], trace_dataflow, nested=True)
  File "/home/hex/.local/lib/python3.10/site-packages/atheris/instrument_bytecode.py", line 758, in patch_code
    return inst.to_code()
  File "/home/hex/.local/lib/python3.10/site-packages/atheris/instrument_bytecode.py", line 457, in to_code
    self._check_state()
  File "/home/hex/.local/lib/python3.10/site-packages/atheris/instrument_bytecode.py", line 372, in _check_state
    listing[i].check_state()
  File "/home/hex/.local/lib/python3.10/site-packages/atheris/instrument_bytecode.py", line 208, in check_state
    assert jump_arg_bytes(self.arg) == self.reference
AssertionError
import sys
import atheris

with atheris.instrument_imports():
  import base64

def testinput(data):
  base64.encode(data)

atheris.Setup(sys.argv, testinput)
atheris.Fuzz()
TheShiftedBit commented 2 years ago

Looks to be the same issue as https://github.com/google/atheris/issues/30, a Python 3.10-specific bug. (3.10 changed the way opcodes function).

TheShiftedBit commented 2 years ago

Issue fixed and released as 2.0.11.