GNOME Bugzilla – Bug 339815
xdgmime reloads its data and crashes Beagle
Last modified: 2006-06-09 21:00:00 UTC
Steps to reproduce: 1. Use beagle-build-index to index a collection of Ogg files 2. Watch it crash Stack trace: Debug: +file:///var/www/html/Songs/Kate Rusby/Underneath The Stars/11_Sweet_Williams_Ghost.ogg ================================================================= Got a SIGSEGV while executing native code. This usually indicates a fatal error in the mono runtime or one of the native libraries used by your application. ================================================================= Stacktrace: in (wrapper managed-to-native) Beagle.Util.XdgMime:xdg_mime_get_mime_type_for_file (string,intptr) <0xe> in (wrapper managed-to-native) Beagle.Util.XdgMime:xdg_mime_get_mime_type_for_file (string,intptr) <0xfffffffffffffeea> in Beagle.Util.XdgMime:GetMimeType (string) (at /usr/src/build/737669-x86_64/BUILD/beagle-0.2.5/Util/XdgMime.cs:43) in Beagle.Daemon.FilterFactory:FilterIndexable (Beagle.Indexable,Beagle.Daemon.TextCache,Beagle.Daemon.Filter&) (at /usr/src/build/737669-x86_64/BUILD/beagle-0.2.5/beagled/FilterFactory.cs:218) in Beagle.Daemon.LuceneIndexingDriver:Flush_Unlocked (Beagle.Daemon.IndexerRequest) (at /usr/src/build/737669-x86_64/BUILD/beagle-0.2.5/beagled/LuceneIndexingDriver.cs:259) in Beagle.Daemon.LuceneIndexingDriver:Flush (Beagle.Daemon.IndexerRequest) (at /usr/src/build/737669-x86_64/BUILD/beagle-0.2.5/beagled/LuceneIndexingDriver.cs:90) in Beagle.Daemon.BuildIndex:FlushIndexer (Beagle.Daemon.IIndexer,Beagle.Daemon.IndexerRequest) (at /usr/src/build/737669-x86_64/BUILD/beagle-0.2.5/beagled/BuildIndex.cs:383) in Beagle.Daemon.BuildIndex:IndexWorker () (at /usr/src/build/737669-x86_64/BUILD/beagle-0.2.5/beagled/BuildIndex.cs:455) in (wrapper delegate-invoke) System.MulticastDelegate:invoke_void () <0x6a0> in Beagle.Util.ExceptionHandlingThread:ThreadStarted () (at /usr/src/build/737669-x86_64/BUILD/beagle-0.2.5/Util/ExceptionHandlingThread.cs:54) in (wrapper delegate-invoke) System.MulticastDelegate:invoke_void () <0xfffffffffffe602e> in (wrapper runtime-invoke) System.Object:runtime_invoke_void (object,intptr,intptr,intptr) <0xffffffffc0212bc2> Native stacktrace: beagle-build-index(mono_handle_native_sigsegv+0x8d) [0x4e7c6d] beagle-build-index [0x4b56b8] /lib64/libpthread.so.0 [0x3063d0cf40] /lib64/libc.so.6(strcmp+0) [0x3062c73ba0] /lib64/libc.so.6(bsearch+0x5e) [0x3062c312ce] /usr/lib64/beagle/libbeagleglue.so(_xdg_mime_alias_list_lookup+0x3c) [0x2aaaaeda7bac] /usr/lib64/beagle/libbeagleglue.so(xdg_mime_unalias_mime_type+0x2f) [0x2aaaaeda571f] /usr/lib64/beagle/libbeagleglue.so(xdg_mime_mime_type_equal+0x2c) [0x2aaaaeda593c] /usr/lib64/beagle/libbeagleglue.so(_xdg_mime_magic_lookup_data+0x75) [0x2aaaaeda7895] /usr/lib64/beagle/libbeagleglue.so(xdg_mime_get_mime_type_for_file+0x1a1) [0x2aaaaeda5ba1] [0x408e133c] Other information: After some investigation it transpires that there are actually two bugs here - the first is that _xdg_mime_magic_lookup_data() is iterating over the list of matchers given it by xdg_mime_get_mime_type_for_file() (ie the global_match list) and calls xdg_mime_mime_type_equal() which calls xdg_mime_init() which may decide that the MIME data has changed in which case it discards the global_match list and rebuilds it. When we return to xdg_mime_get_mime_type_for_file() the list that was being interated over has been freed and we crash shortly therafter. Of course you would normally have to ve very unlucky to encounter this as the MIME data doesn't change very often, but there is a second bug which causes beagle to decide to reread it when it hasn't changed - in fact after every check (every 5 seconds) it is reread. The reason for this is that because HAVE_MMAP is not defined _xdg_mime_cache_new_from_file() always returns NULL which means that xdg_mime_init_from_directory() does not add mime.cache to the dir_time_list. When xdg_check_dirs() is next called to check for changes it fails to find anything to compare mime.cache to so forces a reload. This continues ad infinitum.
I believe this has been fixed in this commit. http://cia.navi.cx/stats/project/gnome/beagle/.message/4c160 However, if you could attach/provide a way for us download the offending file or try the CVS of beagle to verify that would be great.
(In reply to comment #1) > I believe this has been fixed in this commit. > > http://cia.navi.cx/stats/project/gnome/beagle/.message/4c160 I believe not. This is a bug in xdgmime itself, while trying to determine the mimetype. The commit referred to fixed a crash in beagle due to unmatched mimetype between entagged and beagle.
That's right - that commit actually relates to my earlier bug, 339792, which is closed because it was already fixed by the commit. There is point in attaching a file either, as this isn't specific to any particular file - it crashes on a different file each time a I run it. It's a timing thing as the crash only occurs when the five second timeout to trigger a recheck of the MIME data happens at the right (or wrong) point.
The xdgmime stuff is shared among a bunch of different applications, as it's the reference implementation of the freedesktop.org shared mime info spec: http://freedesktop.org/wiki/Standards_2fshared_2dmime_2dinfo_2dspec Tom, do you know if a bug has been filed (or better yet, fixed) upstream about this?
I've checked out the current xdgmime code and it exactly matches the code in beagle 0.2.5 so it certainly doesn't look like anything has been fixed. I also can't see anything in the xdgmime bugzilla which appears to match either of these issues. Do you want me to report it upstream in the xdgmime bugzilla? The constant re-read issue can (and quite possibly should) be worked around (at least for platforms with mmap support) by adding AC_FUNC_MMAP() to the beagle configure so that xdgmime knows mmap is available. That also means the MIME cache will be used which it isn't at the moment. It also mitigates the first problem as the crash can then only occur if the MIME data genuinely changes at a bad moment.
Yeah, if you don't mind filing an upstream bug, that would be a good idea, considering many others also use xdgmime it's bound to bite someone some day. :) Adding AC_FUNC_MMAP() is a good idea, I'll add that.
Pushed upstream to the FreeDesktop.org bugzila as bug #6824 (https://bugs.freedesktop.org/show_bug.cgi?id=6824).
I've checked in the AC_FUNC_MMAP() thing, and I submitted a patch upstream.
Haven't heard anything about the patch, so I just committed this to our local tree.