Closed kungf closed 1 year ago
fix. Maybe there are unused bytes remaining, inspired by:
//tcmalloc/testing/memory_errors_test.cc
// Eat up unsampled bytes remaining to flush the new sample rates.
while (true) {
void *p = ::operator new(kPageSize);
if (tcmalloc::Static::guardedpage_allocator()->PointerIsMine(p)) {
::operator delete(p);
break;
}
::operator delete(p);
}
fix test code :
#include <iostream>
#include "tcmalloc/malloc_extension.h"
int main() {
tcmalloc::MallocExtension::SetProfileSamplingRate(1);
tcmalloc::MallocExtension::SetGuardedSamplingRate(0);
tcmalloc::MallocExtension::ActivateGuardedSampling();
for (int i = 0; i < 100000; i++ ){
void *p = ::operator new(128);
::operator delete(p);
}
int64_t *cs = new int64_t[10];
delete[] cs;
cs[11] = 11;
return 0;
}
I writed an example, memory used after free, but gwp-asan didn't show any error trace, the program works fine. This is the code:
This is the BUILD: