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 751592 - Stop using GMemVtable
Stop using GMemVtable
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2015-06-27 16:38 UTC by Alexander Larsson
Modified: 2015-07-28 04:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Deprecate and drop support for memory vtables (15.34 KB, patch)
2015-06-27 16:40 UTC, Alexander Larsson
committed Details | Review

Description Alexander Larsson 2015-06-27 16:38:33 UTC
The memory vtable doesn't work anymore as there is no way to call g_set_mem_vtable() before g_malloc & co is used (because the glib/gobject global constructors call these before main). Therefore we should stop paying the price of constantly calling malloc via a vfunc and just remove all the vtable support code.
Comment 1 Alexander Larsson 2015-06-27 16:40:31 UTC
Created attachment 306206 [details] [review]
Deprecate and drop support for memory vtables

The memory vtables no longer work, because glib contructors are called
before main(), so there is no way to set it them before use. This stops using
the vtable at all, and deprecates and stubs out the related functions.
Comment 2 Alexander Larsson 2015-06-27 16:43:41 UTC
See also bug 701694
Comment 3 Colin Walters 2015-06-28 21:26:26 UTC
While I mostly support this, I think the assertion is only true for gobject and above.  The libglib.so ctor appears to only parse environment variables and doesn't malloc.

I had been thinking before of allowing applications to
#define GLIB_NO_G_MALLOC
which if set, causes #define g_malloc malloc and so on.

(In practice I assume this in my apps anyways)

But that wouldn't address the indirection inside libg{lib,object,io}.so nor any dependencies.
Comment 4 Colin Walters 2015-06-28 21:29:57 UTC
Also worth noting that e.g. Firefox has been going the other way for https://developer.mozilla.org/en-US/docs/Mozilla/Performance/Memory_reporting
and trying to get statistics at runtime for every allocator type, which relies on library-defined interception.
Comment 5 Matthias Clasen 2015-07-26 19:38:14 UTC
I'm also in favor of dropping the non-longer working vtable stuff, and instead document g_malloc as always using malloc, and recommend people use libc's profiling support.
Comment 6 Matthias Clasen 2015-07-28 04:05:34 UTC
Attachment 306206 [details] pushed as 3be6ed6 - Deprecate and drop support for memory vtables