[Lldb-commits] [PATCH] D18965: [Driver] Fix a segfault in signal handlers

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Mon Apr 11 07:28:58 PDT 2016

labath created this revision.
labath added a reviewer: clayborg.
labath added a subscriber: lldb-commits.

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.



Index: tools/driver/Driver.cpp
--- tools/driver/Driver.cpp
+++ tools/driver/Driver.cpp
@@ -1283,16 +1283,20 @@
 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);
 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);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18965.53239.patch
Type: text/x-patch
Size: 730 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160411/70990362/attachment.bin>

More information about the lldb-commits mailing list