mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-07 03:48:42 +03:00
wip: initial work on tracking source of an allocation in debug mode
This commit is contained in:
parent
0a77b7423f
commit
4090561975
10 changed files with 381 additions and 164 deletions
|
@ -11,6 +11,7 @@ static void double_free1();
|
|||
static void double_free2();
|
||||
static void corrupt_free();
|
||||
static void block_overflow1();
|
||||
static void dangling_ptr_write();
|
||||
|
||||
int main() {
|
||||
mi_version();
|
||||
|
@ -20,6 +21,7 @@ int main() {
|
|||
// double_free2();
|
||||
// corrupt_free();
|
||||
// block_overflow1();
|
||||
dangling_ptr_write();
|
||||
|
||||
void* p1 = malloc(78);
|
||||
void* p2 = malloc(24);
|
||||
|
@ -49,6 +51,14 @@ static void block_overflow1() {
|
|||
free(p);
|
||||
}
|
||||
|
||||
static void dangling_ptr_write() {
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
uint8_t* p = (uint8_t*)mi_malloc(16);
|
||||
free(p);
|
||||
p[0] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// The double free samples come ArcHeap [1] by Insu Yun (issue #161)
|
||||
// [1]: https://arxiv.org/pdf/1903.00503.pdf
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue