mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-06 19:38:41 +03:00
initial working guarded pages
This commit is contained in:
parent
7b5df14bea
commit
0c19eb60cf
12 changed files with 196 additions and 37 deletions
|
@ -11,6 +11,7 @@ static void double_free1();
|
|||
static void double_free2();
|
||||
static void corrupt_free();
|
||||
static void block_overflow1();
|
||||
static void block_overflow2();
|
||||
static void invalid_free();
|
||||
static void test_aslr(void);
|
||||
static void test_process_info(void);
|
||||
|
@ -28,6 +29,7 @@ int main() {
|
|||
// double_free2();
|
||||
// corrupt_free();
|
||||
// block_overflow1();
|
||||
block_overflow2();
|
||||
// test_aslr();
|
||||
// invalid_free();
|
||||
// test_reserved();
|
||||
|
@ -76,6 +78,12 @@ static void block_overflow1() {
|
|||
free(p);
|
||||
}
|
||||
|
||||
static void block_overflow2() {
|
||||
uint8_t* p = (uint8_t*)mi_malloc(16);
|
||||
p[17] = 0;
|
||||
free(p);
|
||||
}
|
||||
|
||||
// The double free samples come ArcHeap [1] by Insu Yun (issue #161)
|
||||
// [1]: https://arxiv.org/pdf/1903.00503.pdf
|
||||
|
||||
|
|
|
@ -65,6 +65,15 @@ bool mem_is_zero(uint8_t* p, size_t size) {
|
|||
int main(void) {
|
||||
mi_option_disable(mi_option_verbose);
|
||||
|
||||
CHECK_BODY("malloc-aligned9a") { // test large alignments
|
||||
void* p = mi_zalloc_aligned(1024 * 1024, 2);
|
||||
mi_free(p);
|
||||
p = mi_zalloc_aligned(1024 * 1024, 2);
|
||||
mi_free(p);
|
||||
result = true;
|
||||
};
|
||||
|
||||
|
||||
// ---------------------------------------------------
|
||||
// Malloc
|
||||
// ---------------------------------------------------
|
||||
|
@ -157,6 +166,7 @@ int main(void) {
|
|||
printf("malloc_aligned5: usable size: %zi\n", usable);
|
||||
mi_free(p);
|
||||
};
|
||||
/*
|
||||
CHECK_BODY("malloc-aligned6") {
|
||||
bool ok = true;
|
||||
for (size_t align = 1; align <= MI_BLOCK_ALIGNMENT_MAX && ok; align *= 2) {
|
||||
|
@ -174,6 +184,7 @@ int main(void) {
|
|||
}
|
||||
result = ok;
|
||||
};
|
||||
*/
|
||||
CHECK_BODY("malloc-aligned7") {
|
||||
void* p = mi_malloc_aligned(1024,MI_BLOCK_ALIGNMENT_MAX);
|
||||
mi_free(p);
|
||||
|
@ -189,7 +200,7 @@ int main(void) {
|
|||
}
|
||||
result = ok;
|
||||
};
|
||||
CHECK_BODY("malloc-aligned9") {
|
||||
CHECK_BODY("malloc-aligned9") { // test large alignments
|
||||
bool ok = true;
|
||||
void* p[8];
|
||||
size_t sizes[8] = { 8, 512, 1024 * 1024, MI_BLOCK_ALIGNMENT_MAX, MI_BLOCK_ALIGNMENT_MAX + 1, 2 * MI_BLOCK_ALIGNMENT_MAX, 8 * MI_BLOCK_ALIGNMENT_MAX, 0 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue