actually test malloc/free from InitLateMaybeRecursive

This days compilers ~always optimize out free(malloc(N)) to nothing.
This commit is contained in:
Aliaksey Kandratsenka 2023-06-21 10:38:03 -04:00
parent a80ce7b0e1
commit d9b14b9da1
2 changed files with 6 additions and 6 deletions

View File

@ -141,12 +141,6 @@ void Static::InitLateMaybeRecursive() {
CentralCacheUnlockAll, // parent calls after fork
CentralCacheUnlockAll); // child calls after fork
#endif
#ifndef NDEBUG
// pthread_atfork above may malloc sometimes. Lets ensure we test
// that malloc works from here.
free(malloc(1));
#endif
}
} // namespace tcmalloc

View File

@ -299,6 +299,12 @@ void ThreadCache::InitModule() {
// We do "late" part of initialization without holding lock since
// there is chance it'll recurse into malloc
Static::InitLateMaybeRecursive();
#ifndef NDEBUG
// pthread_atfork above may malloc sometimes. Lets ensure we test
// that malloc works from here.
(operator delete)((operator new)(1));
#endif
}
void ThreadCache::InitTSD() {