8000 linux: Don't let the crash monitor's logcat inherit our stdin by tubibibo · Pull Request #1289 · frida/frida-core · GitHub
[go: up one dir, main page]

Skip to content

linux: Don't let the crash monitor's logcat inherit our stdin - #1289

Open
tubibibo wants to merge 1 commit into
frida:mainfrom
tubibibo:fix/crash-monitor-logcat-stdin
Open

tubibibo wants to merge 1 commit into
frida:mainfrom
tubibibo:fix/crash-monitor-logcat-stdin

Conversation

@tubibibo
@tubibibo tubibibo commented Nov 6, 2026
Copy link
Copy Markdown
Contributor

When frida-server is started as adb shell /data/local/tmp/frida-server, adbd
hands it a single socket for both stdin and stdout. The crash monitor then
starts logcat -b crash -B with STDIN_INHERIT, so logcat ends up holding a
copy of that socket.

If frida-server dies abnormally (SIGKILL, SIGSEGV), logcat is reparented to
init but keeps holding that socket, so the host-side adb shell keeps waiting
instead of returning.

The crash monitor has no use for frida-server's stdin, so don't inherit it.
With neither STDIN_INHERIT nor STDIN_PIPE set, GSubprocess hands the child
/dev/null.

This change only affects the GSubprocess fallback; the SuperSU spawning path
is unchanged.

Fixes #1288.

Verification

Originally reported on an Android 16 x86_64 emulator (API 36) with
frida-server 17.26.0, where SIGKILL and SIGSEGV behave the same.

Reproduced here on an Android 14 x86_64 emulator (LDPlayer), frida-server
17.24.1, SIGKILL, over adb:

logcat's fd 0 after kill -9 of frida-server
current code socket:[47368] — the same socket as frida-server's fd 0 and fd 1 logcat reparented to init, still holding the socket; the host's adb shell client stayed alive until logcat was killed, then exited 137
started with </dev/null (control) /dev/null the host's adb shell client exited immediately with 137, even though logcat was left running

The control only changes the stdin setup; it establishes the mechanism, not the
patched binary.

Finally, the GLib semantics the patch relies on, checked by spawning through
GSubprocess on Linux:

flags child's fd 0
STDIN_INHERIT | STDOUT_PIPE | STDERR_SILENCE inherited from the parent
STDOUT_PIPE | STDERR_SILENCE /dev/null

I couldn't build frida-core on this machine (no Vala/meson toolchain), so the
patched frida-server itself was not built or run.

When frida-server runs under `adb shell`, its stdin and stdout are the same
socket. The crash monitor's logcat inherited that socket, so when frida-server
died abnormally, logcat kept it open and the host's `adb shell` never saw EOF.

Let the child get /dev/null for stdin instead, like it would without
STDIN_INHERIT. Logcat has no use for stdin anyway.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android: a crashed frida-server leaves adb shell hanging, because its crash monitor's logcat inherits stdin

1 participant

0