diff options
author | Elliott Hughes <enh@google.com> | 2023-08-11 01:56:02 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-08-11 01:56:02 +0000 |
commit | 1317aa642182906c0d8ab5496dd3025632e22022 (patch) | |
tree | f98d11d6a158167e19fc9141c79d877280a616a6 /src/client/linux/handler | |
parent | 8d0176459cfc11e28e9427a7eadcf7a42f654f62 (diff) | |
parent | c9c160dbfd52b61faae9473c1b18c1a0f7869908 (diff) | |
download | google-breakpad-1317aa642182906c0d8ab5496dd3025632e22022.tar.gz |
Upgrade google-breakpad to v2023.01.27 am: 332a4371ed am: c3c25b3748 am: 4e7c6460d7 am: c9c160dbfd
Original change: https://android-review.googlesource.com/c/platform/external/google-breakpad/+/2704174
Change-Id: I95bc0a6692c028156ded7502fadc728415e92f38
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'src/client/linux/handler')
-rw-r--r-- | src/client/linux/handler/exception_handler.cc | 26 | ||||
-rw-r--r-- | src/client/linux/handler/exception_handler.h | 23 | ||||
-rw-r--r-- | src/client/linux/handler/exception_handler_unittest.cc | 37 | ||||
-rw-r--r-- | src/client/linux/handler/microdump_extra_info.h | 5 | ||||
-rw-r--r-- | src/client/linux/handler/minidump_descriptor.cc | 5 | ||||
-rw-r--r-- | src/client/linux/handler/minidump_descriptor.h | 6 |
6 files changed, 58 insertions, 44 deletions
diff --git a/src/client/linux/handler/exception_handler.cc b/src/client/linux/handler/exception_handler.cc index c65feaa1..bbdb798b 100644 --- a/src/client/linux/handler/exception_handler.cc +++ b/src/client/linux/handler/exception_handler.cc @@ -1,5 +1,4 @@ -// Copyright (c) 2010 Google Inc. -// All rights reserved. +// Copyright 2010 Google LLC // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -11,7 +10,7 @@ // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. -// * Neither the name of Google Inc. nor the names of its +// * Neither the name of Google LLC nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // @@ -138,7 +137,7 @@ void InstallAlternateStackLocked() { // SIGSTKSZ may be too small to prevent the signal handlers from overrunning // the alternative stack. Ensure that the size of the alternative stack is // large enough. - static const unsigned kSigStackSize = std::max(16384, SIGSTKSZ); + const unsigned kSigStackSize = std::max<unsigned>(16384, SIGSTKSZ); // Only set an alternative stack if there isn't already one, or if the current // one is too small. @@ -419,8 +418,8 @@ struct ThreadArgument { // This is the entry function for the cloned process. We are in a compromised // context here: see the top of the file. // static -int ExceptionHandler::ThreadEntry(void *arg) { - const ThreadArgument *thread_arg = reinterpret_cast<ThreadArgument*>(arg); +int ExceptionHandler::ThreadEntry(void* arg) { + const ThreadArgument* thread_arg = reinterpret_cast<ThreadArgument*>(arg); // Close the write end of the pipe. This allows us to fail if the parent dies // while waiting for the continue signal. @@ -461,10 +460,7 @@ bool ExceptionHandler::HandleSignal(int /*sig*/, siginfo_t* info, void* uc) { memcpy(&g_crash_context_.float_state, fp_ptr, sizeof(g_crash_context_.float_state)); } -#elif !defined(__ARM_EABI__) && !defined(__mips__) - // FP state is not part of user ABI on ARM Linux. - // In case of MIPS Linux FP state is already part of ucontext_t - // and 'float_state' is not a member of CrashContext. +#elif GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE ucontext_t* uc_ptr = (ucontext_t*)uc; if (uc_ptr->uc_mcontext.fpregs) { memcpy(&g_crash_context_.float_state, uc_ptr->uc_mcontext.fpregs, @@ -495,7 +491,7 @@ bool ExceptionHandler::SimulateSignalDelivery(int sig) { } // This function may run in a compromised context: see the top of the file. -bool ExceptionHandler::GenerateDump(CrashContext *context) { +bool ExceptionHandler::GenerateDump(CrashContext* context) { if (IsOutOfProcess()) return crash_generation_client_->RequestDump(context, sizeof(*context)); @@ -701,8 +697,7 @@ bool ExceptionHandler::WriteMinidump() { } #endif -#if !defined(__ARM_EABI__) && !defined(__aarch64__) && !defined(__mips__) - // FPU state is not part of ARM EABI ucontext_t. +#if GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE && !defined(__aarch64__) memcpy(&context.float_state, context.context.uc_mcontext.fpregs, sizeof(context.float_state)); #endif @@ -726,8 +721,11 @@ bool ExceptionHandler::WriteMinidump() { #elif defined(__mips__) context.siginfo.si_addr = reinterpret_cast<void*>(context.context.uc_mcontext.pc); +#elif defined(__riscv) + context.siginfo.si_addr = + reinterpret_cast<void*>(context.context.uc_mcontext.__gregs[REG_PC]); #else -#error "This code has not been ported to your platform yet." +# error "This code has not been ported to your platform yet." #endif return GenerateDump(&context); diff --git a/src/client/linux/handler/exception_handler.h b/src/client/linux/handler/exception_handler.h index f44483ff..f8bc1ead 100644 --- a/src/client/linux/handler/exception_handler.h +++ b/src/client/linux/handler/exception_handler.h @@ -1,5 +1,4 @@ -// Copyright (c) 2010 Google Inc. -// All rights reserved. +// Copyright 2010 Google LLC // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -11,7 +10,7 @@ // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. -// * Neither the name of Google Inc. nor the names of its +// * Neither the name of Google LLC nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // @@ -44,6 +43,15 @@ #include "common/using_std_string.h" #include "google_breakpad/common/minidump_format.h" +#if !defined(__ARM_EABI__) && !defined(__mips__) && !defined(__riscv) +// FP state is not part of user ABI for Linux ARM. +// In case of MIPS and RISCV Linux FP state is already part of ucontext_t +// so 'float_state' is not required. +# define GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE 1 +#else +# define GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE 0 +#endif + namespace google_breakpad { // ExceptionHandler @@ -82,7 +90,7 @@ class ExceptionHandler { // attempting to write a minidump. If a FilterCallback returns false, // Breakpad will immediately report the exception as unhandled without // writing a minidump, allowing another handler the opportunity to handle it. - typedef bool (*FilterCallback)(void *context); + typedef bool (*FilterCallback)(void* context); // A callback function to run after the minidump has been written. // |descriptor| contains the file descriptor or file path containing the @@ -192,10 +200,7 @@ class ExceptionHandler { siginfo_t siginfo; pid_t tid; // the crashing thread. ucontext_t context; -#if !defined(__ARM_EABI__) && !defined(__mips__) - // #ifdef this out because FP state is not part of user ABI for Linux ARM. - // In case of MIPS Linux FP state is already part of ucontext_t so - // 'float_state' is not required. +#if GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE fpstate_t float_state; #endif }; @@ -234,7 +239,7 @@ class ExceptionHandler { static void RestoreHandlersLocked(); void PreresolveSymbols(); - bool GenerateDump(CrashContext *context); + bool GenerateDump(CrashContext* context); void SendContinueSignalToChild(); void WaitForContinueSignal(); diff --git a/src/client/linux/handler/exception_handler_unittest.cc b/src/client/linux/handler/exception_handler_unittest.cc index 27808aa1..691ea133 100644 --- a/src/client/linux/handler/exception_handler_unittest.cc +++ b/src/client/linux/handler/exception_handler_unittest.cc @@ -1,5 +1,4 @@ -// Copyright (c) 2010 Google Inc. -// All rights reserved. +// Copyright 2010 Google LLC // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -11,7 +10,7 @@ // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. -// * Neither the name of Google Inc. nor the names of its +// * Neither the name of Google LLC nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // @@ -201,7 +200,7 @@ static bool DoneCallback(const MinidumpDescriptor& descriptor, // optimize them out. In the case of ExceptionHandlerTest::ExternalDumper, // GCC-4.9 optimized out the entire set up of ExceptionHandler, causing // test failure. -volatile int *p_null; // external linkage, so GCC can't tell that it +volatile int* p_null; // external linkage, so GCC can't tell that it // remains NULL. Volatile just for a good measure. static void DoNullPointerDereference() { *p_null = 1; @@ -306,8 +305,22 @@ TEST(ExceptionHandlerTest, ParallelChildCrashesDontHang) { } } - // Wait a while until the child should have crashed. - usleep(1000000); + // Poll the child to see if it crashed. + int status, wp_pid; + for (int i = 0; i < 100; i++) { + wp_pid = HANDLE_EINTR(waitpid(child, &status, WNOHANG)); + ASSERT_NE(-1, wp_pid); + if (wp_pid > 0) { + ASSERT_TRUE(WIFSIGNALED(status)); + // If the child process terminated by itself, + // it will have returned SIGSEGV. + ASSERT_EQ(SIGSEGV, WTERMSIG(status)); + return; + } else { + usleep(100000); + } + } + // Kill the child if it is still running. kill(child, SIGKILL); @@ -649,7 +662,7 @@ TEST(ExceptionHandlerTest, InstructionPointerMemory) { memset(prefix_bytes, 0, sizeof(prefix_bytes)); memset(suffix_bytes, 0, sizeof(suffix_bytes)); EXPECT_TRUE(memcmp(bytes, prefix_bytes, sizeof(prefix_bytes)) == 0); - EXPECT_TRUE(memcmp(bytes + kOffset, kIllegalInstruction, + EXPECT_TRUE(memcmp(bytes + kOffset, kIllegalInstruction, sizeof(kIllegalInstruction)) == 0); EXPECT_TRUE(memcmp(bytes + kOffset + sizeof(kIllegalInstruction), suffix_bytes, sizeof(suffix_bytes)) == 0); @@ -738,7 +751,7 @@ TEST(ExceptionHandlerTest, InstructionPointerMemoryMinBound) { uint8_t suffix_bytes[kMemorySize / 2 - sizeof(kIllegalInstruction)]; memset(suffix_bytes, 0, sizeof(suffix_bytes)); - EXPECT_TRUE(memcmp(bytes + kOffset, kIllegalInstruction, + EXPECT_TRUE(memcmp(bytes + kOffset, kIllegalInstruction, sizeof(kIllegalInstruction)) == 0); EXPECT_TRUE(memcmp(bytes + kOffset + sizeof(kIllegalInstruction), suffix_bytes, sizeof(suffix_bytes)) == 0); @@ -994,7 +1007,7 @@ CrashHandler(const void* crash_context, size_t crash_context_size, msg.msg_control = cmsg; msg.msg_controllen = sizeof(cmsg); - struct cmsghdr *hdr = CMSG_FIRSTHDR(&msg); + struct cmsghdr* hdr = CMSG_FIRSTHDR(&msg); hdr->cmsg_level = SOL_SOCKET; hdr->cmsg_type = SCM_RIGHTS; hdr->cmsg_len = CMSG_LEN(sizeof(int)); @@ -1003,7 +1016,7 @@ CrashHandler(const void* crash_context, size_t crash_context_size, hdr->cmsg_level = SOL_SOCKET; hdr->cmsg_type = SCM_CREDENTIALS; hdr->cmsg_len = CMSG_LEN(sizeof(struct ucred)); - struct ucred *cred = reinterpret_cast<struct ucred*>(CMSG_DATA(hdr)); + struct ucred* cred = reinterpret_cast<struct ucred*>(CMSG_DATA(hdr)); cred->uid = getuid(); cred->gid = getgid(); cred->pid = getpid(); @@ -1056,7 +1069,7 @@ TEST(ExceptionHandlerTest, ExternalDumper) { pid_t crashing_pid = -1; int signal_fd = -1; - for (struct cmsghdr *hdr = CMSG_FIRSTHDR(&msg); hdr; + for (struct cmsghdr* hdr = CMSG_FIRSTHDR(&msg); hdr; hdr = CMSG_NXTHDR(&msg, hdr)) { if (hdr->cmsg_level != SOL_SOCKET) continue; @@ -1066,7 +1079,7 @@ TEST(ExceptionHandlerTest, ExternalDumper) { ASSERT_EQ(sizeof(int), len); signal_fd = *(reinterpret_cast<int*>(CMSG_DATA(hdr))); } else if (hdr->cmsg_type == SCM_CREDENTIALS) { - const struct ucred *cred = + const struct ucred* cred = reinterpret_cast<struct ucred*>(CMSG_DATA(hdr)); crashing_pid = cred->pid; } diff --git a/src/client/linux/handler/microdump_extra_info.h b/src/client/linux/handler/microdump_extra_info.h index bf01f0c7..1da69d09 100644 --- a/src/client/linux/handler/microdump_extra_info.h +++ b/src/client/linux/handler/microdump_extra_info.h @@ -1,5 +1,4 @@ -// Copyright 2015 Google Inc. -// All rights reserved. +// Copyright 2015 Google LLC // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -11,7 +10,7 @@ // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. -// * Neither the name of Google Inc. nor the names of its +// * Neither the name of Google LLC nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // diff --git a/src/client/linux/handler/minidump_descriptor.cc b/src/client/linux/handler/minidump_descriptor.cc index bd94474e..517fce97 100644 --- a/src/client/linux/handler/minidump_descriptor.cc +++ b/src/client/linux/handler/minidump_descriptor.cc @@ -1,5 +1,4 @@ -// Copyright (c) 2012 Google Inc. -// All rights reserved. +// Copyright 2012 Google LLC // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -11,7 +10,7 @@ // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. -// * Neither the name of Google Inc. nor the names of its +// * Neither the name of Google LLC nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // diff --git a/src/client/linux/handler/minidump_descriptor.h b/src/client/linux/handler/minidump_descriptor.h index c7e4f2b3..d822c9d9 100644 --- a/src/client/linux/handler/minidump_descriptor.h +++ b/src/client/linux/handler/minidump_descriptor.h @@ -1,5 +1,4 @@ -// Copyright (c) 2012 Google Inc. -// All rights reserved. +// Copyright 2012 Google LLC // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -11,7 +10,7 @@ // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. -// * Neither the name of Google Inc. nor the names of its +// * Neither the name of Google LLC nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // @@ -33,6 +32,7 @@ #include <assert.h> #include <sys/types.h> +#include <cstdint> #include <string> #include "client/linux/handler/microdump_extra_info.h" |