From 218f7fb68e219884f6eec9714afb4da691450bc5 Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Fri, 7 Oct 2016 16:42:05 -0700 Subject: debuggerd: report crashes even when out of file descriptors. Use nasty clone hacks to let us close random file descriptors to be able to connect to debuggerd when the fd table is full. Bug: http://b/32013594 Test: crasher exhaustfd-SIGSEGV Change-Id: I47772e9a5994da4473bd935b105d9c36827c017a --- debuggerd/debuggerd.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'debuggerd/debuggerd.cpp') diff --git a/debuggerd/debuggerd.cpp b/debuggerd/debuggerd.cpp index a6d3d382e..b8a62a583 100644 --- a/debuggerd/debuggerd.cpp +++ b/debuggerd/debuggerd.cpp @@ -69,6 +69,7 @@ struct debugger_request_t { debugger_action_t action; pid_t pid, tid; uid_t uid, gid; + pid_t ignore_tid; uintptr_t abort_msg_address; }; @@ -215,6 +216,7 @@ static int read_request(int fd, debugger_request_t* out_request) { out_request->action = static_cast(msg.action); out_request->tid = msg.tid; + out_request->ignore_tid = msg.ignore_tid; out_request->pid = cr.pid; out_request->uid = cr.uid; out_request->gid = cr.gid; @@ -408,7 +410,7 @@ static void redirect_to_32(int fd, debugger_request_t* request) { } #endif -static void ptrace_siblings(pid_t pid, pid_t main_tid, std::set& tids) { +static void ptrace_siblings(pid_t pid, pid_t main_tid, pid_t ignore_tid, std::set& tids) { char task_path[64]; snprintf(task_path, sizeof(task_path), "/proc/%d/task", pid); @@ -434,7 +436,7 @@ static void ptrace_siblings(pid_t pid, pid_t main_tid, std::set& tids) { continue; } - if (tid == main_tid) { + if (tid == main_tid || tid == ignore_tid) { continue; } @@ -583,7 +585,7 @@ static void worker_process(int fd, debugger_request_t& request) { std::set siblings; if (!attach_gdb) { - ptrace_siblings(request.pid, request.tid, siblings); + ptrace_siblings(request.pid, request.tid, request.ignore_tid, siblings); } // Generate the backtrace map before dropping privileges. -- cgit v1.2.3