[PATCH] Add AddressSanitizer annotations to std::vector

Jonathan Wakely jwakely@redhat.com
Wed Jul 5 19:17:00 GMT 2017


On 05/07/17 20:00 +0100, Jonathan Wakely wrote:
>We can probably do similar annotations for std::deque, so that
>partially filled pages are annotated. I also have a patch for
>shared_ptr so that objects created by make_shared can be marked as
>invalid after they're destroyed.

This is the make_shared annotation patch. This allows ASan to give an
error for:

  auto p = std::make_shared<int>();
  std::weak_ptr<int> w = p;
  int* pi = p.get();
  p = nullptr;
  return *pi;

The error isn't ideal, because ASan thinks we're using a container,
because that's what the annotations are intended for:

==4525==ERROR: AddressSanitizer: container-overflow

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 1930 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20170705/99be869d/attachment.bin>


More information about the Libstdc++ mailing list