aboutsummaryrefslogtreecommitdiff
path: root/src/client/linux
Commit message (Collapse)AuthorAgeFilesLines
* CopyFile: add a C++ APIMike Frysinger2020-09-071-1/+1
| | | | | | | | Having to swizzle to C strings all the time is a bit annoying. Change-Id: I0b80877706e32e873e567685f6b471745da70311 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2396557 Reviewed-by: Mark Mentovai <mark@chromium.org>
* fix pointer style to match the style guideMike Frysinger2020-07-1519-59/+59
| | | | | | | | | | We do this in a lot of places, but we're inconsistent. Normalize the code to the Google C++ style guide. Change-Id: Ic2aceab661ce8f6b993dda21b1cdf5d2198dcbbf Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2262932 Reviewed-by: Sterling Augustine <saugustine@google.com> Reviewed-by: Mark Mentovai <mark@chromium.org>
* Use breakpad_getcontext on all Linux platforms missing getcontextMichael Forney2020-03-163-0/+3
| | | | | | | | | | | | | | | | | | | | getcontext is also not available on musl libc, so generalize breakpad_getcontext so it can be used as a fallback for non-Android platforms as well. On x86_64 and i386, ucontext_t uses an Android-specific offset for storage of FP registers, since its sigset_t differs in size. So, make the definition of MCONTEXT_FPREGS_MEM and UCONTEXT_FPREGS_MEM_OFFSET conditional on whether we are building for Android. On glibc and musl, signal.h and asm/sigcontext.h can't be included together, so in breakpad_context_unittest.cc, only compare the libc and kernel _fpstate when on Android. Bug: google-breakpad:631 Change-Id: If81d73c4101bae946e9a3655b8d1c40a34ab6c38 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2102135 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Fix some bugs in CheckMicrodumpContentsMichael Forney2020-03-131-2/+2
| | | | | | | | | | | | | | The crash address from the microdump was never checked against anything. Instead, the test was checking the value of a constant. On 32-bit systems, an intptr_t cannot represent kCrashAddress (0xDEADDEAD), causing a failure when the crash address is parsed from the microdump. Instead, use uintptr_t, which matches the type of kCrashAddress. Change-Id: Ib5612743803609f7801dcfb98deaa8779e362025 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2100816 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Use public fpregset_t type to define fpstate_tMichael Forney2020-03-103-4/+6
| | | | | | | | | | | | | | | The _libc_fpstate struct tag is an implementation detail of glibc, and musl uses a different struct tag, _fpstate. Unfortunately, the public type fpregset_t is a pointer type, so is not suitable for allocating storage, or referring to constant storage. Instead, we can use std::remove_pointer<fpregset_t>::type to refer to the pointed-to type, regardless of the struct tag. Bug: google-breakpad:631 Change-Id: Iaf47f15b2d834dd8de839431f65a481e9b0c7f9e Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2096171 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Use standard header locations for poll.h and signal.hMichael Forney2020-03-104-4/+3
| | | | | | | | | | | | | | | | sys/poll.h and sys/signal.h just redirect to the standardized location for these headers, poll.h and signal.h. On musl libc, including the incorrect header path results in a warning, and since breakpad is built with -Werror, this is an error. In exception_handler.cc, signal.h is already included earlier, so we can drop the sys/signal.h include. Bug: google-breakpad:631 Change-Id: If36d326453e3267d38a5b92ed1301f828e46befe Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2097344 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Revert "Remove use of "register" keyword, deprecated in C++17"Mark Mentovai2019-11-011-1/+1
| | | | | | | | | | | | | | This reverts commit 07411862eaa9a9a38e84caed2e97e836e456656f. We were a bit overzealous in removing “register” here. Both clang and GCC correctly disallow “register” as a storage class specifier in C++17 mode by producing an error in ordinary use. However, they require “register” to be specified for explicit register variables, and do not produce an error in this case. Change-Id: I223f2652c6da4215d6e8788d902e767c94b8c29d Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1894875 Reviewed-by: Mark Mentovai <mark@chromium.org>
* linux, client: set module name from DT_SONAMEJoshua Peraza2019-10-301-17/+27
| | | | | | | | | | | | | | | | | | 3e56ef9d changed dump_syms to set the module name from DT_SONAME expecting that clients were already using DT_SONAME when it was present. The Breakpad client previously only used DT_SONAME as the name for a module if it detected that it was likely mapped from a zip file. This patch updates the Breakpad Linux client to always use the DT_SONAME in minidumps if it's present. Also included are changes to address comments that were missed from that review. Bug: 1016924 Change-Id: I4aae8c05e6793d4b0598049a8964ddd4cb0c6194 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1889231 Reviewed-by: Mark Mentovai <mark@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org>
* linux, dump_syms: set module name from DT_SONAMEJoshua Peraza2019-10-241-43/+0
| | | | | | | | | | | | | The Breakpad and Crashpad clients will use an object's DT_SONAME as the name for a module if it exists. Previously, linux dump_syms would assume the basename of an input elf file matches that value, causing symbol lookups to fail if they were mismatched. This patch updates dump_syms to use DT_SONAME as the module name, if present. Bug: 1016924 Change-Id: I5eff0cf06c703841df3fb552cb5a8e1e50a20c64 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1876763 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Remove use of "register" keyword, deprecated in C++17Mark Mentovai2019-08-121-1/+1
| | | | | | | | | | "register" as a storage class specifier has been deprecated since C++11, and has been removed from C++17 while remaining a reserved word. See C++17 5.11 and C.4.3. Change-Id: I2dbab8a7061cb680d902644d39ea1a7fbc930e5c Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1749329 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* linux: fix broken testsJoshua Peraza2019-06-042-4/+4
| | | | | | | | Fixes errors for comparisons between signed and unsigned ints. Change-Id: I7ef151ba84a48a0c8cc449cfaf12b9fef775d5a7 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1642361 Reviewed-by: Mark Mentovai <mark@chromium.org>
* Linux breakpad_unittests: fix ThreadSanitizer problemsMark Mentovai2019-04-264-7/+41
| | | | | | | | | | | | | | | | Some tests were failing because they had expectations about the number of threads in a process, but TSan, and in some cases, ASan, introduce their own threads. Where a sanitizer affects this, the expectations are now used as minimum thread counts, not exact thread counts. See https://www.brooklinen.com/blogs/brookliving/best-thread-count-for-sheets. These problems were detected by ThreadSanitizer at https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8915151099544583616/+/steps/breakpad_unittests__with_patch_/0/stdout Bug: chromium:949098 Change-Id: Ie40f1766bea27e9bcb112bf9e0b8b846fb343012 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1585948 Reviewed-by: Robert Sesek <rsesek@chromium.org>
* Linux MinidumpWriter: fix stack-use-after-scope violationMark Mentovai2019-04-261-2/+4
| | | | | | | | | | | | | | | | | | One form of google_breakpad::WriteMinidump() passed MappingList and AppMemoryList objects by reference to a MinidumpWriter object, instantiating them directly as constructor parameters. The MinidumpWriter stored these objects internally as references, and the underlying objects went out of scope after MinidumpWriter construction. The MinidumpWriter outlived them, causing a violation on any attempt to access them following construction. This bug was detected by AddressSanitizer at https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8915150848087289472/+/steps/breakpad_unittests__with_patch_/0/stdout Bug: chromium:949098 Change-Id: I072ea9f1b64e1eae3e89d4a2b158764ff7970db5 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1585946 Reviewed-by: Robert Sesek <rsesek@chromium.org>
* Make breakpad_unittests work with Chrome's test runner instead of gtest'sMark Mentovai2019-04-192-3/+7
| | | | | | | | | | | | | | | | | | | Chrome's test runner on Linux installs its own StackDumpSignalHandler which swallows signals and doesn't re-raise them. This is sloppy, but apparently there are reasons (https://crbug.com/551681). For breakpad_unittests, it causes problems where a test process expects (via waitpid()) to observe a child crash. Deal with those cases by explicitly restoring the default signal handler. In another case, Chrome's test runner seems to have been arriving at the conclusion that it was to expect output from a child. Transitioning from exit() to _exit() fixes this problem, and it's not necessarily a bad idea to do this in post-fork() children without an execve() anyway. Bug: chromium:949098 Change-Id: I5a6af0c2a09cd8eac9998358f6d5ea665288236f Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1575670 Reviewed-by: Mark Mentovai <mark@chromium.org>
* linux_core_dumper: add missing newline to Android test-disabled messageMark Mentovai2019-04-091-3/+3
| | | | | | | | | | | | | | The [ OK ] LinuxCoreDumperTest.VerifyExceptionDetails line does not appear at the beginning of a line, hiding it from Chromium’s test infrastructure. This causes the test to have an unknown result, which is treated as a failure. https://ci.chromium.org/p/chromium/builders/try/android-kitkat-arm-rel/233129 Bug: google-breakpad:791 Change-Id: I0eb646a219fa40347db884fd28ace647328c5e49 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1558893 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* linux_core_dumper: partially disable test on AndroidMike Frysinger2019-04-071-0/+9
| | | | | | | | | | | | | | | | | | | | | Running this test on android-kitkat-arm-rel fails for some reason: [ RUN ] LinuxCoreDumperTest.VerifyExceptionDetails linux_core_dumper_unittest.cc:170: Failure Expected: (0U) != (dumper.crash_address()), actual: 0 vs 0 linux_core_dumper_unittest.cc:178: Failure Expected equality of these values: 2U Which is: 2 info.size() Which is: 0 [ FAILED ] LinuxCoreDumperTest.VerifyExceptionDetails (7 ms) Disable it for now on Android until someone can look into it. Bug: google-breakpad:791 Change-Id: I40a5e3dbeeb44e5eb0df187e61d55e07d8ad3613 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1546778 Reviewed-by: Mark Mentovai <mark@chromium.org>
* linux_core_dumper: add explicit casts for exception fieldsMike Frysinger2019-03-301-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | Some of the fields we save might have signed types depending on the system (e.g. `typedef int pid_t`). Depending on the toolchain, we can trip -Werror=narrowing failures like: src/client/linux/minidump_writer/linux_core_dumper.cc:248:66: error: narrowing conversion of ‘(__pid_t)info->siginfo_t::_sifields.siginfo_t::<anonymous union>::_kill.siginfo_t::<anonymous union>::<anonymous struct>::si_pid’ from ‘__pid_t {aka int}’ to ‘long unsigned int’ inside { } [-Werror=narrowing] set_crash_exception_info({info->si_pid, info->si_uid}); ^^^^^^ src/client/linux/minidump_writer/linux_core_dumper.cc:252:71: error: narrowing conversion of ‘(int)info->siginfo_t::_sifields.siginfo_t::<anonymous union>::_sigsys.siginfo_t::<anonymous union>::<anonymous struct>::_syscall’ from ‘int’ to ‘long unsigned int’ inside { } [-Werror=narrowing] set_crash_exception_info({info->si_syscall, info->si_arch}); ^^^^^^^^^^ Since the exception info fields are all uint64_t which should be large enough to handle all the fields in the siginfo_t structure, add casts for all the assignments to avoid these errors. We have implicit casts even without them, so we aren't changing behavior. Bug: google-breakpad:791 Bug: chromium:945653 Change-Id: Ib04e015998f08b857159ac13e9a065a66d228d49 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1544862 Reviewed-by: Mark Mentovai <mark@chromium.org>
* linux_core_dumper: handle missing SIGSYS supportMike Frysinger2019-03-142-0/+8
| | | | | | | | | | | | If the kernel/C library headers are old, they might not have the fields needed for SIGSYS decoding. Add ifdef checks for that and skip the logic entirely. Easier than adding arch-specific siginfo structs to the codebase. Bug: google-breakpad:791 Change-Id: Ia473e3ffa61fce4c42cf4c1e73a9df044599bc5c Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1524447 Reviewed-by: Mark Mentovai <mark@chromium.org>
* linux_core_dumper: support setting exception_informationMike Frysinger2019-03-124-1/+76
| | | | | | | | | | | | | | Many signals in Linux support additional metadata on a per-signal basis. We can extract that from NT_SIGINFO and pass it through in the exception_information fields. The current core dumper logic doesn't set exception_information at all, so this is an improvement. Bug: google-breakpad:791 Change-Id: I38b78d6494e9bc682441750d98ac9be5b0656f5a Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1497662 Reviewed-by: Mark Mentovai <mark@chromium.org>
* linux_core_dumper: add a fallback definition for NT_SIGINFOMike Frysinger2019-03-071-0/+1
| | | | | | | | | | When building on an old system with outdated headers, this define might not be available. Add a fallback to our existing elf header. Bug: google-breakpad:790 Change-Id: I4dfe7a5cebd414cca3582a1a9cfc983503d5a779 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1507073 Reviewed-by: Mark Mentovai <mark@chromium.org>
* linux_core_dumper: support NT_SIGINFO for reading crashing addressMike Frysinger2019-03-031-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | The current core dumper only parses NT_PRSTATUS notes. With signal details, this note only includes three fields: signo, code, and errno. We set exception_code to signo and exception_flag to code. The errno value isn't set by the kernel, so there's no need to save it. However, we never fill in exception_address which means all converted crashes look like they happen at address 0. This implies a NULL jump which is usually not the case, so it's just confusing. The prstatus structure doesn't offer anything directly that tracks this. Starting with linux-3.7, the kernel writes out the full siginfo structure in the NT_SIGINFO note. So lets support that to pull out si_addr which, for a bunch of common signals, is the value we want in exception_address. The size of the siginfo_t structure should be locked to 128 bytes at build time for all architectures, so this should hopefully be stable. Bug: google-breakpad:790 Change-Id: I458bad4787b1a8b73fad8fe068e9f23bec957599 Reviewed-on: https://chromium-review.googlesource.com/c/1497661 Reviewed-by: Mark Mentovai <mark@chromium.org>
* breakpad: Remove semicolons.Nico Weber2019-02-211-1/+1
| | | | | | | Bug: chromium:926235 Change-Id: I7f0795ebd651303b6f7fb6981c2f639e17a536bb Reviewed-on: https://chromium-review.googlesource.com/c/1481232 Reviewed-by: Mark Mentovai <mark@chromium.org>
* Delete deprecated SetFirstChanceExceptionHandler functionAndreas Haas2019-02-193-38/+0
| | | | | | | | | | | | | | | This CL removes the code I marked as deprecated in https://crrev.com/c/1411776. I could not delete the code in that CL before I removed all uses in Chrome in https://crrev.com/c/1411643. The tracking bug contains more information. R=mark@chromium.org Bug: chromium:921971 Change-Id: I77597826ef6e69a13ece529a5d24702bc72aa436 Reviewed-on: https://chromium-review.googlesource.com/c/1412353 Reviewed-by: Mark Mentovai <mark@chromium.org>
* Introduce SetFirstChanceHandler with more strict signatureAndreas Haas2019-01-153-3/+40
| | | | | | | | | | | | | | | | | | | Eventually, I want to remove the current version of SetFirstChanceHandler. That is why I changed the name of the current callback type to FirstChanceHandlerDeprecated. I also made sure that it is not possible to have two different FirstChanceHandlers set at the same time. This is the first of a set of CLs to clean up the API between Chrome, BreakPad, and V8. See more information in the tracking bug. R=mark@chromium.org Bug: chromium:921971 Change-Id: Ia8c2fd9bd875c36dd7ae8bb4a02e538556bc67a1 Reviewed-on: https://chromium-review.googlesource.com/c/1411776 Reviewed-by: Mark Mentovai <mark@chromium.org>
* Rename MDRawContextARM64 and its context flagsJoshua Peraza2018-08-014-4/+4
| | | | | | | | | | This makes way for the addition of a struct matching Microsoft's layout for ARM64. Change-Id: I115f25290863e7438852691d1ec3c9324a42f7a5 Reviewed-on: https://chromium-review.googlesource.com/1152158 Reviewed-by: Mark Mentovai <mark@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Initialize variables for MSANSergey Abbakumov2018-04-102-2/+2
| | | | | | | | | | The variables in the CL are not initialized. Even if it's safe not to initialize them here, MSAN doesn't know that. Bug: 394028 Change-Id: I597a7d76aa19d5789decd0f85150fa31c9655269 Reviewed-on: https://chromium-review.googlesource.com/1001573 Reviewed-by: Lei Zhang <thestig@chromium.org>
* Linux: Write out si_code for SIGBUS exceptions.Lei Zhang2018-04-035-11/+26
| | | | | | | | | Store the information in the exception record's exception_information field. Change-Id: Ie215cae2f070fdab63c3d05cc1bc4fb4b7b095fa Reviewed-on: https://chromium-review.googlesource.com/990799 Reviewed-by: Mark Mentovai <mark@chromium.org>
* Extend ifdef to include helper functionsLars Volker2018-01-311-2/+2
| | | | | | | | | | The previous change to fix compiling on Android < N forgot to include a helper in the ifdef, thus not fixing the problem. This change extends the ifdef to include all helpers used by the test. Change-Id: Ibb3030f54a81b5609a0b55ccef387a3cba22d088 Reviewed-on: https://chromium-review.googlesource.com/895240 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Remove barrier to fix Android build.Lars Volker2018-01-311-1/+3
| | | | | | | | | | | The unittest for #752 made use of pthread_barrier_t, which is not supported on Android. This change replaces the barrier code with a simple sleep, which proved sufficient to trigger the race. It only affects the test and does not affect the original fix for #752. Change-Id: I82c32cf00899176fa09089e716ed85850b8711e6 Reviewed-on: https://chromium-review.googlesource.com/895168 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Only restore the signal handler if sigaction has not changedLars Volker2018-01-092-0/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Restoring the signal handler in ExceptionHandler::SignalHandler() can lead to a race in scenarios where multiple threads crash within a short time. This can cause threads to alternately try to write a minidump without ever terminating the process. The first thread to write a minidump will reset the signal handler to the SIG_DFL using signal() in InstallDefaultHandler(). The next thread to execute SignalHandler() will detect this and will reset the signal handler to SignalHandler(). If the first thread takes too long to write its minidump (e.g. when there are many threads), the chances increase that the second thread will enter SignalHandler() before the first one leaves the critical section. After resetting the signal handler, the second thread will fail to write a minidump (since the file already exists) and will try to reset the signal handler to the default by calling RestoreHandlersLocked(). However, in the meantime the first thread will have entered SignalHandler() again and will overwrite it one more time. After that, no further attempts will be made to restore the default signal handler and both threads will continue to re-raise the signal and attempt to write minidump files. This change adds a check to make sure that cur_handler.sa_sigaction is still pointing to SignalHandler() before re-installing the handler. To test this we start a large number of sleeping threads and two threads that will crash simultaneously. Without the fix, this would reproducibly lead to a loop between the two crashing threads. Bug: 752 Change-Id: I784328cfff17ddc7476d6668354570ab867ba405 Reviewed-on: https://chromium-review.googlesource.com/855137 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Fix minidump on ChromeOSYunlian Jiang2017-12-201-8/+25
| | | | | | | | | | | | | Chrome somehow changed the memory mapping with hugepage enabled. This makes the hack in CrOSPostProcessMappings more general. BUG=chromium:793452 TEST=with this patch on Chromium, minidump_dump *dmp shows the right information on chrome Change-Id: Iff58bf1a712a6e66cbd2d813422db7549a3080a5 Reviewed-on: https://chromium-review.googlesource.com/837963 Reviewed-by: Mark Mentovai <mark@chromium.org>
* Fix double declaration of tgkill when using Android NDK Headers.Nicholas Baldwin2017-10-301-7/+1
| | | | | | | | | | | | | As of Android API level 16 tgkill is declared in the NDK version of signal.h, which conflicts with the static definition found in src/client/linux/handler/exception_handler.cc. This change removes the static tgkill definition and replaces its use with sys_tgkill from the linux syscall support library. Bug: Change-Id: Ic70addd8a064cfa36345d86b7e36409e2089e909 Reviewed-on: https://chromium-review.googlesource.com/738912 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Move main executable handling out of procmaps parser loop.Peter Collingbourne2017-10-171-19/+21
| | | | | | | | | | | | | | | | | | | | | | | | If the mapping for the main executable needed to be merged (for example, if it was linked with lld and therefore contains an r mapping followed by an r/x mapping), we would never reach the code that makes it the first module. Handle that situation by moving that code into a separate loop. This fixes an issue where breakpad_unittests fails on Android devices when linked with lld. It appears that the glibc dynamic loader happens to always load executables (or at least the executables that we create) at a lower address than DSOs, so we never hit this bug on desktop Linux. Testing: "make check" with both gold and lld as linker. Also breakpad_unittests when patched into Chromium on Linux (lld) and Android (gold and lld). Bug: chromium:469376 Change-Id: I6329e4afd2f1bf44c25a6c3e684495e21dba83a6 Reviewed-on: https://chromium-review.googlesource.com/722286 Reviewed-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: Mark Mentovai <mark@chromium.org>
* Rename src/common/memory.h to memory_allocator.h.Ted Mielczarek2017-10-176-6/+6
| | | | | | | | | | | | memory.h shadows a system header which normally isn't a problem because of the include paths in Breakpad, but the Firefox build system winds up with src/common in the include path so we've had a workaround for this for years. Renaming the file lets us get rid of that workaround and shouldn't hurt anything. Change-Id: I3b7c4239dc77f3b2b7cf2b572a0cad88cd7e8522 Reviewed-on: https://chromium-review.googlesource.com/723261 Reviewed-by: Mark Mentovai <mark@chromium.org>
* Replace remaining references to 'struct ucontext' with 'ucontext_t'Mark Mentovai2017-09-206-33/+33
| | | | | | | | | | | | | | | | | This relands https://chromium.googlesource.com/breakpad/breakpad/src/+/e3035bc406cee8a4d765e59ad46eb828705f17f4, which was accidentally committed to breakpad/breakpad/src, the read-only mirror of src in breakpad/breakpad. (Well, it should have been read-only.) See https://crbug.com/766164. This fixes issues with glibc-2.26. See https://bugs.gentoo.org/show_bug.cgi?id=628782 , https://sourceware.org/git/?p=glibc.git;h=251287734e89a52da3db682a8241eb6bccc050c9 , and https://sourceware.org/ml/libc-alpha/2017-08/msg00010.html for context. Change-Id: Id66f474d636dd2afa450bab925c5514a800fdd6f Reviewed-on: https://chromium-review.googlesource.com/674304 Reviewed-by: Mark Mentovai <mark@chromium.org>
* drop bundled gflags from the checkoutMike Frysinger2017-09-131-1/+2
| | | | | | | | | | | | The only code using gflags is google_crash_report_sender, and nothing builds or tests that code currently. Switch it over to using system versions of gflags so we can drop the local prebuilts. Tested local builds by hand of the tool. Bug: google-breakpad:360 Change-Id: I75d79b176468c948773079a54d87e70709feaf87 Reviewed-on: https://chromium-review.googlesource.com/665799 Reviewed-by: Mark Mentovai <mark@chromium.org>
* Add crash reason and address to microdumps.Tobias Sargeant2017-08-144-0/+111
| | | | | | | | | | | | This will allow us to provide the right information for webview renderer crashes. At the moment the crash information for the browser process is captured (from the debuggerd output) instead. BUG=754715 Change-Id: I409546311b6e38fe1cf804097c18d7bb2a015d83 Reviewed-on: https://chromium-review.googlesource.com/612381 Reviewed-by: Robert Sesek <rsesek@chromium.org>
* A couple of minor fixesLeonard Mosescu2017-07-111-1/+1
| | | | | | | | | | | | | | | | 1. Fixing ExceptionHandlerTest.FirstChanceHandlerRuns: exit() is not an async-signal-safe function (http://man7.org/linux/man-pages/man7/signal-safety.7.html) 2. Fixing entry point signature in minidump_dump Changed "const char* argv[]" to "char* argv[]" to match the standard entry point signature 3. Updating .gitignore to exclude unit test artifacts Change-Id: I9662898d0bd97769621fb6476a720105821c60f0 Reviewed-on: https://chromium-review.googlesource.com/562356 Reviewed-by: Mark Mentovai <mark@chromium.org> Reviewed-by: Ivan Penkov <ivanpe@chromium.org> Reviewed-by: Joshua Peraza <jperaza@chromium.org>
* Fix asan buildsEric Holk2017-06-221-23/+23
| | | | | | | | | | | | | When rolling this into Chrome, we got compile failures due to DoNullPointerDereference being undefined but the new FirstChanceHandlerRuns tests depends on this and was still defined. The fix is to only enable the FirstChanceHandlerRuns test on non-asan builds. Bug: Change-Id: I5a3da0a21e2d0dd663ffc01137496d16905293a6 Reviewed-on: https://chromium-review.googlesource.com/544186 Reviewed-by: Mark Mentovai <mark@chromium.org>
* Add first chance exception handler APIEric Holk2017-06-193-0/+44
| | | | | | | | | | | | | | This change adds the option for Breakpad hosts to register a callback that gets the first chance to handle an exception. The handler will return true if it handled the exception and false otherwise. The primary use case is V8's trap-based bounds checking support for WebAssembly. Bug: Change-Id: I5aa5b87d1229f1cef905a00404fa2027ee86be56 Reviewed-on: https://chromium-review.googlesource.com/509994 Reviewed-by: Mark Mentovai <mark@chromium.org>
* Merge exec and non-exec segments while merging executable bit.Peter Collingbourne2017-05-261-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bfd and gold linkers create segments like this: r/x, r/w where the r/x segment covers the start of the ELF file. lld's segments look like this: r, r/x, r/w where the r segment covers the start of the ELF file. So we cannot rely on the location of the r/x to tell where the start of the ELF is. But we can still rely on the r and r/x mappings being adjacent. So what we do is when we see an r segment followed by an r/x, merge the r into the r/x and claim that it is executable. This way, the minidump writer will continue to see a single executable segment covering the entire executable. Testing: "make check" passes when breakpad is compiled with lld compiled from trunk (requires bug fix from LLVM r303689). Also patched change into chromium and tested these builds: $ cat args.gn is_chrome_branded = true is_debug = false is_official_build = true use_lld = true allow_posix_link_time_opt = false is_cfi = false $ cat args.gn target_os = "android" target_cpu = "arm" is_debug = false is_official_build = true is_chrome_branded = true With both builds breakpad_unittests passes and chrome/chrome_modern_public_apk create good minidumps after navigating to chrome://inducebrowsercrashforrealz (checked that minidump contains stack trace entry for content::HandleDebugURL). Bug: chromium:716484 Change-Id: Ib6ed3a8420b83acf4a5962843930fb006734cb95 Reviewed-on: https://chromium-review.googlesource.com/513610 Reviewed-by: Primiano Tucci <primiano@chromium.org>
* Don't attempt to use PTRACE_GETREGS if it isn't defined.John Budorick2017-05-251-1/+5
| | | | | | | | | | | Follow up to https://chromium-review.googlesource.com/c/484479/, which does not compile on arm64. Bug: chromium:725754 Change-Id: Iaa6fbc332564909a10e2602a1026c14fb25625f4 Reviewed-on: https://chromium-review.googlesource.com/515044 Reviewed-by: Mark Mentovai <mark@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Simplify ELF parser code.Peter Collingbourne2017-05-251-5/+4
| | | | | | | | | | | | | The layout of Elf32_Nhdr and Elf64_Nhdr is the same, so remove templating and code that extracts the elfclass from the ELF file. Testing: "make check" and breakpad_unittests when patched into chromium. Bug: chromium:716484 Change-Id: I41442cfff48afc6ae1a5b604d22b67550a910376 Reviewed-on: https://chromium-review.googlesource.com/514450 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Use __NR_exit_group in MinidumpWriterTest.MinidumpStacksSkippedIfRequested.John Budorick2017-05-241-10/+24
| | | | | | | | | Also adds waits for all child processes spawned in MinidumpWriterTest. Bug: 725754 Change-Id: I3248925993dede2c113ab1989b322a9d9c8f24bd Reviewed-on: https://chromium-review.googlesource.com/513480 Reviewed-by: Mark Mentovai <mark@chromium.org>
* Fix race in ExceptionHandler::GenerateDump()Lars Volker2017-05-101-3/+9
| | | | | | | | | | | | | | | | | | | | | When writing a minidump on Linux, we called clone() in linux/handler/exception_handler.cc with the CLONE_FILES flag. If the parent process died while the child waited for the continuation signal, the write side of the pipe 'fdes' stayed open in the child. The child would not receive a SIGPIPE and would wait forever. To fix this, we clone without CLONE_FILES and then close the read-side of fdes in the master before the ptrace call. That way, if the master dies, the child will receive a SIGPIPE and will die, too. To test this I added a sleep() call before SendContinueSignalToChild() and then killed the master, manually observing that the child would die, too. Bug: 728 Change-Id: Ifd72de835a34e7d9852ae1a362e707fdc6c96c7e Reviewed-on: https://chromium-review.googlesource.com/464708 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Fixing breakpad on old linux kernelAndrew Ermakovich2017-04-212-29/+53
| | | | | | | | | | Try to read the trace's registers by PTRACE_GETREGS if kernel doesn't support PTRACE_GETREGSET. Bug: Change-Id: I881f3a868789747ca217f22a93370c6914881f9a Reviewed-on: https://chromium-review.googlesource.com/484479 Reviewed-by: Mike Frysinger <vapier@chromium.org>
* Treat the process stack as the top of memory for free space histograms.Tobias Sargeant2017-03-292-1/+22
| | | | | | | | | | | | | Because we can't determine the top of userspace mappable memory directly, we rely on the fact that the process stack is allocated at the top of the address space (minus some randomization). Anything after that should not count as free space. BUG=695382 Change-Id: I68453aac9732c2bd4b87236b234518068dec6640 Reviewed-on: https://chromium-review.googlesource.com/446100 Reviewed-by: Primiano Tucci <primiano@chromium.org>
* Fix ASSERT_EQUAL that should have been ASSERT_EQ.Tobias Sargeant2017-03-241-1/+1
| | | | | | | | BUG=703599 Change-Id: I5623705edc41644495aa4f2389056d255e22da8e Reviewed-on: https://chromium-review.googlesource.com/459617 Reviewed-by: Primiano Tucci <primiano@chromium.org>
* Don't generate minidump if crash thread doesn't ref principal mapping.Tobias Sargeant2017-03-232-13/+105
| | | | | | | | | | | | | If the crashing thread doesn't reference the principal mapping we can assume that not only is that thread uninteresting from a debugging perspective, the whole crash is uninteresting. In that case we should not generate a minidump at all. BUG=703599 Change-Id: Ia25bbb8adb79d04dcaf3992c3d2474f3b9b1f796 Reviewed-on: https://chromium-review.googlesource.com/457338 Reviewed-by: Robert Sesek <rsesek@chromium.org>
* [MIPS] Get (ptrace) value of $pc for a threadGordana Cmiljanovic2017-03-221-0/+2
| | | | | | | | | This change is fixing LinuxPtraceDumperTest.SanitizeStackCopy test case. Change-Id: I1eb3becfd4b3660bc5529b5d2a5e35db0b6eb6e0 Reviewed-on: https://chromium-review.googlesource.com/458277 Reviewed-by: Mark Mentovai <mark@chromium.org>