This is an archive of the discontinued LLVM Phabricator instance.

sanitizers: consistently check result of MmapFixedNoReserve
ClosedPublic

Authored by dvyukov on Jul 16 2018, 2:56 AM.

Details

Summary

MmapFixedNoReserve does not terminate process on failure.
Failure to check its result and die will always lead to harder
to debug crashes later in execution. This was observed in Go
processes due to some address space conflicts.

Consistently check result of MmapFixedNoReserve.
While we are here also add warn_unused_result attribute
to prevent such bugs in future and change return type to bool
as that's what all callers want.

Diff Detail

Event Timeline

dvyukov created this revision.Jul 16 2018, 2:56 AM
alekseyshl accepted this revision.Jul 16 2018, 9:56 AM
alekseyshl added inline comments.
lib/sanitizer_common/sanitizer_common.h
92

It might be beneficial to add MmapFixedNoReserveOrDie to match other functions in this header and simplify many call sites.

This revision is now accepted and ready to land.Jul 16 2018, 9:56 AM
dvyukov added inline comments.Jul 20 2018, 1:40 AM
lib/sanitizer_common/sanitizer_common.h
92

I've considered this but can't make my mind. We still need both versions and half of call sites don't just Die. So I've done what looks like a strict win and most importantly prevents bugs.

dvyukov closed this revision.Jul 20 2018, 1:40 AM

Submitted in 337531