Wireshark-dev: Re: [Wireshark-dev] Cannot use "capture info" dialog, wireshark gets SIGUSR1 [WO

From: Alexey Neyman <avn@xxxxxxxxxxxxxxx>
Date: Fri, 8 Aug 2008 22:36:43 -0700
I pinpointed the breakage breakage to somewhere in between revision 
25545 and 25577. It cannot be pinpointed any more precisely, as 
revisions in between do not build.

The author of most these changes was Guy Harries (CC'ed). One of the 
changes was making capture_info_delete_cb() rely on the "gpointer data" 
argument instead of using a global pointer, and it broke this feature.

I understand that using global pointer is probably a bad practice. 
However, I am not familiar with GTK internals to investigate it 
further. So, until somebody fixes it "the right way", could the 
attached workaround be applied?

Best regards,
Alexey Neyman.

On Friday 08 August 2008 01:43:30 Alexey Neyman wrote:
> Howdy,
>
> I am running Ubuntu Hardy 8.04.1, GCC 4.2.3 on x86_64. Wireshark
> sources are top-of-trunk.
>
> When starting a capture, I tried to uncheck the boxes "Update list of
> packets in real time" and "Hide capture info dialog". The capture
> started fine, but when I hit the "Stop" button, Wireshark exited due
> to receipt of SIGUSR1.
>
> If I use the "Stop capture" button on the toolbar, the capture stops
> and the list of captured packets is displayed.
>
> I traced the problem to the following fact: the
> capture_info_delete_cb() function is called with a "data" pointer
> which is different from the one supplied to g_connect(). It so
> happens that the fork_child member at that "bad pointer" has a value
> of 0, and thus SIGUSR1 is delivered to the current process group
> instead of dumpcap.
>
> Below, what GDB shows:
>
> <<<<<
> Breakpoint 6, capture_info_ui_create (cinfo=0x78be40,
> capture_opts=0x79c0e0) at capture_info_dlg.c:269
> 269       stop_bt = g_object_get_data(G_OBJECT(bbox),
> WIRESHARK_STOCK_CAPTURE_STOP);
> (gdb) c
> Continuing.
>
> Breakpoint 7, capture_info_delete_cb (w=0x196e420, event=0x79c0e0,
> data=0x89c960) at capture_info_dlg.c:93
> 93      capture_info_delete_cb(GtkWidget *w _U_, GdkEvent *event _U_,
> gpointer data) {
> <<<<
>
> Note that the correct value for capture_opts somehow ended up in
> 'event' argument instead of 'data'. I am not sure if it is a GTK or
> Wireshark problem. Is GTK packaging arguments to signals in a wrong
> way on x86_64?
>
> Best regards,
> Alexey Neyman.
> _______________________________________________
> Wireshark-dev mailing list
> Wireshark-dev@xxxxxxxxxxxxx
> https://wireshark.org/mailman/listinfo/wireshark-dev
Index: gtk/capture_info_dlg.c
===================================================================
--- gtk/capture_info_dlg.c	(revision 25965)
+++ gtk/capture_info_dlg.c	(working copy)
@@ -50,6 +50,7 @@
 #include "gtk/main.h"
 #include "gtk/help_dlg.h"
 #include "gtk/stock_icons.h"
+#include "gtk/capture_globals.h"
 
 #ifdef HAVE_AIRPCAP
 #include <airpcap.h>
@@ -90,13 +91,12 @@
 }
 
 static gboolean
-capture_info_delete_cb(GtkWidget *w _U_, GdkEvent *event _U_, gpointer data) {
-  capture_options *capture_opts = data;
+capture_info_delete_cb(GtkWidget *w _U_, GdkEvent *event _U_, gpointer data _U_) {
 #ifdef HAVE_AIRPCAP
   airpcap_set_toolbar_stop_capture(airpcap_if_active);
 #endif
 
-  capture_stop(capture_opts);
+  capture_stop(&global_capture_opts);
   return TRUE;
 }