Bug#535568: lxpanel: Segfaults randomly in cpu.so plugin
Andrew Lee wrote: > Thank you very much for the patch. I am a bit busy now. I'd test it > ASAP. If there is no problem, I'd included it in next upload. > > BTW, the latest version of lxpanel is in experimental. If you are > interested, please test it and report bugs. :) Roger that. Sorry for the duplicated "reversed" patch - bad day. OK, probably I will take a look at the experimental one. -- Marcin Szewczyk http://wodny.org mailto:marcin.szewc...@wodny.borg <- remove b / usuń b xmpp:wo...@ubuntu.pl xmpp:wo...@jabster.pl -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Bug#535568: lxpanel: Segfaults randomly in cpu.so plugin
Hi Marcin, Thank you very much for the patch. I am a bit busy now. I'd test it ASAP. If there is no problem, I'd included it in next upload. BTW, the latest version of lxpanel is in experimental. If you are interested, please test it and report bugs. :) Cheers, -Andrew -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Bug#535568: lxpanel: Segfaults randomly in cpu.so plugin
I had some time to debug. An explanation and a patch included. Explanation: in cpu.c in cpu_update() there is a loop with a condition: i < (c->Wwg - BORDER_SIZE) The SEGFAULT appears when a problem with GTK widget allocation occurs. As the GTK documentation[1] states: "gtk_widget_set_size_request () [...] However in some strange cases a widget may be allocated less than its requested size, and in many cases a widget may be allocated more space than it requested." I've got the "strange case" here, every time lxpanel starts just after openbox. 'configure_event' is signalled a couple of times and sometimes the first one occurs after allocation of 1x1px space, while the requested size is 40x20px. When cpu_update() is allowed to execute with size 1x1 it goes into an infinite loop because (c->Wwg - BORDER_SIZE) gets negative (1 - 2), but is then compared to unsigned int. It has enough time to write unallocated memory. I thought that it would be simplest to just check if we have the requested space before drawing. [1] http://library.gnome.org/devel/gtk/unstable/GtkWidget.html#gtk-widget-set-size-request -- Marcin Szewczyk http://wodny.org mailto:marcin.szewc...@wodny.borg <- remove b / usuń b xmpp:wo...@ubuntu.pl xmpp:wo...@jabster.pl --- lxpanel-patched/src/plugins/cpu/cpu.c 2009-09-15 12:54:35.0 +0200 +++ lxpanel-0.4.1+svn20090524/src/plugins/cpu/cpu.c 2008-11-14 15:49:11.0 +0100 @@ -36,8 +36,6 @@ #define KILOBYTE 1024 #define MAX_WGSIZE 100 -#define WWIDTH 40 -#define WHEIGHT 20 #define BORDER_SIZE 2 #include "dbg.h" @@ -75,10 +73,6 @@ float total; ENTER; - -if(c->Wwg < WWIDTH) - RET(TRUE); - if(!c->pixmap) RET(TRUE); @@ -116,11 +110,6 @@ RET(TRUE); } -/* bugs.debian.org #535568: - * sometimes configure_event is signalled before the widget's space - * allocation has succeeded resulting in allocation.width and height - * being less than requested (for example 1x1) - */ static gint configure_event(GtkWidget *widget, GdkEventConfigure *event, cpu_t *c) { @@ -186,7 +175,7 @@ GTK_WIDGET_SET_FLAGS( p->pwid, GTK_NO_WINDOW ); c->da = gtk_drawing_area_new(); -gtk_widget_set_size_request(c->da, WWIDTH, WHEIGHT); +gtk_widget_set_size_request(c->da, 40, 20); gtk_widget_add_events( c->da, GDK_BUTTON_PRESS_MASK ); gtk_widget_show(c->da);
Bug#535568: lxpanel: Segfaults randomly in cpu.so plugin
I had some time to debug. An explanation and a patch included. Explanation: in cpu.c in cpu_update() there is a loop with a condition: i < (c->Wwg - BORDER_SIZE) The SEGFAULT appears when a problem with GTK widget allocation occurs. As the GTK documentation[1] states: "gtk_widget_set_size_request () [...] However in some strange cases a widget may be allocated less than its requested size, and in many cases a widget may be allocated more space than it requested." I've got the "strange case" here, every time lxpanel starts just after openbox. 'configure_event' is signalled a couple of times and sometimes the first one occurs after allocation of 1x1px space, while the requested size is 40x20px. When cpu_update() is allowed to execute with size 1x1 it goes into an infinite loop because (c->Wwg - BORDER_SIZE) gets negative (1 - 2), but is then compared to unsigned int. It has enough time to write unallocated memory. I thought that it would be simplest to just check if we have the requested space before drawing. [1] http://library.gnome.org/devel/gtk/unstable/GtkWidget.html#gtk-widget-set-size-request -- Marcin Szewczyk http://wodny.org mailto:marcin.szewc...@wodny.borg <- remove b / usuń b xmpp:wo...@ubuntu.pl xmpp:wo...@jabster.pl --- lxpanel-patched/src/plugins/cpu/cpu.c 2009-09-15 12:54:35.0 +0200 +++ lxpanel-0.4.1+svn20090524/src/plugins/cpu/cpu.c 2008-11-14 15:49:11.0 +0100 @@ -36,8 +36,6 @@ #define KILOBYTE 1024 #define MAX_WGSIZE 100 -#define WWIDTH 40 -#define WHEIGHT 20 #define BORDER_SIZE 2 #include "dbg.h" @@ -75,10 +73,6 @@ float total; ENTER; - -if(c->Wwg < WWIDTH) - RET(TRUE); - if(!c->pixmap) RET(TRUE); @@ -116,11 +110,6 @@ RET(TRUE); } -/* bugs.debian.org #535568: - * sometimes configure_event is signalled before the widget's space - * allocation has succeeded resulting in allocation.width and height - * being less than requested (for example 1x1) - */ static gint configure_event(GtkWidget *widget, GdkEventConfigure *event, cpu_t *c) { @@ -186,7 +175,7 @@ GTK_WIDGET_SET_FLAGS( p->pwid, GTK_NO_WINDOW ); c->da = gtk_drawing_area_new(); -gtk_widget_set_size_request(c->da, WWIDTH, WHEIGHT); +gtk_widget_set_size_request(c->da, 40, 20); gtk_widget_add_events( c->da, GDK_BUTTON_PRESS_MASK ); gtk_widget_show(c->da);
Bug#535568: lxpanel: Segfaults randomly in cpu.so plugin
Package: lxpanel Version: 0.4.1+svn20090524-1 Severity: normal Lxpanel segfaults randomly in cpu.so plugin during its startup. Some output from $gdb lxpanel: ** (lxpanel:5042): DEBUG: cache file_name = /home/wodny/.cache/menus/8ee9cbaa190888694876f62889f53d6f lxpanel : X error: BadAlloc (insufficient resources for operation) lxpanel : X error: BadDrawable (invalid Pixmap or Window parameter) Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb73b2700 (LWP 5042)] 0xb7fd30ff in ?? () from /usr/lib/lxpanel/plugins/cpu.so -- System Information: Debian Release: squeeze/sid APT prefers unstable APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable') Architecture: i386 (i686) Kernel: Linux 2.6.30-1-686 (SMP w/2 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages lxpanel depends on: ii libasound21.0.20-3 shared library for ALSA applicatio ii libatk1.0-0 1.26.0-1 The ATK accessibility toolkit ii libc6 2.9-18 GNU C Library: Shared libraries ii libcairo2 1.8.8-2The Cairo 2D vector graphics libra ii libfontconfig12.6.0-4generic font configuration library ii libfreetype6 2.3.9-5FreeType 2 font engine, shared lib ii libglib2.0-0 2.20.4-1 The GLib library of C routines ii libgtk2.0-0 2.16.3-1 The GTK+ graphical user interface ii libmenu-cache00.2.5-1an implementation of the freedeskt ii libpango1.0-0 1.24.3-1 Layout and rendering of internatio ii libx11-6 2:1.2.1-1 X11 client-side library ii lxmenu-data 0.1-1 freedesktop.org menu specification lxpanel recommends no packages. Versions of packages lxpanel suggests: ii elinks [www-browser] 0.12~pre4-1advanced text-mode WWW browser ii iceweasel [www-browse 3.0.11-1 lightweight web browser based on M ii links [www-browser] 2.2-1+b1 Web browser running in text mode pn lxpanel-netstat-plugi (no description available) pn lxsession-lite | lxse (no description available) ii lynx-cur [www-browser 2.8.7pre6-1Text-mode WWW Browser with NLS sup ii opera [www-browser] 9.63.2474.gcc4.qt3 The Opera Web Browser -- no debconf information -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org