aboutsummaryrefslogtreecommitdiff
path: root/src/client/linux/handler/exception_handler_unittest.cc
Commit message (Collapse)AuthorAgeFilesLines
* 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-091-0/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* 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-191-0/+23
| | | | | | | | | | | | | | 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>
* breakpad: fix unittest errorsYunlian Jiang2016-05-041-4/+0
| | | | | | | | | | | This fixes the unittest error caused by https://codereview.chromium.org/1884283002/ TEST=unittest passes on falco board in ChromeOS. BUG= R=vapier@chromium.org Review URL: https://codereview.chromium.org/1952083002 .
* Switch the Linux minidump writer to use MDCVInfoELF for CV data.Ted Mielczarek2016-04-051-14/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This preserves full build ids in minidumps, which are useful for tracking down the right version of system libraries from Linux distributions. The default build id produced by GNU binutils' ld is a 160-bit SHA-1 hash of some parts of the binary, which is exactly 20 bytes: https://sourceware.org/binutils/docs-2.26/ld/Options.html#index-g_t_002d_002dbuild_002did-292 The bulk of the changes here are to change the signatures of the FileID methods to use a wasteful_vector instead of raw pointers, since build ids can be of arbitrary length. The previous change that added support for this in the processor code preserved the return value of `Minidump::debug_identifier()` as the current `GUID+age` treatment for backwards-compatibility, and exposed the full build id from `Minidump::code_identifier()`, which was previously stubbed out for Linux dumps. This change keeps the debug ID in the `dump_syms` output the same to match. R=mark@chromium.org, thestig@chromium.org BUG= Review URL: https://codereview.chromium.org/1688743002 .
* Fix -Wunused-function warnings in ASAN builds.Lei Zhang2015-12-301-6/+2
| | | | | | | | A=thakis@chromium.org BUG=chromium:573250 Original Review: https://codereview.chromium.org/1551963002/ Review URL: https://codereview.chromium.org/1551983002 .
* tests: InstructionPointerMemoryNullPointer: make it work under llvmvapier@chromium.org2015-07-201-1/+6
| | | | | | | | | | | | | When LLVM sees an attempt to dereference a NULL pointer, it will generate invalid opcodes (undefined behavior) which leads to SIGILL which breaks this unittest. Upstream's recommendation in this case is to add volatile markings to get the actual dereference to happen. This is documented in the blog post under "Dereferencing a NULL Pointer": http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1473 4c0a9323-5329-0410-9bdc-e9ce6186880e
* MIPS64: Initial MIPS64 related change.mark@chromium.org2015-04-151-0/+4
| | | | | | | | | | | With this change Breakpad can be compiled for MIPS64, but it is not yet functional. Patch by Gordana Cmiljanovic <Gordana.Cmiljanovic@imgtec.com> Review URL: https://breakpad.appspot.com/6824002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1446 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Fix compilation with gcc --std=c++11ted.mielczarek@gmail.com2015-03-241-1/+1
| | | | | | | | | Patch by Jon Turney <jon.turney.1111@gmail.com> R=ted at https://breakpad.appspot.com/7824002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1435 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Cleanup: hide undefined behavior from the compiler better.ivanpe@chromium.org2014-07-011-4/+18
| | | | | | | | | | Submitting this on behalf of Paul Pluzhnikov. R=mark@chromium.org Review URL: https://breakpad.appspot.com/6674002 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1342 4c0a9323-5329-0410-9bdc-e9ce6186880e
* disable unittests under ASAN that use memory crashesvapier@chromium.org2013-12-111-5/+14
| | | | | | | | | | | | | | | | | | | | | There are a bunch of tests that use invalid memory acesses (on purpose) to trigger a crash so that we can detect things are dumped correctly. When we run under ASAN, it catches those accesses and the breaks the testing flow. For now, use the existing ADDRESS_SANITIZER symbol to disable more tests. Ideally we'd use a compile-time attribute to disable ASAN on a few funcs, but that seems to be broken atm. BUG=chromium:293519 BUG=chromium:304575 TEST=ran unittests under ASAN and they now pass TEST=ran unittests w/out asan/clang and they still pass R=benchan@chromium.org Review URL: https://breakpad.appspot.com/884002 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1255 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Adding mips support for Android.gordana.cmiljanovic@imgtec.com2013-09-251-1/+6
| | | | | | | | | | | | | | Mips linux support has been added previously in r1212. Some additional changes are required to make breakpad functional on Android. BUG=none TEST=build, unittests, chrome test application Review URL: https://breakpad.appspot.com/632002 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1215 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Adding support for mips.gordana.cmiljanovic@imgtec.com2013-09-111-19/+35
| | | | | | | | | | | | | Support for mips cpu is added to all breakapad targets including unittests. BUG=none TEST=unittests Review URL: https://breakpad.appspot.com/614002 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1212 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Fix three unit tests on recent ARM devices.digit@chromium.org2013-03-211-0/+24
| | | | | | | | | | | | Three unit tests were failing on recent ARM devices (e.g. Galaxy Nexus or Nexus 4), while ran properly on older ones (e.g. Nexus S). The main issue is that the instruction cache needs to be explicitely cleared on ARM after writing machine code bytes to a malloc()-ed page with PROT_EXEC. Review URL: https://breakpad.appspot.com/540002 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1132 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Use stdint types everywhereted.mielczarek@gmail.com2013-03-061-21/+21
| | | | | | R=mark at https://breakpad.appspot.com/535002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1121 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Fix some issues with -Werror=sign-compare on Android buildsted.mielczarek@gmail.com2013-02-011-1/+1
| | | | | | R=digit at https://breakpad.appspot.com/524002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1110 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Cleaning up google-breakpad source code of signed-unsigned comparison warningsivan.penkov@gmail.com2012-11-211-16/+16
| | | | | | | | http://breakpad.appspot.com/488002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1083 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Fix some compiler errors in exception_handler_unittest by casting like crazyted.mielczarek@gmail.com2012-10-151-2/+4
| | | | | | R=digit at https://breakpad.appspot.com/483002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1072 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Make Linux signal handler more robust.digit@chromium.org2012-10-091-0/+31
| | | | | | | | | | | | | | | | | | | | | | Breakpad can be used on processes where a mistaken library saves then restores one of our signal handlers with 'signal' instead of 'sigaction'. This loses the SA_SIGINFO flag associated with the Breakpad handler, and in some cases (e.g. Android/ARM kernels), the values of the 'info' and 'uc' parameters that ExceptionHandler::SignalHandler() receives will be completely bogus, leading to a crash when the function is executed (and of course, no minidump generation). To work-around this, have SignalHandler() check the state of the flag. If it is incorrectly unset, re-register with 'sigaction' and the correct flag, then return. The signal will be re-thrown, and this time the function will be called with the correct values. Review URL: https://breakpad.appspot.com/481002 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1067 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Fix merge error from r1055ted.mielczarek@gmail.com2012-10-021-1/+0
| | | | git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1056 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Fix linux compile errors for some systems.qsr@chromium.org2012-10-021-9/+10
| | | | | | | | Codereview: https://breakpad.appspot.com/460002/ Patch by: jakerr@google.com git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1055 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Fix the Linux build with clang.thestig@chromium.org2012-09-261-0/+1
| | | | | | Review URL: https://breakpad.appspot.com/470002 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1052 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Allow generating minidumps from live process on Linux via ExceptionHandlerted.mielczarek@gmail.com2012-09-181-0/+66
| | | | | | | Original patch by Chris Jones <jones.chris.g@gmail.com> at https://bugzilla.mozilla.org/show_bug.cgi?id=544936 and https://bugzilla.mozilla.org/show_bug.cgi?id=555309 R=mark at https://breakpad.appspot.com/449003/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1043 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Allow adding extra memory regions to minidump on linux/windowsted.mielczarek@gmail.com2012-09-181-1/+80
| | | | | | | A=Bill McCloskey <wmccloskey@mozilla.com>, ted, original patch from https://bugzilla.mozilla.org/show_bug.cgi?id=662646 R=mark at https://breakpad.appspot.com/450002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1041 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Add a GetInstructionPointer method to MinidumpExceptionted.mielczarek@gmail.com2012-09-171-42/+3
| | | | | | R=mark at https://breakpad.appspot.com/444003/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1039 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Allow setting a new MinidumpDescriptor on ExceptionHandler, also expose ↵ted.mielczarek@gmail.com2012-09-171-0/+4
| | | | | | | | directory from MinidumpDescriptor R=digit at https://breakpad.appspot.com/452003/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1037 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Properly redeliver (or don't) signals to the previous handlers.mark@chromium.org2012-09-041-0/+174
| | | | | | | | | | | | | | | | | | | | | | | | If none of the installed ExceptionHandlers handle a signal (their FilterCallbacks or HandlerCallbacks all return false), then the signal should be delivered to the signal handlers that were previously installed. This requires that old_handlers_ become a static vector so that we can restore the handlers in the static HandleSignal. Currently it is also restoring signals in ~ExceptionHandler (if there are no others). This should not be required since our documentation states that a process can only have one ExceptionHandler for which install_handlers is true (and so we get the correct behavior if we simply leave our handlers installed forever), but even the tests themselves violate that. Patch by Chris Hopman <cjhopman@chromium.org> Review URL: https://breakpad.appspot.com/440002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1025 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Adding a way to create an ExceptionHandler that takes in a file descriptorjcivelli@chromium.org2012-08-091-235/+243
| | | | | | | | | | | | where the minidump should be created, without the need of opening any other file. BUG=None TEST=Run unit-tests. git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1007 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Conditionally compiling a unittest - based on whether AddressSanitizer is used. ivan.penkov@gmail.com2012-08-061-0/+7
| | | | | | | | http://breakpad.appspot.com/428002 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1004 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Speculatively back out r989 per http://codereview.chromium.org/10805065/ :mark@chromium.org2012-07-241-39/+0
| | | | | | | | | | | | | | | | | | | | Ted Mielczarek: > You could try backing out r989, although Mozilla has been running with that > patch for months without issue. Me: > src/client/windows/handler/exception_handler.cc in r989 appears to have > formatting problems, an unwanted property change, and no real Breakpad review > history, so maybe we should back it out anyway until the proper process is > followed. NACL Tests nacl_integration failures: http://build.chromium.org/p/chromium/builders/NACL%20Tests/builds/30138 chrome src/native_client/tests/inbrowser_crash_test/crash_dump_tester.py says that the observed failures are a symptom of crash_service.exe itself crashing. git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@998 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Linux: Fix a bunch of clang errors from not handling return values.thestig@chromium.org2012-07-241-5/+8
| | | | | | Review URL: https://breakpad.appspot.com/421002 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@995 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Allow adding extra memory regions to minidump on linux/windowsted.mielczarek2012-07-191-0/+39
| | | | | | A=Bill McCloskey <wmccloskey@mozilla.com> R=ted at https://bugzilla.mozilla.org/show_bug.cgi?id=662646 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@989 4c0a9323-5329-0410-9bdc-e9ce6186880e
* This change allows compiling the google-breakpad code using a global ↵ivan.penkov@gmail.com2012-06-281-6/+7
| | | | | | ::string class instead of std::string. For more details take a look at common/using_std_string.h git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@974 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Fix compilation warnings related to unchecked return valuested.mielczarek2012-04-251-1/+8
| | | | | | | Patch by Chris Dearman <chris@mips.com> R=benchan at http://breakpad.appspot.com/377001 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@957 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Fix file descriptor leaks in ExternalDumper testted.mielczarek2012-04-111-0/+2
| | | | | | | Patch by Chris Dearman <chris@mips.com> R=ted at http://breakpad.appspot.com/372002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@951 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Fix test addresses to use uintptr_t instead of u_int64_t.benchan@chromium.org2012-01-271-1/+1
| | | | | | | | | | | | | | | | When a variable is used to set (and lookup) MappingInfo's "start_addr" field, it needs to match types -- which is "uintptr_t". When Chrome OS updated the 'make' that's used for building, the 32-bit "char *" had sign-extended when cast up to a u_int64_t -- maybe because pointers were unsigned before and then changed to be signed -- and that caused the address lookup to fail. BUG=chromium-os:25355 TEST=Ran Breakpad unittests A=mkrebs@chromium.org Review URL: http://breakpad.appspot.com/345001 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@908 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Correct compilation warning.qsr@chromium.org2011-11-231-27/+29
| | | | | | | | | 1) Modify src/common/mac/macho_walker.cc to remove a signed vs unsigned comparison. 2) Replace mktemp in test using AutoTmpDir that has been moved from client/mac/tests to common/tests. Review URL: http://breakpad.appspot.com/328001 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@888 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Fix clang warning / miscompile.mmentovai2011-01-241-2/+2
| | | | | | | | | Patch by Nico Weber <thakis@chromium.org> Review URL: http://breakpad.appspot.com/256001 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@760 4c0a9323-5329-0410-9bdc-e9ce6186880e
* allow passing info about known memory mappings to MinidumpWriter and ↵ted.mielczarek2010-12-131-0/+86
| | | | | | | | ExceptionHandler r=thestig at http://breakpad.appspot.com/242001/show git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@741 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Delete an old Makefile and fix lots of lint errors.thestig@chromium.org2010-11-081-5/+5
| | | | | | Review URL: http://breakpad.appspot.com/225001 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@727 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Add support for building the Linux client code using the Android NDKted.mielczarek2010-10-201-12/+19
| | | | | | r=mwu at http://breakpad.appspot.com/212001/show git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@716 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Write a window of memory around the instruction pointer from the crashing ↵ted.mielczarek2010-09-231-0/+314
| | | | | | | | thread to the minidump on OS X. R=nealsid at http://breakpad.appspot.com/200001/show git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@699 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Write a window of memory around the instruction pointer from the crashing ↵ted.mielczarek2010-09-171-0/+123
| | | | | | | | thread to the minidump on Linux. R=nealsid at http://breakpad.appspot.com/194001/show git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@693 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Add a free() to ExceptionHandlerTest.ChildCrash.thestig@chromium.org2010-09-161-0/+1
| | | | | | Review URL: http://breakpad.appspot.com/193001 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@687 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Import linux_syscall_support.h from linux-syscall-support.googlecode.com ↵thestig@chromium.org2010-09-151-2/+2
| | | | | | | | instead of using our own copy. Review URL: http://breakpad.appspot.com/192001 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@686 4c0a9323-5329-0410-9bdc-e9ce6186880e
* ARM support, with some build system changes to support x86-64, arm, and i386 ↵nealsid2010-03-021-7/+4
| | | | | | | | | | | in an autoconf style build in Linux. The O2 build for the unit tests is still broken but I'm checking this in to unblock people A=nealsid R=ajwong, hannahtang, ted.mielczarek git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@541 4c0a9323-5329-0410-9bdc-e9ce6186880e
* Breakpad: Update copyright notice years on all files changed in 2010.jimblandy2010-02-091-1/+1
| | | | | | | | | | We've gotten mixed advice from the lawyery types about whether this matters. But it's easy enough to do. a=jimblandy, r=nealsid git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@517 4c0a9323-5329-0410-9bdc-e9ce6186880e