This is an archive of the discontinued LLVM Phabricator instance.

[Sanitizers] Operator new() interceptors always die on allocation error
ClosedPublic

Authored by alekseyshl on Jun 27 2017, 6:07 PM.

Details

Summary

Operator new interceptors behavior is now controlled by their nothrow
property as well as by allocator_may_return_null flag value:

  • allocator_may_return_null=* + new() - die on allocation error
  • allocator_may_return_null=0 + new(nothrow) - die on allocation error
  • allocator_may_return_null=1 + new(nothrow) - return null

Ideally new() should throw std::bad_alloc exception, but that is not
trivial to achieve, hence TODO.

Event Timeline

alekseyshl created this revision.Jun 27 2017, 6:07 PM
cryptoad added inline comments.Jun 27 2017, 10:40 PM
lib/scudo/scudo_new_delete.cpp
33

Thanks for doing those changes on Scudo as well.
Would it possible to get mark the failure branches as UNLIKELY? (at least the ones in Scudo).

  • Add UNLIKELY around OOM checks and add NORETURN to DieOnFailure methods.
alekseyshl marked an inline comment as done.Jun 28 2017, 12:12 PM
eugenis accepted this revision.Jun 28 2017, 2:41 PM
This revision is now accepted and ready to land.Jun 28 2017, 2:41 PM
This revision was automatically updated to reflect the committed changes.