[libcxx-commits] [PATCH] D132090: [1a/3][ASan][compiler-rt] API for double ended containers

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Sep 7 13:46:35 PDT 2022


ldionne added a comment.

Thanks a lot for the patch series. I've been independently considering changes to our so-called "debug mode" recently where `std::vector` & friends would have special iterators that keep track of the size of the container they point into, and can trap when dereferenced at an out-of-bounds address. This could be achieved by storing the bounds of the vector's allocation at the beginning of the allocation itself, and then those bounds-aware iterators would basically have a pointer within the allocation, and a pointer to the header containing that metadata. This would have the benefit that iterators have access to the bounds information as long as they are not invalidated by reallocating the vector. But the vector object itself (not the contiguous memory + header it points to) could move around without impacting the iterators.

Okay, so this is mostly unrelated to this patch because it concerns only contiguous containers so far. However, since this patch expands the intersection between the library and AddressSanitizer, perhaps it is worth discussing the pros and cons of each approach. In particular, the typical slowdown for using ASAN is documented <https://clang.llvm.org/docs/AddressSanitizer.html> as roughly 2x. The goal I was aiming for with the design I drafted above would be to have a smaller performance impact than ASAN, with the goal of hopefully being able to even turn it on in production in some scenarios.

Having obviously done a lot of work and thinking in the intersection of the library and sanitizers, do you have thoughts about this?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132090/new/

https://reviews.llvm.org/D132090



More information about the libcxx-commits mailing list