! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
panel generate a segmentation fault in debug mode and cannot be run
Status:
RESOLVED: FIXED
Product:
Xfce4-panel

Comments

Description William Bonnet 2007-02-18 12:24:55 CET
User-Agent:       Mozilla/5.0 (X11; U; SunOS sun4u; fr-FR; rv:1.8.1) Gecko/20061228 Firefox/2.0
Build Identifier: 

When running panel from command line in debug mode (compiled with --enable-debug), it crashes because of a segmentation fault.

The error comes from an partially uninitialized structure sent to the _DBG macro. Somes strings are output by the macro but memory is not allocated, causing the SEGV.

Reproducible: Always

Actual Results:  
DBG[panel-item-manager.c:202] ??(): Plugin .desktop file: /opt/csw/share/xfce4/panel-plugins/separator.desktopDBG[panel-item-manager.c:241] ??(): Internal plugin: /opt/csw/lib/xfce4/panel-plugins/libseparator.so
DBG[panel-item-manager.c:348] ??():  + class "separator": name=Séparation ou espaceur, comment=Ajoute un espace ou une ligne entre les éléments du panneau, icon=signal SEGV (no mapping at the fault address) in strlen at 0xfe2b0d70
0xfe2b0d70: strlen+0x0050:      ld       [%o2], %o1



Patch is provided. 

Severity set a Major, even if panel cannot be run, it "only" happens in debug mode.
Comment 1 William Bonnet 2007-02-18 12:28:17 CET
Created attachment 1006 
This patch solve the problem by initializing all the structure members

When a string is not read from the file, is is initialized to "". Thus it can be used safely with _DBG.

The patch i propose also add some "test and output debugs" line code by testing for NULL pointers.
Comment 2 Jasper Huijsmans editbugs 2007-02-18 12:44:15 CET
Hi William,

Thanks for working on this. I have a couple of questions about the patch.

I always assumed that it is valid to pass a NULL pointer for %s, I guess this is not true for Solaris :(  I'd rather check for this in the DBG macro than add otherwise useless allocations of empty strings, though.

About the other checks, did you ever encounter a situation where these functions returned NULL? The checks look fine to me (apart from the obvious cut an paste error 'dirs == NULL' for everything ;-), but I'm curious to know if this every happened to you.

I guess I'll have to check all debug or warning messages for possible NULL pointers. Thanks again for working on this.
Comment 3 William Bonnet 2007-02-18 14:54:15 CET
Hi Jasper 
 
> Thanks for working on this. 

You're welcome ;)

> I always assumed that it is valid to pass a NULL pointer for %s, I guess this
> is not true for Solaris :(  I'd rather check for this in the DBG macro than add
> otherwise useless allocations of empty strings, though.

I have tried to initialize the string to NULL before using g_strdup ("") and i had the same segfault. I tried with setting a empty string ("") and it worked. I haven't looked what is behind the call to DBG and g_strdup (but i suppose it is a strdup call and some fprintf call ?)

I guess i can answer that yes it is different since it works this way, or maybe there is a problem elsewhere in the macro ? 

> About the other checks, did you ever encounter a situation where these
> functions returned NULL? 

No it did not happened. I was looking for the origin or the segfault and i added some extra traces to the different segment of code that could generate a NULL pointer problem. I prefered to add trace everywhere and compile once, instead of adding traces one by one :)

> The checks look fine to me (apart from the obvious cut
> an paste error 'dirs == NULL' for everything ;-), 

oops sorry :) 

> I guess I'll have to check all debug or warning messages for possible NULL
> pointers. Thanks again for working on this.
 
No problem. I am still searching for the origin of a few other problem under Solaris (which works fine on my xubuntu...). 

Comment 4 Jasper Huijsmans editbugs 2007-02-18 19:32:58 CET
Created attachment 1007 
check for NULL string values in DBG messages

William, could you try this patch instead of the one you created?

The solution is a bit different and I didn't add all checks from your patch, but it should work now.
Comment 5 William Bonnet 2007-02-18 21:07:37 CET
Hi Jasper
 
> William, could you try this patch instead of the one you created?

It works fine

thanks
Comment 6 Jasper Huijsmans editbugs 2007-02-19 18:37:13 CET
Ok, thanks for testing. I have committed it to SVN, so it will be available in the next release of Xfce.

Bug #2922

Reported by:
William Bonnet
Reported on: 2007-02-18
Last modified on: 2010-11-20

People

Assignee:
Nick Schermer
CC List:
0 users

Version

Attachments

Additional information