Skip to content

Commit

Permalink
added missing MADV_DONTDUMP calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
mangod9 committed Oct 19, 2022
1 parent a585fc3 commit 4c53ff8
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/coreclr/gc/unix/gcenv.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,11 @@ static void* VirtualReserveInner(size_t size, size_t alignment, uint32_t flags,
pRetVal = pAlignedRetVal;
}

#ifdef MADV_DONTDUMP
// Do not include reserved memory in coredump.
madvise(pRetVal, size, MADV_DONTDUMP);
#endif

return pRetVal;
}

Expand Down Expand Up @@ -765,7 +770,14 @@ bool GCToOSInterface::VirtualDecommit(void* address, size_t size)
// that much more clear to the operating system that we no
// longer need these pages. Also, GC depends on re-committed pages to
// be zeroed-out.
return mmap(address, size, PROT_NONE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0) != NULL;
void* bRetVal = mmap(address, size, PROT_NONE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0);

#ifdef MADV_DONTDUMP
// Do not include freed memory in coredump.
madvise(address, size, MADV_DONTDUMP);
#endif

return (bRetVal != NULL);
}

// Reset virtual memory range. Indicates that data in the memory range specified by address and size is no
Expand Down Expand Up @@ -796,6 +808,11 @@ bool GCToOSInterface::VirtualReset(void * address, size_t size, bool unlock)
#endif
}

#ifdef MADV_DONTDUMP
// Do not include reset memory in coredump.
madvise(address, size, MADV_DONTDUMP);
#endif

return (st == 0);
}

Expand Down

0 comments on commit 4c53ff8

Please sign in to comment.