wip: initial work on tracking source of an allocation in debug mode

This commit is contained in:
daan 2020-02-11 09:37:26 -08:00
parent 0a77b7423f
commit 4090561975
10 changed files with 381 additions and 164 deletions

View file

@ -23,10 +23,12 @@ public:
~Test() { }
};
void dangling_ptr_write();
int main() {
mi_stats_reset(); // ignore earlier allocations
atexit(free_p);
dangling_ptr_write();
void* p1 = malloc(78);
void* p2 = mi_malloc_aligned(16,24);
free(p1);
@ -53,6 +55,14 @@ int main() {
return 0;
}
static void dangling_ptr_write() {
for (int i = 0; i < 1000; i++) {
uint8_t* p = new uint8_t[16];
free(p);
p[0] = 0;
}
}
class Static {
private:
void* p;