FS#80279 - [glib2] shared-mime-info 2.4-1 issue with javascript/ecmascript definition
Attached to Project:
Arch Linux
Opened by mephinet (mephinet) - Friday, 17 November 2023, 09:44 GMT
Last edited by Buggy McBugFace (bugbot) - Saturday, 25 November 2023, 20:22 GMT
Opened by mephinet (mephinet) - Friday, 17 November 2023, 09:44 GMT
Last edited by Buggy McBugFace (bugbot) - Saturday, 25 November 2023, 20:22 GMT
|
Details
Now this took a while to figure out:
After a system update last week, meld 3.22.0-2 stopped working for me (even though it hasn't seen a new version for ~6 months), immediately dying with a segfault. Using gdb and strace, I could trace it down to the parsing of the recently-used.xbel file, which contains the content of the recently opened files menu. Meld is stuck in an infinite loop until (I guess) stack runs out: $ gdb /usr/bin/python -ex "set args /usr/bin/meld" -ex run #3 0x00007ffff6a1d2ff in __gio_xdg_cache_mime_type_subclass (mime=mime@entry=0x7fffeb5a6610 "text/javascript", base=base@entry=0x555555b410c0 "application/x-meld-comparison") at ../glib/gio/xdgmime/xdgmimecache.c:971 #4 0x00007ffff6a1d2ff in __gio_xdg_cache_mime_type_subclass (mime=mime@entry=0x7fffeb5d3484 "application/ecmascript", base=base@entry=0x555555b410c0 "application/x-meld-comparison") at ../glib/gio/xdgmime/xdgmimecache.c:971 #5 0x00007ffff6a1d2ff in __gio_xdg_cache_mime_type_subclass (mime=mime@entry=0x7fffeb5a6610 "text/javascript", base=base@entry=0x555555b410c0 "application/x-meld-comparison") at ../glib/gio/xdgmime/xdgmimecache.c:971 #6 0x00007ffff6a1d2ff in __gio_xdg_cache_mime_type_subclass (mime=mime@entry=0x7fffeb5d3484 "application/ecmascript", base=base@entry=0x555555b410c0 "application/x-meld-comparison") at ../glib/gio/xdgmime/xdgmimecache.c:971 Downgrading to shared-mime-info-2.3-1 fixes the segfault. I bisected the recently-used.xbel and found the entry that triggers the behaviour - an entry for a .js file. A minimal recently-used.xbel is attached. Maybe https://cgit.freedesktop.org/xdg/shared-mime-info/commit/?id=9f234ca58cfd9b935ab8cc5efb90aa9ae0cc127b is to blame? Steps to reproduce: * Install meld 3.22.0-2 and shared-mime-info-2.4-1 * Make a backup of your .local/share/recently-used.xbel * Copy the attached recently-used-reproducer.xbel over your .local/share/recently-used.xbel * Start meld, enjoy the segfault * Downgrade to shared-mime-info-2.3-1 * meld starts fine |
This task depends upon
Closed by Buggy McBugFace (bugbot)
Saturday, 25 November 2023, 20:22 GMT
Reason for closing: Moved
Additional comments about closing: https://gitlab.archlinux.org/archlinux/p ackaging/packages/glib2/issues/1
Saturday, 25 November 2023, 20:22 GMT
Reason for closing: Moved
Additional comments about closing: https://gitlab.archlinux.org/archlinux/p ackaging/packages/glib2/issues/1
I encountered this with Dolphin not starting up, stuck in a loop with a fast infinite memory leak. Better reproduction was Thunar crashing every time I opened a directory which contained a JS file, or a GTK file picker crashing any app using it (say of VS Code) on visiting such directory.
Simplest reproduction: `xdg-mime query filetype 0test/1.js`
The JS file has to contain a function declaration or something, empty file doesn't cause issues.
I troubleshooted this on Matrix with users @olly1240 (who tried to reproduce it on a fresh new VM install and couldn't so probably not an upstream issue) and @post-factum.
Stack trace:
#0 0x00007fcb8b754c99 in cache_alias_lookup (alias=alias@entry=0x7fcb87c9b58c "application/ecmascript") at ../glib/gio/xdgmime/xdgmimecache.c:308
#1 0x00007fcb8b7550a2 in __gio_xdg_cache_unalias_mime_type (mime=0x7fcb87c9b58c "application/ecmascript") at ../glib/gio/xdgmime/xdgmimecache.c:988
#2 __gio_xdg_cache_mime_type_subclass (mime=mime@entry=0x7fcb87c9b58c "application/ecmascript", base=base@entry=0x7fcb87c98e48 "text/x-matlab")
at ../glib/gio/xdgmime/xdgmimecache.c:911
#3 0x00007fcb8b7552ff in __gio_xdg_cache_mime_type_subclass (mime=mime@entry=0x7fcb879db46c "text/javascript", base=base@entry=0x7fcb87c98e48 "text/x-matlab")
at ../glib/gio/xdgmime/xdgmimecache.c:971
#4 0x00007fcb8b7552ff in __gio_xdg_cache_mime_type_subclass (mime=mime@entry=0x7fcb87c9b58c "application/ecmascript", base=base@entry=0x7fcb87c98e48 "text/x-matlab")
at ../glib/gio/xdgmime/xdgmimecache.c:971
#5 0x00007fcb8b7552ff in __gio_xdg_cache_mime_type_subclass (mime=mime@entry=0x7fcb879db46c "text/javascript", base=base@entry=0x7fcb87c98e48 "text/x-matlab")
at ../glib/gio/xdgmime/xdgmimecache.c:971
#6 0x00007fcb8b7552ff in __gio_xdg_cache_mime_type_subclass (mime=mime@entry=0x7fcb87c9b58c "application/ecmascript", base=base@entry=0x7fcb87c98e48 "text/x-matlab")
at ../glib/gio/xdgmime/xdgmimecache.c:971
#7 0x00007fcb8b7552ff in __gio_xdg_cache_mime_type_subclass (mime=mime@entry=0x7fcb879db46c "text/javascript", base=base@entry=0x7fcb87c98e48 "text/x-matlab")
at ../glib/gio/xdgmime/xdgmimecache.c:971
#8 0x00007fcb8b7552ff in __gio_xdg_cache_mime_type_subclass (mime=mime@entry=0x7fcb87c9b58c "application/ecmascript", base=base@entry=0x7fcb87c98e48 "text/x-matlab")
at ../glib/gio/xdgmime/xdgmimecache.c:971
#9 0x00007fcb8b7552ff in __gio_xdg_cache_mime_type_subclass (mime=mime@entry=0x7fcb879db46c "text/javascript", base=base@entry=0x7fcb87c98e48 "text/x-matlab")
at ../glib/gio/xdgmime/xdgmimecache.c:971
#10 0x00007fcb8b7552ff in __gio_xdg_cache_mime_type_subclass (mime=mime@entry=0x7fcb87c9b58c "application/ecmascript", base=base@entry=0x7fcb87c98e48 "text/x-matlab")
at ../glib/gio/xdgmime/xdgmimecache.c:971
Edit:
I suspect a similar change is needed in glib to guard against infinite recursion in _xdg_mime_cache_mime_type_subclass [3].
[1]: https://code.qt.io/cgit/qt/qtbase.git/commit/?id=54656da9ace06caf4a0eeb1832989c0ab211a4a0
[2]: https://gitlab.freedesktop.org/xdg/shared-mime-info/-/merge_requests/258
[3]: https://gitlab.gnome.org/GNOME/glib/-/blob/2.78.1/gio/xdgmime/xdgmimecache.c?ref_type=tags#L971
<mime-type type="application/javascript">
<sub-class-of type="application/ecmascript"/>
Deleting this file solves the issue, even with shared-mime-info 2.4-1.
So I guess that there is no way to assure that the different definitions are, over all, cycle free. The cycle breaking needs to be done by the reading applications.
$ ls -al /home/ojirio/.nix-profile/share/mime/packages/
lrwxrwxrwx 1 root root 104 Jan 1 1970 freedesktop.org.xml -> /nix/store/hklmsy2ilprrywn1ppyad7aaglx2zvg4-shared-mime-info-2.2/share/mime/packages/freedesktop.org.xml
Clearly the new 2.4 shared-mime-info Arch package conflicts with that.
This directory is referenced by XDG_DATA_DIRS which I assume means is used in the mime type resolution:
$ export | grep XDG_DATA_DIRS
declare -x XDG_DATA_DIRS="/nix/store/1605y2yxxh4v85nlppv7al28d1rl73ib-mate-terminal-1.26.1/share:/nix/store/drdhg1pghyl0dvmngkadv6viv8jrm0zc-gsettings-desktop-schemas-44.0/share/gsettings-schemas/gsettings-desktop-schemas-44.0:/nix/store/6qp789r70ka5ahxfzrr9l3h6szclsgsr-gtk+3-3.24.38/share/gsettings-schemas/gtk+3-3.24.38:/nix/store/47vwyf8dfi0ny4bd31khq9ah0nqvw504-mate-desktop-1.26.2/share/gsettings-schemas/mate-desktop-1.26.2:/nix/store/1605y2yxxh4v85nlppv7al28d1rl73ib-mate-terminal-1.26.1/share/gsettings-schemas/mate-terminal-1.26.1:/nix/var/nix/profiles/default/share:/home/ojirio/.nix-profile/share:/usr/share/ubuntu:/usr/local/share:/usr/share:/var/lib/snapd/desktop:/usr/share"
So I think until Nix updates shared-mime-info to 2.4 I'll need to stay on shared-mime-info 2.3 in Arch packages.
Or until glib2 can handle cyclic references.
( 4/13) Updating the MIME type database...
Error in type 'application/x-core' (in /usr/share/mime/packages/freedesktop.org.xml): Error in <match> element: Mask is longer than value.
Error in type 'image/jp2' (in /usr/share/mime/packages/freedesktop.org.xml): Error in <match> element: Mask is longer than value.
Error in type 'image/jpx' (in /usr/share/mime/packages/freedesktop.org.xml): Error in <match> element: Mask is longer than value.
Error in type 'image/jpm' (in /usr/share/mime/packages/freedesktop.org.xml): Error in <match> element: Mask is longer than value.
Error in type 'video/mj2' (in /usr/share/mime/packages/freedesktop.org.xml): Error in <match> element: Mask is longer than value.
Error in type 'image/vnd.adobe.photoshop' (in /usr/share/mime/packages/freedesktop.org.xml): Error in <match> element: Mask is longer than value.
Edit: To make matters worse, it doesn't happen every time i.e. it's intermittent, there is some randomness involved.
@ojirio reported encountering the issue using dolphin which I believe does not use glib2 but does use qt5-base and a fix has been committed [1] at least for qt6-base.
[1]: https://code.qt.io/cgit/qt/qtbase.git/commit/?id=54656da9ace06caf4a0eeb1832989c0ab211a4a0
[1]: https://gitlab.gnome.org/GNOME/glib/-/commit/d9c50cac5d160798498e42d5b190ad89920a9a6a
[2]: https://gitlab.gnome.org/GNOME/glib/-/commit/77902e1b1c8ff906a560270656a51a28787b9492
[3]: https://gitlab.gnome.org/GNOME/glib/-/commit/e03abe74572618a58b7ac0d17c9480639e48f080
[4]: https://gitlab.gnome.org/GNOME/glib/-/commit/b382d059eec47567f693098d20bc5b936aa53704