gobject related crash in vlc-cache-gen
vlc 2.2.0-pre2 failed to build on Debian's mips build machine because of a crash in vlc-cache-gen. We have also got [https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=752544 #752544] for 2.1.4 with a similar crash. This crash appears to happen at random and after some builds I was able to reproduce it. I got the following traceback:
[#0](https://code.videolan.org/videolan/vlc/-/issues/0) __strcmp_ssse3 () at ../sysdeps/x86_64/multiarch/../strcmp.S:209
[#1](https://code.videolan.org/videolan/vlc/-/issues/1) 0x00007ff698fc0949 in g_str_equal (v1=<optimized out>, v2=<optimized out>) at /build/glib2.0-Rdz7wU/glib2.0-2.40.0/./glib/ghash.c:1776
[#2](https://code.videolan.org/videolan/vlc/-/issues/2) 0x00007ff698fbff29 in g_hash_table_lookup_node (hash_return=<synthetic pointer>, key=0x7ff6916ade2c, hash_table=0x1b32800)
at /build/glib2.0-Rdz7wU/glib2.0-2.40.0/./glib/ghash.c:389
[#3](https://code.videolan.org/videolan/vlc/-/issues/3) g_hash_table_lookup (hash_table=0x1b32800, key=key@entry=0x7ff6916ade2c) at /build/glib2.0-Rdz7wU/glib2.0-2.40.0/./glib/ghash.c:1092
[#4](https://code.videolan.org/videolan/vlc/-/issues/4) 0x00007ff698fe0dc4 in quark_from_string (duplicate=0, string=0x7ff6916ade2c "-g-type-private--GTypeFlags")
at /build/glib2.0-Rdz7wU/glib2.0-2.40.0/./glib/gquark.c:173
[#5](https://code.videolan.org/videolan/vlc/-/issues/5) g_quark_from_static_string (string=string@entry=0x7ff6916ade2c "-g-type-private--GTypeFlags") at /build/glib2.0-Rdz7wU/glib2.0-2.40.0/./glib/gquark.c:237
[#6](https://code.videolan.org/videolan/vlc/-/issues/6) 0x00007ff6916764cc in gobject_init_ctor () at /build/glib2.0-Rdz7wU/glib2.0-2.40.0/./gobject/gtype.c:4336
[#7](https://code.videolan.org/videolan/vlc/-/issues/7) 0x00007ff69b3149fa in call_init (l=<optimized out>, argc=argc@entry=2, argv=argv@entry=0x7fff3da168b8, env=env@entry=0x1a05010) at dl-init.c:78
[#8](https://code.videolan.org/videolan/vlc/-/issues/8) 0x00007ff69b314ae3 in call_init (env=0x1a05010, argv=0x7fff3da168b8, argc=2, l=<optimized out>) at dl-init.c:36
[#9](https://code.videolan.org/videolan/vlc/-/issues/9) _dl_init (main_map=main_map@entry=0x1b23740, argc=2, argv=0x7fff3da168b8, env=0x1a05010) at dl-init.c:126
[#10](https://code.videolan.org/videolan/vlc/-/issues/10) 0x00007ff69b318c48 in dl_open_worker (a=a@entry=0x7fff3da15e58) at dl-open.c:577
[#11](https://code.videolan.org/videolan/vlc/-/issues/11) 0x00007ff69b3148b4 in _dl_catch_error (objname=objname@entry=0x7fff3da15e48, errstring=errstring@entry=0x7fff3da15e50,·
mallocedp=mallocedp@entry=0x7fff3da15e47, operate=operate@entry=0x7ff69b318970 <dl_open_worker>, args=args@entry=0x7fff3da15e58) at dl-error.c:187
[#12](https://code.videolan.org/videolan/vlc/-/issues/12) 0x00007ff69b31843b in _dl_open (file=0x1b1eda0 "../modules/gui/qt4/.libs/libqt4_plugin.so", mode=-2147483647, caller_dlopen=<optimized out>, nsid=-2,·
argc=2, argv=0x7fff3da168b8, env=0x1a05010) at dl-open.c:661
[#13](https://code.videolan.org/videolan/vlc/-/issues/13) 0x00007ff699ef302b in dlopen_doit (a=a@entry=0x7fff3da16070) at dlopen.c:66
[#14](https://code.videolan.org/videolan/vlc/-/issues/14) 0x00007ff69b3148b4 in _dl_catch_error (objname=0x1a1a150, errstring=0x1a1a158, mallocedp=0x1a1a148, operate=0x7ff699ef2fd0 <dlopen_doit>,·
args=0x7fff3da16070) at dl-error.c:187
[#15](https://code.videolan.org/videolan/vlc/-/issues/15) 0x00007ff699ef35dd in _dlerror_run (operate=operate@entry=0x7ff699ef2fd0 <dlopen_doit>, args=args@entry=0x7fff3da16070) at dlerror.c:163
[#16](https://code.videolan.org/videolan/vlc/-/issues/16) 0x00007ff699ef30c1 in __dlopen (file=file@entry=0x1b1eda0 "../modules/gui/qt4/.libs/libqt4_plugin.so", mode=mode@entry=1) at dlopen.c:87
[#17](https://code.videolan.org/videolan/vlc/-/issues/17) 0x00007ff69aae897f in module_Load (p_this=p_this@entry=0x1a05328, path=path@entry=0x1b1eda0 "../modules/gui/qt4/.libs/libqt4_plugin.so",·
p_handle=p_handle@entry=0x7fff3da160c0, lazy=lazy@entry=true) at posix/plugin.c:60
[#18](https://code.videolan.org/videolan/vlc/-/issues/18) 0x00007ff69aad065b in module_InitDynamic (obj=0x1a05328, path=path@entry=0x1b1eda0 "../modules/gui/qt4/.libs/libqt4_plugin.so", fast=fast@entry=true)
at modules/bank.c:583
[#19](https://code.videolan.org/videolan/vlc/-/issues/19) 0x00007ff69aad0988 in AllocatePluginFile (st=0x7fff3da16130, relpath=<optimized out>, abspath=0x1b1eda0 "../modules/gui/qt4/.libs/libqt4_plugin.so",·
bank=0x7fff3da16580) at modules/bank.c:526
[#20](https://code.videolan.org/videolan/vlc/-/issues/20) AllocatePluginDir (bank=bank@entry=0x7fff3da16580, maxdepth=1, maxdepth@entry=2, absdir=<optimized out>, reldir=0x1b272c0 "gui/qt4/.libs")
at modules/bank.c:488
[#21](https://code.videolan.org/videolan/vlc/-/issues/21) 0x00007ff69aad08e4 in AllocatePluginDir (bank=bank@entry=0x7fff3da16580, maxdepth=2, maxdepth@entry=3, absdir=<optimized out>, reldir=0x1b23590 "gui/qt4")
at modules/bank.c:492
[#22](https://code.videolan.org/videolan/vlc/-/issues/22) 0x00007ff69aad08e4 in AllocatePluginDir (bank=bank@entry=0x7fff3da16580, maxdepth=3, maxdepth@entry=4, absdir=<optimized out>, reldir=0x1a82a50 "gui")
at modules/bank.c:492
[#23](https://code.videolan.org/videolan/vlc/-/issues/23) 0x00007ff69aad08e4 in AllocatePluginDir (bank=bank@entry=0x7fff3da16580, maxdepth=4, maxdepth@entry=5, absdir=absdir@entry=0x1a1a1e0 "../modules",·
reldir=reldir@entry=0x0) at modules/bank.c:492
[#24](https://code.videolan.org/videolan/vlc/-/issues/24) 0x00007ff69aad0e64 in AllocatePluginPath (p_this=p_this@entry=0x1a05328, path=0x1a1a1e0 "../modules", mode=mode@entry=CACHE_USE) at modules/bank.c:401
[#25](https://code.videolan.org/videolan/vlc/-/issues/25) 0x00007ff69aad14d3 in AllocateAllPlugins (p_this=0x1a05328) at modules/bank.c:346
[#26](https://code.videolan.org/videolan/vlc/-/issues/26) module_LoadPlugins (obj=0x1a05328) at modules/bank.c:184
[#27](https://code.videolan.org/videolan/vlc/-/issues/27) 0x00007ff69aa660ed in libvlc_InternalInit (p_libvlc=0x1a05328, i_argc=-1855267284, i_argc@entry=3, ppsz_argv=0x7fff3da166f0) at libvlc.c:151
[#28](https://code.videolan.org/videolan/vlc/-/issues/28) 0x00007ff69b0efbcb in libvlc_new (argc=2, argv=<optimized out>) at core.c:59
[#29](https://code.videolan.org/videolan/vlc/-/issues/29) 0x0000000000400976 in fprintf (__fmt=0x400c55 "-pre2", __stream=<optimized out>) at /usr/include/x86_64-linux-gnu/bits/stdio2.h:97
[#30](https://code.videolan.org/videolan/vlc/-/issues/30) main (argc=2, argv=<optimized out>) at cachegen.c:103
This crash seems to be related to loading gobject after it has already been unloaded once. Making sure that gobject stays around seems to fix this issue. The attached patch implements this by linking vlc-cache-gen against gobject. Another approach would be to preload gobject with LD_PRELOAD.
It would be great to get this fixed in vlc so we don't have to carry around a patch.