This is an archive of the discontinued LLVM Phabricator instance.

[scudo] Minor changes and refactoring
ClosedPublic

Authored by cryptoad on Apr 19 2017, 1:45 PM.

Details

Summary

This is part of D31947 that is being split into several smaller changes.

This one deals with all the minor changes, more specifically:

  • Rename some variables and functions to make their purpose clearer;
  • Reorder some code;
  • Mark the hot termination incurring checks as UNLIKELY; if they happen, the program will die anyway;
  • Add a getScudoChunk method;
  • Add an eraseHeader method to ScudoChunk that will clear a header with 0s;
  • Add a parameter to allocate to know if the allocated chunk should be filled with zeros. This allows calloc to not have to call GetActuallyAllocatedSize; more changes to get rid of this function on the hot paths will follow;
  • reallocate was missing a check to verify that the pointer is properly aligned on MinAlignment;
  • The Stats in the secondary have to be protected by a mutex as the Add and Sub methods are actually not atomic;
  • The software CRC32 function was moved to the header to allow for inlining.

Event Timeline

cryptoad created this revision.Apr 19 2017, 1:45 PM
cryptoad updated this revision to Diff 95816.Apr 19 2017, 2:23 PM

Additional rename of a variable I forgot in the first round.

dvyukov accepted this revision.Apr 20 2017, 6:16 AM

LGTM with a nit

lib/scudo/scudo_allocator.cpp
363

StaticSpinMutex does not need initialization. If anything this can only do harm if the mutex turned out to be locked by somebody else at the moment.
Drop this.

This revision is now accepted and ready to land.Apr 20 2017, 6:16 AM
cryptoad updated this revision to Diff 95962.Apr 20 2017, 8:13 AM
cryptoad marked an inline comment as done.

Addressing review comments.

Thank you Dmitry.

cryptoad closed this revision.Apr 20 2017, 8:23 AM