-
-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get_device() stuck in python child process #176
Comments
👍 Minimum reproducible example: import frida
import logging
from multiprocessing import Process
from threading import Thread
logging.basicConfig(level=logging.INFO, format='%(processName)s %(threadName)s %(message)s')
def list_devs():
logging.info("listing devices...")
logging.info("got these devices: %s", frida.enumerate_devices())
list_devs()
p = Process(target=list_devs, name="ChildProcess")
p.start()
t = Thread(target=list_devs, name="ChildThread")
t.start()
t.join()
logging.info("thread joined")
p.join()
loggin.info("process joined") output:
|
I managed to get the stack trace of the hung process on
Maybe the AsyncTask class isn't meant to be shared among processes but only threads. EDIT I think the "solution" here is to specify in the documentation that, as Frida is a multi-thread library, forking is not supported. |
A (likely nasty) workaround for those getting here like me and finding they can't use Frida from a Python thread/process - even if you aren't doing any sort of multi-threaded work with it (i.e sharing Frida objects/devices/etc across threads). It seems what makes things break here is that So if you do the So instead of:
do:
I haven't dug more on why this happens, if my theory is correct sounds like a fix for this could be to make a way for the bindings to not have this global state initiated implicitly on the import, but rather expose a way of initializing the "Frida context" separately somehow. Caveat emptor, this only enabled my use of running a single Frida invocation within a thread of a single script, which I'd argue is not really multi-threaded usage from Frida's perspective as all of my Frida usage is happening from the same thread. |
Use get_device() in child thread is fine, however, if I call it in child process, it will be stuck without any log.
The text was updated successfully, but these errors were encountered: