Disable tcache by default if running inside Valgrind.

Disable tcache by default if running inside Valgrind, in order to avoid
making unallocated objects appear reachable to Valgrind.
This commit is contained in:
Jason Evans 2012-05-15 23:31:53 -07:00
parent 781fe75e0a
commit 174b70efb4
3 changed files with 8 additions and 1 deletions

View File

@ -12,6 +12,10 @@ found in the git revision history:
- Auto-detect whether running inside Valgrind, thus removing the need to - Auto-detect whether running inside Valgrind, thus removing the need to
manually specify MALLOC_CONF=valgrind:true. manually specify MALLOC_CONF=valgrind:true.
Incompatible changes:
- Disable tcache by default if running inside Valgrind, in order to avoid
making unallocated objects appear reachable to Valgrind.
Bug fixes: Bug fixes:
- Fix heap profiling crash if sampled object is freed via realloc(p, 0). - Fix heap profiling crash if sampled object is freed via realloc(p, 0).

View File

@ -969,7 +969,8 @@ malloc_conf = "xmalloc:true";]]></programlisting>
<link <link
linkend="opt.lg_tcache_max"><mallctl>opt.lg_tcache_max</mallctl></link> linkend="opt.lg_tcache_max"><mallctl>opt.lg_tcache_max</mallctl></link>
option for related tuning information. This option is enabled by option for related tuning information. This option is enabled by
default.</para></listitem> default unless running inside <ulink
url="http://valgrind.org/">Valgrind</ulink>.</para></listitem>
</varlistentry> </varlistentry>
<varlistentry id="opt.lg_tcache_max"> <varlistentry id="opt.lg_tcache_max">

View File

@ -389,6 +389,8 @@ malloc_conf_init(void)
opt_quarantine = JEMALLOC_VALGRIND_QUARANTINE_DEFAULT; opt_quarantine = JEMALLOC_VALGRIND_QUARANTINE_DEFAULT;
opt_redzone = true; opt_redzone = true;
} }
if (config_tcache && opt_valgrind)
opt_tcache = false;
} }
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {