[dpdk-dev] [PATCH] eal: add madvise to avoid dump memory
Burakov, Anatoly
anatoly.burakov at intel.com
Thu Apr 23 14:22:42 CEST 2020
On 23-Apr-20 7:36 AM, Feng Li wrote:
> Hi,
> I have tested as follows, the core dump file is ~ 200KB.
> It should generate one core dump file each crash.
>
> #include <sys/mman.h>
> #include <time.h>
> #include <stdint.h>
> #include <unistd.h>
> #include <stdlib.h>
> #include <stdio.h>
>
> int main(int argc, char** argv) {
> // FIXME(fengli): XXXXX
> uint64_t size = 1<<30;
> void* ptr = mmap(0, size , PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
> if (ptr == (void*)-1) {
> perror("[-] mmap failed with MAP_PRIVATE | MAP_ANONYMOUS");
> exit(1);
> }
> if (madvise(ptr, size , MADV_DONTDUMP) != 0)
> perror("[-] madvise failed");
> while(1)
> sleep(1);
> return 0;
> }
>
That's odd, your code works. Mine, even though it did the same thing,
didn't work the same way. My compiler must like you more than it likes
me :) (or perhaps i had a typo...)
Anyway, i can see that this indeed prevents core dumps on madvise'd
memory (i've also tested it with PROT_NONE).
I'll go ahead and ack the original patch then.
--
Thanks,
Anatoly
More information about the dev
mailing list