[Lldb-commits] [lldb] r265958 - [Driver] Fix a segfault in signal handlers

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Mon Apr 11 09:40:09 PDT 2016

Author: labath
Date: Mon Apr 11 11:40:09 2016
New Revision: 265958

URL: http://llvm.org/viewvc/llvm-project?rev=265958&view=rev
[Driver] Fix a segfault in signal handlers

If we recieve a SIGCONT or SIGTSTP, while the driver is shutting down (which, sometimes, we do,
for reasons which are not completely clear to me), we would crash to due a null pointer
dereference. Guard against this situation.

Reviewers: clayborg

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D18965


Modified: lldb/trunk/tools/driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=265958&r1=265957&r2=265958&view=diff
--- lldb/trunk/tools/driver/Driver.cpp (original)
+++ lldb/trunk/tools/driver/Driver.cpp Mon Apr 11 11:40:09 2016
@@ -1283,7 +1283,9 @@ sigint_handler (int signo)
 sigtstp_handler (int signo)
-    g_driver->GetDebugger().SaveInputTerminalState();
+    if (g_driver)
+        g_driver->GetDebugger().SaveInputTerminalState();
     signal (signo, SIG_DFL);
     kill (getpid(), signo);
     signal (signo, sigtstp_handler);
@@ -1292,7 +1294,9 @@ sigtstp_handler (int signo)
 sigcont_handler (int signo)
-    g_driver->GetDebugger().RestoreInputTerminalState();
+    if (g_driver)
+        g_driver->GetDebugger().RestoreInputTerminalState();
     signal (signo, SIG_DFL);
     kill (getpid(), signo);
     signal (signo, sigcont_handler);

More information about the lldb-commits mailing list