Page MenuHomePhabricator

Refactor `AsanChunk` methods into code that supports both in-process and out-of-process examination of `AsanChunk`s.
Needs RevisionPublic

Authored by delcypher on Jan 19 2019, 3:51 PM.



This refactors the implementations of the Beg(), UsedSize() and
AllocBeg() methods. We do not modify AddrIsInside() because
future patches do not need to use that method in an out-of-process context.

The common code is private and has the Internal suffix. Future
patches will use these new methods in an out-of-process context.

The UsedSizeInternal(...) method takes a new argument
(known_alloc_beg) which allows access to be optimized if the
result of AllocBegInternal() is already known. We will use this
in future patches.

We do not template the AsanChunk type with AddressSpaceView like we did
for the allocators (in previous patches) because it is not possible to
modify the existing methods and preserve the method parameters in
the out-of-process context because we need additional information that the
caller needs to provide. In particular:

  • We need both the address of the copy of the AsanChunk in the local process and its address in the remote process. In the in-process context the this pointer provides both bits of information but this isn't the case in the out-of-process context.
  • We need the address to the ASan allocator in the local process instantiated with the correct AddressSpaceView template. In the in-process context this is just &get_allocator() but in the out-of-process context only the caller knows the address of the copy of the ASan allocator that is instantiated with RemoteAddressSpaceView.

Given the above restrictions this patch refactors the methods into new
methods that take the additional parameters and then modifies the
original methods to provide these additional parameters.

This maximizes code re-use between the in-process and out-of-process use
cases and minimizes the changes required (i.e. none) to existing clients
of AsanChunk.