Repository navigation
Description
What happens
Frida Gadget 17.22.0 (QuickJS) is loaded into an Android app. The JS script attaches Interceptor to android_dlopen_ext / dlopen.
The host then does fork() without exec, and the parent waitpid()s. The child continues and hits the hooked loader. The JS onEnter tries to take the QuickJS recursive mutex that still belongs to a parent thread that does not exist in the child. The child never returns. The parent sits in waitpid forever. From the outside the app just freezes on the first Activity / splash. The process is still alive. No SIGSEGV.
Environment
- Device: Google Pixel 5 (
redfin) - OS: Android 14, API 34
- ABI:
arm64-v8a - Frida: Gadget 17.22.0, default QuickJS runtime
- Gadget loaded in-process (script or listen interaction, both hit it)
- Stacks taken with
debuggerdwhile hung
Same hang with an embedded script on the same Gadget build.
Minimal script
agent.js:
const dl = Module.findExportByName("libdl.so", "android_dlopen_ext")
|| Module.findExportByName("libdl.so", "dlopen")
|| Module.findExportByName("libc.so", "dlopen");
Interceptor.attach(dl, {
onEnter(args) {
try {
this.path = args[0].isNull() ? null : args[0].readUtf8String();
} catch (e) {
this.path = null;
}
},
onLeave() {
}
});Host side that hangs
Any in-process fork() + waitpid after that hook is enough:
#include <dlfcn.h>
#include <sys/wait.h>
#include <unistd.h>
void probe(void) {
pid_t pid = fork();
if (pid == 0) {
void *h = dlopen("libandroid.so", RTLD_NOW);
if (h != NULL)
dlclose(h);
_exit(0);
}
int status;
waitpid(pid, &status, 0); /* never returns */
}On a real app this is often some JNI helper that forks a child to poke the filesystem, then waits. Same shape: parent stuck in wait4, child never exits.
Stacks while hung
Parent, main thread:
wait4
__waitpid
<app function that called fork + wait>
...
android.app.Activity.onCreate
Child of that fork:
futex / pthread_mutex_lock
g_rec_mutex_lock
_gum_quick_scope_enter bindings/gumjs/gumquickcore.c
gum_quick_js_call_listener_on_enter bindings/gumjs/gumquickinterceptor.c
<Gum interceptor trampoline>
android_dlopen_ext / dlopen
_gum_quick_scope_enter does g_rec_mutex_lock (core->mutex):
https://github.com/frida/frida-gum/blob/17.22.0/bindings/gumjs/gumquickcore.c
After fork() without exec, only the forking thread exists in the child. The QuickJS mutex still looks owned by the original JS thread from the parent. The child blocks forever.
Why 17.22 shows this more than 17.17
The deadlock is JS interceptor + fork, not a new QuickJS compiler bug. Gadget also has no ForkMonitor (frida-agent does, in frida-core/lib/payload/fork-monitor.vala).
17.22 made it much easier to hit because every interceptor enter now identifies the stack with gum_memory_query_region():
interceptor_thread_context_identify_stack()
-> gum_memory_query_region(byte_below_sp, ...)On Linux/Android that path opens /proc/self/maps and may ioctl(PROCMAP_QUERY) (gum/backend-linux/gummemory-linux.c). 17.17 first used gum_thread_try_get_ranges() and usually stayed on the pthread stack range.
So on 17.22, a hooked dlopen in the fork child does extra map queries and then still enters the JS listener. That is enough to grab the copied QuickJS mutex and never come back. Parent waitpid hangs. On 17.17 the same app often did not take this path, so it looked fine.
This is separate from the stackful-coroutine SIGSEGV in #1142 / #1149. That one is fixed in 17.22. This is a hang, not a crash.
What I would expect
Either:
- JS interceptor listeners should not run in a
fork()child (untilexec, or until the runtime is re-inited), or - Gadget should reset / drop the QuickJS rec-mutex on
pthread_atforkchild, same idea as agentForkMonitor.
Native interceptor itself is fine. The hang is specifically "JS listener + fork child + parent waiting".
Related, not the same
- frida-gum#275 — Duktape scope deadlock on
pthread close, not fork - frida hangs when in forked process frida#2721 — Python multiprocessing + frida-server
- How to hook forked processes in Android? frida#695 — hooking forked processes
- Child Gating and/or vFork Hook problem. (SIGSEGV) / (SIGBUS) frida#1442 — child-gating / vfork SIGSEGV
Happy to provide more traces if useful.
Activity