gslice: disable by default under valgrind
authorRyan Lortie <desrt@desrt.ca>
Mon, 22 Apr 2013 16:28:44 +0000 (12:28 -0400)
committerRyan Lortie <desrt@desrt.ca>
Mon, 22 Apr 2013 20:15:31 +0000 (16:15 -0400)
commit00fbc2f0ce2fb65da1027485707fbac59b91a1ef
tree8dc30923d4bb2fe30b7f8778326fa773469aa14f
parentc8d56d7cf79b107d0e9a64812734fe877b332093
gslice: disable by default under valgrind

All experienced GLib hackers know that G_SLICE=always-malloc is
absolutely essential when valgrinding but many users of GLib don't know
about this and get hit pretty hard when valgrinding their programs.

When initialising gslice, add a check to see if we are running under
valgrind and disable ourselves if we are.

We only do the check in the case that G_SLICE= was not specified in the
environment, so setting it to an empty string will prevent this default
behaviour.

I considered modifying gslice to use the VALGRIND_MALLOCLIKE_BLOCK
client request in all cases in order to just mark the blocks properly
but these calls are not free and gslice is pretty hyper-optimised.  It's
easier to just disable gslice completely and this way we only have to do
one check during startup.  It's also theoretically possible that someone
might want to use valgrind to debug gslice, in which case the extra
annotations would probably cause quite a lot of difficulty.

https://bugzilla.gnome.org/show_bug.cgi?id=698595
glib/gslice.c