Skip to content
  • Allison Karlitskaya's avatar
    gslice: disable by default under valgrind · 00fbc2f0
    Allison Karlitskaya authored
    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
    00fbc2f0