summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAliaksey Kandratsenka <alk@tut.by>2013-09-14 16:45:42 -0700
committerAliaksey Kandratsenka <alk@tut.by>2013-09-14 16:45:42 -0700
commitcb65e49b83c84bc205203c12793f2dd00c4a7721 (patch)
treea1438c61264cfb602ac86d31adf600eb58427018
parent6979583592df555a369a2c975f5117a1f61911af (diff)
downloadgperftools-cb65e49b83c84bc205203c12793f2dd00c4a7721.tar.gz
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.
-rw-r--r--src/tcmalloc.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/tcmalloc.cc b/src/tcmalloc.cc
index 857da14..ffd76be 100644
--- a/src/tcmalloc.cc
+++ b/src/tcmalloc.cc
@@ -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;