Fix libc++ ASAN failures in resizeWithoutInitialization (#1194)
Summary: This is a proposed fix for issue: https://github.com/facebook/folly/issues/1193 Using `folly::resizeWithoutInitialization` with libc++ and the address sanitizer causes false positive 'container overflow' failures. This PR only addresses the problem for resizing `std::vector`. Presumably the version of `folly::resizeWithoutInitialization` for `std::string` has the same problem, but I have not verified this. ### Potential issues This PR assumes that the `__sanitizer_annotate_contiguous_container` is available in libc++, and that the `std::vector` implementation has been annotated with it. The latter occurred in ~2014: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/vector?r1=191987&r2=208319&pathrev=208319 If there are people using C++14 compilers with versions of libc++ predating the addition of the `std::vector<T>::__annotate_contiguous_container` member function then this fix will fail to compile. I'm not aware of any sane way to detect the exact version of libc++ being used. Perhaps a suitable mitigation for those (few?) people with a C++14 compiler and pre-2015 libc++ implementation would be to provide a `FOLLY_` macro to disable the annotation. Pull Request resolved: https://github.com/facebook/folly/pull/1194 Reviewed By: yfeldblum Differential Revision: D16445890 Pulled By: nbronson fbshipit-source-id: ef33bbd5cc12c71822985c5174bf8e47e6eb3757
Showing
Please register or sign in to comment