unbreak infinite loop under valgrind more robustly

See discussion in https://github.com/gperftools/gperftools/issues/1615

This change avoids the issue even if we're unable to detect valgrind
presence.
3 files changed