breakpad/src
Lars Volker 97a9883676 Only restore the signal handler if sigaction has not changed
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>
2018-01-09 16:22:07 +00:00
..
build Fix MSVC build on 64-bit 2017-09-25 07:10:11 +00:00
client Only restore the signal handler if sigaction has not changed 2018-01-09 16:22:07 +00:00
common Add asm and machine headers 2018-01-03 21:22:16 +00:00
google_breakpad Add optional field indicating multiple symbols at an address 2017-11-29 21:33:23 +00:00
processor Make iterator string types match map container string types 2017-12-01 18:57:52 +00:00
third_party List missing 64-bit arches in the bundled curl 2017-11-13 19:50:29 +00:00
tools Fixed file extention for minidump_upload in tools_linux.gypi 2018-01-04 08:43:43 +00:00
breakpad_googletest_includes.h test: allow use of system gmock/gtest libs 2016-01-25 19:27:56 -05:00
config.h.in Only use O_CLOEXEC on platforms that support it 2017-05-10 21:32:37 +00:00