GNOME Bugzilla – Bug 740317
GSlice is not valgrind-friendly even when going through system malloc
Last modified: 2014-11-18 15:32:52 UTC
Created attachment 290910 [details] The output of the execution with valgrind without G_SLICE Undefined variable (same as G_SLICE set to always-malloc) The simply program can be used to reproduce the problem. /* The program creates a hash table and than destroy it */ #include <stdio.h> #include <stdlib.h> /* GLIB - Library of useful routines for C programming - v. 2.43.0 - Oct 2014 */ #include "glib.h" int main (int argc, char * argv []) { GHashTable * ht; char * g_slice = getenv ("G_SLICE"); printf ("This program creates a hash table and then destroy it\n"); if (g_slice) printf ("The [G_SLICE] environment variable is set to %s\n", g_slice); else printf ("The [G_SLICE] environment variable is not set\n"); /* Create a hash table */ ht = g_hash_table_new (NULL, NULL); /* Destroy the hash table */ g_hash_table_destroy (ht); return 0; }
this is a one-off allocation in thread-local storage. it needs to be performed to initialize the GSlice allocator, so it has to come before the check on the configuration to see if the allocation should go through the system malloc or not. since it's a one-off, it's not a leak — even if it's not overly valgrind-friendly.
re-titling for clarity.
we've already got one of those *** This bug has been marked as a duplicate of bug 627423 ***