desktop-file-utils -q always segfaults

Bug #43977 reported by LGB [Gábor Lénárt]
10
Affects Status Importance Assigned to Milestone
desktop-file-utils (Ubuntu)
Fix Released
Medium
Ubuntu Desktop Bugs

Bug Description

Binary package hint: desktop-file-utils

Cannot install many packeges because post install / configure scripts would execute "update-desktop-database -q" which however always segfaults. The only information I was able to get:

(gdb) run -q
Starting program: /usr/bin/update-desktop-database -q
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)

Program received signal SIGSEGV, Segmentation fault.
0xb7dc98e7 in opendir () from /lib/tls/i686/cmov/libc.so.6
(gdb) bt
#0 0xb7dc98e7 in opendir () from /lib/tls/i686/cmov/libc.so.6
#1 0xb7e8f099 in g_dir_open () from /usr/lib/libglib-2.0.so.0
#2 0x08049ae1 in ?? ()
#3 0x00000010 in ?? ()
#4 0x00000000 in ?? ()

Revision history for this message
LGB [Gábor Lénárt] (lgb) wrote :

I almost forget it: it's up to date (as of 2006/may/10) dapper.

Revision history for this message
Gary Coady (garycoady) wrote :

Thanks for your bug report. Could you please try to obtain a
backtrace by following the instructions on
       http://wiki.ubuntu.com/DebuggingProgramCrash.
This will greatly aid us in tracking down your problem.

Also please install the package libglib2.0-0-dbg

Revision history for this message
LGB [Gábor Lénárt] (lgb) wrote :

Hi, sure, however I've tried to compile from source before as well. The interesting part follows: no segfault with compilation, however it always segfaults when installing deb package from dapper repository. Please note that I've issued 'apt-get --reinstall isntall' as well to be sure not the binary damaged (desktop-file-utils) or something. Now, I did what that wiki page says and no more segfault after it! HOWEVER if I reinstall package from the repository with 'apt-get --reinstall install desktop-file-utils' segfault returns ...

I've also checked: it seems there is no segfault when executing update-desktop-database without any option, however it does if I use -v or -q but _NOT_ if -v and -q. Very strange ... I've also reinstalled any package desktop-file-utils depends on but no success ...

With -v switch, the output is:

Search path is now: [/usr/local/share/applications, /usr/share/applications, Segmentation fault

Revision history for this message
LGB [Gábor Lénárt] (lgb) wrote :

Well in some cases (it seems) the binary compiled from source by me also segfaults but it seems only when using both of -v and -q switch, when I got:

(gdb) run -v -q
Starting program: /usr/bin/update-desktop-database -v -q
Search path is now: [/usr/local/share/applications, /usr/share/applications,
Program received signal SIGSEGV, Segmentation fault.
0xb7db582a in funlockfile () from /lib/tls/i686/cmov/libc.so.6
(gdb) bt
#0 0xb7db582a in funlockfile () from /lib/tls/i686/cmov/libc.so.6
#1 0xb7d9e010 in vfprintf () from /lib/tls/i686/cmov/libc.so.6
#2 0xb7dbe716 in vasprintf () from /lib/tls/i686/cmov/libc.so.6
#3 0xb7ee43e1 in IA__g_vasprintf (string=0xbf841824, format=0x0, args=0x0) at gprintf.c:313
#4 0xb7ed4f01 in IA__g_strdup_vprintf (format=0x0, args=0x0) at gstrfuncs.c:188
#5 0xb7ec60e2 in IA__g_printerr (format=0x10 <Address 0x10 out of bounds>) at gmessages.c:1008
#6 0x0804a62b in print_desktop_dirs (dirs=0x80524f0) at update-desktop-database.c:469
#7 0x0804a73d in main (argc=3, argv=0xbf8419c4) at update-desktop-database.c:514

Revision history for this message
Gary Coady (garycoady) wrote : Re: [Bug 43977] Re: desktop-file-utils -q always segfaults

LGB [Gábor Lénárt] wrote:
> Hi, sure, however I've tried to compile from source before as well. The interesting part follows: no segfault with compilation, however it always segfaults when installing deb package from dapper repository. Please note that I've issued 'apt-get --reinstall isntall' as well to be sure not the binary damaged (desktop-file-utils) or something. Now, I did what that wiki page says and no more segfault after it! HOWEVER if I reinstall package from the repository with 'apt-get --reinstall install desktop-file-utils' segfault returns ...
>
> I've also checked: it seems there is no segfault when executing update-desktop-database without any option, however it does if I use -v or -q but _NOT_ if -v and -q. Very strange ... I've also reinstalled any package desktop-file-utils depends on but no success ...

Can you install valgrind, and run
valgrind desktop-file-utils -q
and report any errors that appear?

Thanks.

Revision history for this message
LGB [Gábor Lénárt] (lgb) wrote : valgrind output

You mean valgrind update-desktop-database -q, right?
It's the update-desktop-database from dapper repository.

valgrind --log-file-exactly=/tmp/L -v update-desktop-database -q

Revision history for this message
Gary Coady (garycoady) wrote : Re: [Bug 43977] Re: desktop-file-utils -q always segfaults

Can you check if that valgrind output was with the debug version of
update-desktop-database? There's some information missing which suggests
that it was run using the version from the repository.

By the way, I'm not worried if the debug version doesn't crash - an
error should still appear in valgrind.

Thanks

Revision history for this message
LGB [Gábor Lénárt] (lgb) wrote : valgrind output again.

OK, another try :)

Revision history for this message
LGB [Gábor Lénárt] (lgb) wrote :

However I ran valgrind against update-desktop-database binary from repository with intent: because as I've written the compiled version seems to behave differently. However the second attachment I've posted some minutes ago was done with the compiled version.

Revision history for this message
Gary Coady (garycoady) wrote : Patch to fix reading/writing invalid memory

This patch should fix all the warnings reported by valgrind, a possible cause of crashes in this case.

Revision history for this message
Gary Coady (garycoady) wrote :

Thanks for that information.
Could you try rebuilding, like before, except go into the existing source directory (called "desktop-file-utils-0.10"), and run
patch -p1 < desktop-file-utils.patch
(where desktop-file-utils.patch is the attachment I added to this bug).

Then run
sudo dpkg-buildpackage -uc -us

This may fix the crash, but I'd like it to be tested, to be sure.

Revision history for this message
LGB [Gábor Lénárt] (lgb) wrote :

Ack. No segfault with any combination of switches.

Valgrind reports now:

ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 15 from 1)

Thanks.

Revision history for this message
Gary Coady (garycoady) wrote : Updated patch

The previous patch would be confusing to anybody reading it :-)

The intent of the original (unpatched) code
if (value[last_char_index] == ';')
   value[last_char_index] = '\0';

was to remove the last character of the string, if it was a semicolon.

If the string was of zero length, the previous patch I uploaded caused a comparison of '\0' against ';', which would always fail, so the patch worked. But this patch only does the test if there are any characters to actually look at.

Revision history for this message
Sebastien Bacher (seb128) wrote :

Gary, thank you for the work on that. You use "if (p > q && p[-1] == '\\' && error == NULL)"

" string_value = g_new (gchar, length);

  p = (gchar *) value;
  q = string_value;
..."

they are different variables, what "p > q" verifies for you? I would rather use "p > value" as condition, what do you think about it?

Revision history for this message
Gary Coady (garycoady) wrote : Re: [Bug 43977] Re: desktop-file-utils -q always segfaults

Sebastien Bacher wrote:
> Gary, thank you for the work on that. You use "if (p > q && p[-1] == '\\' && error == NULL)"
>
> " string_value = g_new (gchar, length);
>
> p = (gchar *) value;
> q = string_value;
> ..."
>
> they are different variables, what "p > q" verifies for you? I would rather use "p > value" as condition, what do you think about it?

While I'd hate to admit to making a mistake, you're right. p and q are
completely unrelated (as regards where they are in memory), and I agree
with using that condition instead.

Revision history for this message
Sebastien Bacher (seb128) wrote :

This upload fixes the issue:

 desktop-file-utils (0.10-1ubuntu11) dapper; urgency=low
 .
   * debian/patches/01_fix_issues_pointed_by_valgrind.patch:
     - patch by Gary Coady <email address hidden> slightly modified
     - fix issues pointed by valgrind leading to a desktop-file-utils crasher
       (Ubuntu: #43977)
   * debian/rules:
     - use simple-patchsys.mk

Changed in desktop-file-utils:
assignee: nobody → desktop-bugs
status: Unconfirmed → Fix Released
Revision history for this message
Sebastien Bacher (seb128) wrote :

I've forwarded the bug and patch upstream: http://bugzilla.gnome.org/show_bug.cgi?id=341393

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.