! 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 !
Fix segfault on clearing empty log
Status:
RESOLVED: FIXED
Product:
Xfce4-notifyd
Component:
general

Comments

Description Igor editbugs 2017-02-18 19:15:57 CET
Created attachment 7005 
patch

Thread 1 "xfce4-notifyd-c" received signal SIGSEGV, Segmentation fault.
0x00007ffff48f4b64 in fclose@@GLIBC_2.2.5 () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff48f4b64 in fclose@@GLIBC_2.2.5 () at /usr/lib/libc.so.6
#1  0x000000000040674f in xfce_notify_log_clear () at xfce4-notifyd/xfce-notify-log.c:127
#2  0x00007ffff516bf75 in g_closure_invoke () at /usr/lib/libgobject-2.0.so.0
#3  0x00007ffff517df82 in  () at /usr/lib/libgobject-2.0.so.0
#4  0x00007ffff5186bcc in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0
#5  0x00007ffff518745b in g_signal_emit_by_name () at /usr/lib/libgobject-2.0.so.0
#6  0x00007ffff516c1a4 in  () at /usr/lib/libgobject-2.0.so.0
#7  0x00007ffff51868bd in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0
#8  0x00007ffff5186faf in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#9  0x00007ffff6d58cbd in  () at /usr/lib/libgtk-3.so.0
#10 0x00007ffff6d58d25 in  () at /usr/lib/libgtk-3.so.0
Comment 1 Simon Steinbeiss editbugs 2017-02-18 20:03:00 CET
Thanks, pushed to master:
https://git.xfce.org/apps/xfce4-notifyd/commit/?id=f8691b209d17748a768a5ce199a2f05890acd78e

(FWIW the better fix would be to make at least the log clear button insensitive.)
Comment 2 Igor editbugs 2017-02-26 18:33:28 CET
Created attachment 7029 
Update log toolbar buttons sensitivity
Comment 3 Igor editbugs 2017-02-26 18:33:50 CET
(In reply to Simon Steinbeiss from comment #1)
> (FWIW the better fix would be to make at least the log clear button
> insensitive.)

Please see the 2nd patch attached.
Comment 4 Simon Steinbeiss editbugs 2017-02-26 23:08:52 CET
Nice work!

Just two small comments:
1) please always mention the bug number in the commit message (better traceability)
2) I know it's not necessary to always cast to the correct type if you're passing around a pointer, but this (imo, and I'm only a self-taught programmer) is a little less readable:
    xfce4_notifyd_log_populate (user_data);
than this:
    GtkWidget *log_listbox = user_data;
    xfce4_notifyd_log_populate (log_listbox);

I have fixed point 1), about 2) I can only say that the various projects in Xfce have very diverse code-bases and I've seen this and that around. C makes you write a lot of LOC anyway, so I usually stick to the latter variant (the Gtk+ devs also seem to do it like that in their example code as well as their code in Gtk+ itself).
Comment 5 Simon Steinbeiss editbugs 2017-02-26 23:09:39 CET
Oh, and I forgot, pushed to master: https://git.xfce.org/apps/xfce4-notifyd/commit/?id=4ae77c091721a03233e3d30546f918f96276a41b
Comment 6 Igor editbugs 2017-02-27 07:40:35 CET
OK, I agree regarding 2).

Moreover, to make it even more clean, I'd tend to using it like
    GtkWidget *log_listbox = GTK_WIDGET (user_data);
    xfce4_notifyd_log_populate (log_listbox);
i.e. casting types explicitly rather than implicitly. xfce4-terminal is using this approach.

But you're right, this is for the sake of readability only; the compiler allows implicit casting of void* to any other pointer type so from its perspective there's no need in doing that.

Bug #13365

Reported by:
Igor
Reported on: 2017-02-18
Last modified on: 2017-02-27

People

Assignee:
Simon Steinbeiss
CC List:
0 users

Version

Attachments

patch (701 bytes, patch)
2017-02-18 19:15 CET , Igor
no flags
Update log toolbar buttons sensitivity (6.89 KB, patch)
2017-02-26 18:33 CET , Igor
no flags

Additional information