issue-536: do not PrintStats if running under valgrind

When we detect running under valgrind we do not initialize our own
malloc. So trying to print malloc stats when asked via MALLOCSTATS
cannot work.

This does fix proposed by Philippe Waroquiers. In which we detect
running under valgrind prior to checking MALLOCSTATS environment
variable and refuse printing stats if we detect valgrind.
This commit is contained in:
Aliaksey Kandratsenka 2013-09-14 16:45:42 -07:00
parent 6979583592
commit cb65e49b83

View File

@ -926,7 +926,11 @@ TCMallocGuard::TCMallocGuard() {
TCMallocGuard::~TCMallocGuard() {
if (--tcmallocguard_refcount == 0) {
const char* env = getenv("MALLOCSTATS");
const char* env = NULL;
if (!RunningOnValgrind()) {
// Valgrind uses it's own malloc so we cannot do MALLOCSTATS
env = getenv("MALLOCSTATS");
}
if (env != NULL) {
int level = atoi(env);
if (level < 1) level = 1;