Merge changes Iddb0cb1e,Ic15e0b08,If1c9adb6

* changes:
  debuggerd_client: increase pipe buffer size to max.
  crash_dump: don't notify ActivityManager if it crashed.
  crash_dump: clear the signal mask.
This commit is contained in:
Treehugger Robot 2017-06-01 21:47:17 +00:00 committed by Gerrit Code Review
commit 2b17afc68d
3 changed files with 33 additions and 5 deletions

View file

@ -28,7 +28,9 @@
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/parseint.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
#include <android-base/unique_fd.h>
#include <cutils/sockets.h>
@ -117,6 +119,20 @@ bool debuggerd_trigger_dump(pid_t pid, DebuggerdDumpType dump_type, unsigned int
return false;
}
std::string pipe_size_str;
int pipe_buffer_size = 1024 * 1024;
if (android::base::ReadFileToString("/proc/sys/fs/pipe-max-size", &pipe_size_str)) {
pipe_size_str = android::base::Trim(pipe_size_str);
if (!android::base::ParseInt(pipe_size_str.c_str(), &pipe_buffer_size, 0)) {
LOG(FATAL) << "failed to parse pipe max size '" << pipe_size_str << "'";
}
}
if (fcntl(pipe_read.get(), F_SETPIPE_SZ, pipe_buffer_size) != pipe_buffer_size) {
PLOG(ERROR) << "failed to set pipe buffer size";
}
if (send_fd(set_timeout(sockfd), &req, sizeof(req), std::move(pipe_write)) != sizeof(req)) {
PLOG(ERROR) << "libdebuggerd_client: failed to send output fd to tombstoned";
return false;

View file

@ -41,6 +41,7 @@
#include <android-base/unique_fd.h>
#include <cutils/sockets.h>
#include <log/log.h>
#include <private/android_filesystem_config.h>
#include <procinfo/process.h>
#include "backtrace.h"
@ -99,8 +100,9 @@ static bool ptrace_seize_thread(int pid_proc_fd, pid_t tid, std::string* error)
return true;
}
static bool activity_manager_notify(int pid, int signal, const std::string& amfd_data) {
android::base::unique_fd amfd(socket_local_client("/data/system/ndebugsocket", ANDROID_SOCKET_NAMESPACE_FILESYSTEM, SOCK_STREAM));
static bool activity_manager_notify(pid_t pid, int signal, const std::string& amfd_data) {
android::base::unique_fd amfd(socket_local_client(
"/data/system/ndebugsocket", ANDROID_SOCKET_NAMESPACE_FILESYSTEM, SOCK_STREAM));
if (amfd.get() == -1) {
PLOG(ERROR) << "unable to connect to activity manager";
return false;
@ -207,9 +209,14 @@ int main(int argc, char** argv) {
action.sa_handler = signal_handler;
debuggerd_register_handlers(&action);
sigset_t mask;
sigemptyset(&mask);
if (sigprocmask(SIG_SETMASK, &mask, nullptr) != 0) {
PLOG(FATAL) << "failed to set signal mask";
}
if (argc != 4) {
LOG(FATAL) << "Wrong number of args: " << argc << " (expected 4)";
return 1;
}
pid_t main_tid;
@ -264,7 +271,7 @@ int main(int argc, char** argv) {
}
// Die if we take too long.
alarm(20);
alarm(2);
std::string attach_error;
@ -408,7 +415,10 @@ int main(int argc, char** argv) {
}
if (fatal_signal) {
activity_manager_notify(target, signo, amfd_data);
// Don't try to notify ActivityManager if it just crashed, or we might hang until timeout.
if (target_info.name != "system_server" || target_info.uid != AID_SYSTEM) {
activity_manager_notify(target, signo, amfd_data);
}
}
// Close stdout before we notify tombstoned of completion.

View file

@ -119,6 +119,8 @@ static void tombstoned_intercept(pid_t target_pid, unique_fd* intercept_fd, uniq
FAIL() << "failed to set pipe size: " << strerror(errno);
}
ASSERT_GE(pipe_buffer_size, 1024 * 1024);
if (send_fd(intercept_fd->get(), &req, sizeof(req), std::move(output_pipe_write)) != sizeof(req)) {
FAIL() << "failed to send output fd to tombstoned: " << strerror(errno);
}