GNOME Bugzilla – Bug 619736
crash on 0-byte file in log search
Last modified: 2010-05-27 08:35:54 UTC
Created attachment 162031 [details] [review] patch to fix 0-byte logfile crash (empathy:29893): GLib-CRITICAL **: g_utf8_casefold: assertion `str != NULL' failed Program received signal SIGSEGV, Segmentation fault. *__GI_strstr (haystack_start=0x0, needle_start=0x159b730 "live.gnome.org") at strstr.c:58 58 strstr.c: No such file or directory. in strstr.c (gdb) bt
+ Trace 222113
633 contents = g_mapped_file_get_contents (file); 634 contents_casefold = g_utf8_casefold (contents, length); 635 636 g_mapped_file_unref (file); 637 638 if (strstr (contents_casefold, text_casefold)) 639 { 640 EmpathyLogSearchHit *hit; 641 642 hit = log_store_empathy_search_hit_new (self, filename); (gdb) p filename $1 = (gchar *) 0x160f9b0 "/home/robot101/.local/share/Empathy/logs/gabble_jabber_bzubhipheron_40gmail_2ecom0/epmfairweather@gmail.com/20090216.log" (gdb) p file $2 = (GMappedFile *) 0x1728a20 (gdb) p length $4 = 0 (gdb) p contents $3 = (gchar *) 0x0 File is zero-byte - don't know how/why: -rw------- 1 robot101 robot101 0 Feb 16 2009 /home/robot101/.local/share/Empathy/logs/gabble_jabber_bzubhipheron_40gmail_2ecom0/epmfairweather@gmail.com/20090216.log Attached patch makes it robust against this. But the UI still blocks while searching, and I have a lot of logs. :'(
Created attachment 162033 [details] [review] updated patch to fix leaks
My patch introduced a leak of the GMappedFile, but also the original code leaked the filename if the GMappedFile creation failed.
Thanks, I merged your patch to 2.30 and master. I just did some comestic changes to fit with our coding style: we use if (ptr != NULL) and if (value != 0) rather than if (ptr) and if (value). if (badger) is only used for booleans. Next time you can use git format-patch for extra git synergy :) This problem has been fixed in our software repository. The fix will go into the next software release. Thank you for your bug report.
FYI I backported your fix to the logger: https://bugs.freedesktop.org/show_bug.cgi?id=28275