This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] Use MADV_FREE on Darwin/BSD to release pages to the OS
ClosedPublic

Authored by kubamracek on Nov 30 2017, 12:06 PM.

Details

Summary

MADV_DONTNEED on Linux actually mark the pages as free to be overwritten with zeroes, but on Darwin and BSD, it's just an advisory flag (the OS cannot discard the content). We should use MADV_FREE on Darwin and BSD.

Diff Detail

Repository
rL LLVM

Event Timeline

kubamracek created this revision.Nov 30 2017, 12:06 PM
Herald added subscribers: Restricted Project, krytarowski, emaste. · View Herald TranscriptNov 30 2017, 12:06 PM
dvyukov accepted this revision.Nov 30 2017, 12:08 PM
This revision is now accepted and ready to land.Nov 30 2017, 12:08 PM
krytarowski added inline comments.Nov 30 2017, 12:10 PM
lib/sanitizer_common/sanitizer_posix_libcdep.cc
65 ↗(On Diff #124986)

Please include SANITIZER_NETBSD too (and in the description).

kcc edited edge metadata.Nov 30 2017, 1:42 PM

Will this even build on Linux?
I don't see MADV_FREE in /usr/include

Maybe define SANITIZER_MADVISE_DONTNEED in lib/sanitizer_common/sanitizer_platform.h?

kubamracek edited the summary of this revision. (Show Details)
kcc accepted this revision.Nov 30 2017, 2:55 PM

LGTM.

This revision was automatically updated to reflect the committed changes.