RE: [PATCH] fix error sending signal to dead process

"Patrick Monnerat" <[email protected]> Thu, 19 Apr 2012 17:19:02 +0200
Newsgroups gmane.comp.debugging.insight
Message-ID <AB5E58B87EB73C46A38073D8F459F113D9F89A@dataspheresrv01>
Keith Seitz wrote:

> There should be spaces between function names and opening parenthesis.

> [Yeah, it's rather lame, but it is GNU coding standard. Insight
follows GDB's conventions.]

> ChangeLog entry?

The new attached patch fixes both of your remarks. It has been made
against today's cvs snapshot.

> [Aside: Eew. I can't believe Tcl_Eval is still being used!]

Well... I'm not enough involved in insight's guts and tcl to share your
estonishment. You're probably right. But I can say at least this call is
clear enough to understand what's happening :-)
In fact I'm only the insight's packager for Fedora.

Thanks for your help.
Cheers,
Patrick
insight-7.4.50-sig2dead.patch (application/octet-stream, 1.3 KB)
diff -Naur src.orig/gdb/gdbtk/ChangeLog src.new/gdb/gdbtk/ChangeLog
--- src.orig/gdb/gdbtk/ChangeLog	2012-04-19 11:41:24.000000000 +0200
+++ src.new/gdb/gdbtk/ChangeLog	2012-04-19 17:04:04.601462401 +0200
@@ -1,3 +1,8 @@
+2012-04-19  Patrick Monnerat  <[email protected]>
+
+	* generic/gdbtk-hooks.c (gdbtk_annotate_signal): Avoid
+	dereferencing a null (i.e.: dead) process/thread.
+
 2012-04-19  Roland Schwingel  <[email protected]>
 
 	* generic/gdbtk-bp.c: Updated copyright.
diff -Naur src.orig/gdb/gdbtk/generic/gdbtk-hooks.c src.new/gdb/gdbtk/generic/gdbtk-hooks.c
--- src.orig/gdb/gdbtk/generic/gdbtk-hooks.c	2012-03-28 15:09:12.000000000 +0200
+++ src.new/gdb/gdbtk/generic/gdbtk-hooks.c	2012-04-19 16:57:27.929884730 +0200
@@ -804,7 +804,7 @@
 gdbtk_annotate_signal (void)
 {
   char *buf;
-  struct thread_info *tp = inferior_thread ();
+  struct thread_info *tp;
 
   /* Inform gui that the target has stopped. This is
      a necessary stop button evil. We don't want signal notification
@@ -812,6 +812,11 @@
      timeout. */
   Tcl_Eval (gdbtk_interp, "gdbtk_stop_idle_callback");
 
+  if (ptid_equal (inferior_ptid, null_ptid))
+    return;
+
+  tp = inferior_thread ();
+
   buf = xstrprintf ("gdbtk_signal %s {%s}",
 	     target_signal_to_name (tp->suspend.stop_signal),
 	     target_signal_to_string (tp->suspend.stop_signal));