frida / frida-tools

Frida CLI tools
Other
338 stars 95 forks source link

test_tracer.py test_basics prints stack trace #150

Open smcpeak opened 6 months ago

smcpeak commented 6 months ago

When tests/test_tracer.py is run, the test_basics test (which is the only test) prints a stack trace:

$ python3 -m unittest -v tests/test_tracer.py 
test_basics (tests.test_tracer.TestTracer) ... Exception in thread Thread-1:
Traceback (most recent call last):
  File "/home/scott/opt/python-3.9.13/lib/python3.9/threading.py", line 980, in _bootstrap_inner
    self.run()
  File "/home/scott/opt/python-3.9.13/lib/python3.9/threading.py", line 917, in run
    self._target(*self._args, **self._kwargs)
  File "/home/scott/wrk/frida/frida-tools/frida_tools/reactor.py", line 70, in _run
    work()
  File "/home/scott/wrk/frida/frida-tools/frida_tools/tracer.py", line 363, in <lambda>
    self._reactor.schedule(lambda: self._on_message(message, data, ui))
  File "/home/scott/wrk/frida/frida-tools/frida_tools/tracer.py", line 402, in _on_message
    handled = self._try_handle_message(*params)
  File "/home/scott/wrk/frida/frida-tools/frida_tools/tracer.py", line 433, in _try_handle_message
    self._script.post(response)
AttributeError: 'NoneType' object has no attribute 'post'
ok

----------------------------------------------------------------------
Ran 1 test in 0.515s

OK

After some preliminary debugging, it seems that self._script is None at the call point because the stop method has already been called. But I can't tell if the _try_handle_message method should gracefully handle that (presumably by just returning, but True or False?) or if the problem is with the way the test works.

It's also troubling that the failure causing this stack trace to be printed does not also cause the test to fail.

frida-tools version c10668fe45 Python 3.9.13 Linux Mint 20.1