After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 691077 - gio-querymodules crashes with SIGSEGV
gio-querymodules crashes with SIGSEGV
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
2.35.x
Other Linux
: Normal major
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-01-03 15:51 UTC by jobol
Modified: 2013-01-11 09:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
a patch (623 bytes, patch)
2013-01-03 15:51 UTC, jobol
none Details | Review
0001-gio-querymodules-Ensure-we-re-linked-to-GObject.patch (902 bytes, patch)
2013-01-10 21:28 UTC, Colin Walters
accepted-commit_now Details | Review

Description jobol 2013-01-03 15:51:18 UTC
Created attachment 232648 [details] [review]
a patch

When running gio-querymodules-64 a SIGSEGV may be raised and a core file generated.
It happens:
when running spec macro %glib2_gio_module_post (in MIC image creation, or rpm installation)
when there is more than one library in directory /usr/lib64/gio/modules (one is not enough)
Investigation shows that it comes from re-initialisation of libgobject.so (constructor function) from a dynamic library. It tries to access symbols previously defined but invalidated because the previous dynamic library that recorded it was unloaded.

Reverting the commit http://git.gnome.org/browse/glib/commit/gio/gio-querymodules.c?id=1dc774a653e992e1153fbed16f90097fa8db467f solves the problem (see patch). But maybe is there an upstream "2.38" way of doing it since g_type_init is now deprecated.
Comment 1 jobol 2013-01-04 08:21:40 UTC
The proposed patch is a hack.

What is the real problem? It is that gobject and plugins don't unregister them when their dynamic library is swept out of memory.

Is their a plan to solve it ?
Comment 2 Emmanuele Bassi (:ebassi) 2013-01-04 09:08:43 UTC
(In reply to comment #1)

calling g_type_init() multiple times within the same process space is perfectly legal, so I doubt reverting that commit is actually solving anything.

> What is the real problem? It is that gobject and plugins don't unregister them
> when their dynamic library is swept out of memory.

if the plugin loads GObject and then tries to unload it, then it's always going to fail: GObject registers a lot of static types (i.e. type data that is not meant to be unloaded), so it has never been safe to unload it and then re-load it.

> Is their a plan to solve it ?

yes, the proposed plan is to disallow unloading GType modules altogether.
Comment 3 jobol 2013-01-04 09:20:39 UTC
(In reply to comment #2)
> (In reply to comment #1)
> 
> calling g_type_init() multiple times within the same process space is perfectly
> legal, so I doubt reverting that commit is actually solving anything.

In fact, it solves the problem.

> > What is the real problem? It is that gobject and plugins don't unregister them
> > when their dynamic library is swept out of memory.
> 
> if the plugin loads GObject and then tries to unload it, then it's always going
> to fail: GObject registers a lot of static types (i.e. type data that is not
> meant to be unloaded), so it has never been safe to unload it and then re-load
> it.

Oh yeah. BTW, to be clearly understood, libgobject is loaded and unloaded automatically by plugins libraries of /usr/lib64/gio/modules.

> > Is their a plan to solve it ?
> 
> yes, the proposed plan is to disallow unloading GType modules altogether.

What a poor plan! But a good plan because it solves the problem. Then the solution is to remove line 97 of gio-querymodules: the line of 'g_module_close (module);'
Comment 4 Emmanuele Bassi (:ebassi) 2013-01-04 10:05:22 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > (In reply to comment #1)
> > 
> > calling g_type_init() multiple times within the same process space is perfectly
> > legal, so I doubt reverting that commit is actually solving anything.
> 
> In fact, it solves the problem.

it would be nice if you looked into *why* it seems to solve the issue.

just closing the GModule should not do anything to the types registered by the GIO plugins - unless a plugin is trying to unload its own types.

> > > What is the real problem? It is that gobject and plugins don't unregister them
> > > when their dynamic library is swept out of memory.
> > 
> > if the plugin loads GObject and then tries to unload it, then it's always going
> > to fail: GObject registers a lot of static types (i.e. type data that is not
> > meant to be unloaded), so it has never been safe to unload it and then re-load
> > it.
> 
> Oh yeah. BTW, to be clearly understood, libgobject is loaded and unloaded
> automatically by plugins libraries of /usr/lib64/gio/modules.

which libraries are these? can you pinpoint the actual plugin that causes this issue?

> > > Is their a plan to solve it ?
> > 
> > yes, the proposed plan is to disallow unloading GType modules altogether.
> 
> What a poor plan!

not really: unloading types never really worked, and it cannot be compatibly fixed. all in all, it's the least disruptive option.
Comment 5 jobol 2013-01-04 10:30:15 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > (In reply to comment #2)
> > > (In reply to comment #1)
> > > 
> > > calling g_type_init() multiple times within the same process space is perfectly
> > > legal, so I doubt reverting that commit is actually solving anything.
> > 
> > In fact, it solves the problem.
> 
> it would be nice if you looked into *why* it seems to solve the issue.

It solves because gio-querymodules now creates the static types
and keeps it available to the loaded plugins modules.
More: it wasn't linked to libgobject-2.0 before and
now it is (see "ldd /usr/bin/gio-querymodules-64" output)

Before the patch

load gio-querymodules -> auto dlopen libglib-2.0
 load module 1 -> auto dlopen libgobject-2.0 -> auto constructor gobject
 close module 1 -> auto dlclose libgobject-2.0
 load module 2 -> auto dlopen libgobject-2.0, auto constructor gobject CRASH

After the patch

load gio-querymodules -> auto dlopen libglib-2.0, auto dlopen libgobject-2.0, auto constructor gobject
 load module 1 -> nothing to do because already done (see man dlopen)
 close module 1
 load module 2 -> nothing to do because already done (see man dlopen)
 ...

> just closing the GModule should not do anything to the types registered by the
> GIO plugins - unless a plugin is trying to unload its own types.
> 
> > > > What is the real problem? It is that gobject and plugins don't unregister them
> > > > when their dynamic library is swept out of memory.
> > > 
> > > if the plugin loads GObject and then tries to unload it, then it's always going
> > > to fail: GObject registers a lot of static types (i.e. type data that is not
> > > meant to be unloaded), so it has never been safe to unload it and then re-load
> > > it.
> > 
> > Oh yeah. BTW, to be clearly understood, libgobject is loaded and unloaded
> > automatically by plugins libraries of /usr/lib64/gio/modules.
> 
> which libraries are these? can you pinpoint the actual plugin that causes this
> issue?

$ ls /usr/lib64/gio/modules  
giomodule.cache      
libgiognutls.so		     
libgsettingsgconfbackend.so
libdconfsettings.so  
libgioremote-volume-monitor.so  
libgvfsdbus.so

> 
> > > > Is their a plan to solve it ?
> > > 
> > > yes, the proposed plan is to disallow unloading GType modules altogether.
> > 
> > What a poor plan!
> 
> not really: unloading types never really worked, and it cannot be compatibly
> fixed. all in all, it's the least disruptive option.
Comment 6 Matthias Clasen 2013-01-04 12:36:11 UTC
(In reply to comment #5)

> > 
> > it would be nice if you looked into *why* it seems to solve the issue.
> 
> It solves because gio-querymodules now creates the static types
> and keeps it available to the loaded plugins modules.
> More: it wasn't linked to libgobject-2.0 before and
> now it is (see "ldd /usr/bin/gio-querymodules-64" output)

Bingo. Thats the real issue, I'd say.
Comment 7 jobol 2013-01-07 11:42:51 UTC
Then who confirms that bug?
Comment 8 Colin Walters 2013-01-10 21:28:28 UTC
Created attachment 233182 [details] [review]
0001-gio-querymodules-Ensure-we-re-linked-to-GObject.patch

g_type_init() is deprecated, we should use g_type_ensure() instead.
Comment 9 Matthias Clasen 2013-01-11 01:15:07 UTC
Review of attachment 233182 [details] [review]:

looks fine
Comment 10 Dominique Leuenberger 2013-01-11 09:20:07 UTC
I tested this patch on my build platform (openSUSE Build Service) and can confirm that my gio-querymodules crash is gone with this as well.