mirror of
https://github.com/gperftools/gperftools
synced 2025-02-17 20:56:53 +00:00
ensure that heap checker initialization actually calls malloc
I.e. all recent compilers (both gcc and clang) optimize out delete(new int) sequence to nothing. We call to tc_new and tc_delete directly to suppress this optimization.
This commit is contained in:
parent
b96dc99dbf
commit
1c3f0dda1b
@ -66,7 +66,12 @@ class HeapLeakCheckerGlobalPrePost {
|
|||||||
// MallocHook_InitAtFirstAllocation_HeapLeakChecker. See malloc_hook.cc.
|
// MallocHook_InitAtFirstAllocation_HeapLeakChecker. See malloc_hook.cc.
|
||||||
// This is done in this roundabout fashion in order to avoid self-deadlock
|
// This is done in this roundabout fashion in order to avoid self-deadlock
|
||||||
// if we directly called HeapLeakChecker_BeforeConstructors here.
|
// if we directly called HeapLeakChecker_BeforeConstructors here.
|
||||||
delete new int;
|
//
|
||||||
|
// We use explicit global operator new/delete functions since
|
||||||
|
// plain 'naked' delete new int modern compilers optimize out to
|
||||||
|
// nothing. And apparently calling those global new/delete
|
||||||
|
// functions is assumed by compilers to be 'for effect' as well.
|
||||||
|
(operator delete)((operator new)(4));
|
||||||
// This needs to be called before the first allocation of an STL
|
// This needs to be called before the first allocation of an STL
|
||||||
// object, but after libc is done setting up threads (because it
|
// object, but after libc is done setting up threads (because it
|
||||||
// calls setenv, which requires a thread-aware errno). By
|
// calls setenv, which requires a thread-aware errno). By
|
||||||
|
Loading…
Reference in New Issue
Block a user