! 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 !
Thunar crashes when hovering over a CD drive with an icon
Status:
RESOLVED: FIXED

Comments

Description Ambroz Bizjak 2011-02-19 15:22:44 CET
Created attachment 3485 
Fix for the bug

To reproduce:
1. install a CD drive
2. remove media from the drive
3. open Thunar
4. insert a CD that has a special icon (e.g. a Windows game)
5. click on the CD drive in the side pane and wait until it is mounted
6. navigate to computer:///
7. move the cursor over the CD drive entry

Result:
GLib-GIO-CRITICAL **: char *g_file_get_path(GFile *): assertion `G_IS_FILE (file)' failed
(more assertion failures and maybe crash)
Comment 1 Jannis Pohlmann editbugs 2011-02-19 16:13:36 CET
That's weird. g_file_icon_get_file() returns the icon->file member of the GFileIcon and g_object_get(..., "file", &icon_file, ...) returns exactly the same thing, or should do that at least. You can see this here:

  http://git.gnome.org/browse/glib/tree/gio/gfileicon.c

Do you know if this was different in older releases of GLib?
Comment 2 Ambroz Bizjak 2011-02-19 16:18:04 CET
Sorry, I don't really know why the original code crashes. Seems like the cast of GIcon to GFileIcon is done wrong, but I've never done any GLib programming. I just changed it do use a propery like the code a few line above does for themed icons.
Comment 3 Jannis Pohlmann editbugs 2011-02-19 16:29:44 CET
I checked again in the GLib/GIO source code and both ways should work exactly the same way. g_file_icon_get_file() was even introduced before there was a "file" property, so I think it is the better choice. The cast is correct but still... I wonder why the patch works for you and the current code doesn't...
Comment 4 Ambroz Bizjak 2011-02-19 18:02:48 CET
You're right, there's nothing wrong with that piece of code. This smells of memory corruption. I'll investigate further.

Can you reproduce it? I should note that it has to be a CD/DVD; a .desktop file with an absolute file for Icon will not trigger it.
Comment 5 Jannis Pohlmann editbugs 2011-02-19 18:06:27 CET
I cannot reproduce it yet because I first have to find a CD with a special icon. ;)
Comment 6 Ambroz Bizjak 2011-02-19 18:16:03 CET
Created attachment 3487 
Better fix for the bug

Got it! :)
Comment 7 Jannis Pohlmann editbugs 2011-02-19 18:29:01 CET
Yep, that's indeed it. g_file_icon_get_file() doesn't increase the reference count of the GFile it returns. Good catch!

Fixed in master and the xfce-4.8 branch. I've credited you as the author of the commit:

commit d5739ef148b02a5212dea2c0d7dcb7de4c79dd46
Author: Ambroz Bizjak <ambrop7@gmail.com>
Date:   Sat Feb 19 18:26:20 2011 +0100

    Don't decrease refcount of files returned by GFileIcon (bug #7309).
    
    This fixes a crash when hovering CD drives with a special icon in
    computer://.
    
    Signed-off-by: Jannis Pohlmann <jannis@xfce.org>

Bug #7309

Reported by:
Ambroz Bizjak
Reported on: 2011-02-19
Last modified on: 2011-02-19

People

Assignee:
Jannis Pohlmann
CC List:
0 users

Version

Attachments

Fix for the bug (504 bytes, patch)
2011-02-19 15:22 CET , Ambroz Bizjak
no flags
Better fix for the bug (406 bytes, patch)
2011-02-19 18:16 CET , Ambroz Bizjak
no flags

Additional information