12 volatile sig_atomic_t signaled
= 0;
17 if (munmap(address
, kMmapSize
) != 0)
23 void* newaddr
= mmap(address
, kMmapSize
, PROT_READ
| PROT_WRITE
,
24 MAP_ANON
| MAP_FIXED
| MAP_PRIVATE
, -1, 0);
25 if (newaddr
!= address
)
27 fprintf(stderr
, "Newly mmaped address (%p) does not equal old address (%p).\n",
31 *(int*)newaddr
= kMagicValue
;
36 if (signal(SIGSEGV
, handler
) == SIG_ERR
)
42 address
= mmap(NULL
, kMmapSize
, PROT_NONE
, MAP_ANON
| MAP_PRIVATE
, -1, 0);
43 if (address
== MAP_FAILED
)
49 // This should first trigger a segfault. Our handler will make the memory readable and write
50 // the magic value into memory.
51 if (*(int*)address
!= kMagicValue
)