1 From caa6f1ea462d0f0c612b871106e3e309fe0290f5 Mon Sep 17 00:00:00 2001
2 From: Stephan Bergmann <sbergman@redhat.com>
3 Date: Thu, 16 Aug 2018 09:04:35 +0200
4 Subject: [PATCH] Handle race between ExceptionHandler::SignalHandler and
7 ...where thread A is blocked locking g_handler_stack_mutex_ in SignalHandler
8 while thread B executes ~ExceptionHandler and sets g_handler_stack to null, but
9 which thread A didn't expect to be null once it acquired the lock.
11 src/client/linux/handler/exception_handler.cc | 6 ++++--
12 1 file changed, 4 insertions(+), 2 deletions(-)
14 diff --git a/src/client/linux/handler/exception_handler.cc b/src/client/linux/handler/exception_handler.cc
15 index b895f6d7..4d58e510 100644
16 --- a/src/client/linux/handler/exception_handler.cc
17 +++ b/src/client/linux/handler/exception_handler.cc
18 @@ -372,8 +372,10 @@ void ExceptionHandler::SignalHandler(int sig, siginfo_t* info, void* uc) {
22 - for (int i = g_handler_stack_->size() - 1; !handled && i >= 0; --i) {
23 - handled = (*g_handler_stack_)[i]->HandleSignal(sig, info, uc);
24 + if (g_handler_stack_ != NULL) {
25 + for (int i = g_handler_stack_->size() - 1; !handled && i >= 0; --i) {
26 + handled = (*g_handler_stack_)[i]->HandleSignal(sig, info, uc);
30 // Upon returning from this signal handler, sig will become unmasked and then