User Tools

Site Tools


proc:core_dump_filter

Proc - Core Dump Filter

When a process is dumped, all anonymous memory is written to a core file as long as the size of the core file isn't limited. But sometimes we don't want to dump some memory segments, for example, huge shared memory. Conversely, sometimes we want to save file-backed memory segments into a core file, not only the individual files.

/proc/<pid>/coredump_filter allows you to customize which memory segments will be dumped when the <pid> process is dumped. coredump_filter is a bitmask of memory types. If a bit of the bitmask is set, memory segments of the corresponding memory type are dumped, otherwise they are not dumped.

The following 7 memory types are supported:

  • (bit 0) anonymous private memory.
  • (bit 1) anonymous shared memory.
  • (bit 2) file-backed private memory.
  • (bit 3) file-backed shared memory.
  • (bit 4) ELF header pages in file-backed private memory areas (it is effective only if the bit 2 is cleared).
  • (bit 5) hugetlb private memory.
  • (bit 6) hugetlb shared memory.

NOTE: MMIO pages such as frame buffer are never dumped and vDSO pages are always dumped regardless of the bitmask status.

Bits 0-4 doesn't effect any hugetlb memory. hugetlb memory are only effected by bit 5-6.

Default value of coredump_filter is 0x23; this means all anonymous memory segments and hugetlb private memory are dumped.

If you don't want to dump all shared memory segments attached to pid 1234, write 0x21 to the process's proc file.

echo 0x21 > /proc/1234/coredump_filter

When a new process is created, the process inherits the bitmask status from its parent. It is useful to set up coredump_filter before the program runs.

For example:

echo 0x7 > /proc/self/coredump_filter
./some_program
proc/core_dump_filter.txt · Last modified: 2020/07/15 09:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki