[RFC] std::vector and std::string ASan annotations design
Ivan Baravy
i.baravy@samsung.com
Tue Jan 24 17:14:00 GMT 2017
Hello,
libc++ has a feature of ASan annotations inside std::vector [1,2] and
std::string [3]. These make it possible to detect container overflows,
i.e. accesses between its size and capacity. I also noticed similar
approach to libstdc++ [4], unfinished though. I really like the idea to
have this feature in libstdc++ and I prepared patches providing the
annotations mostly based on libc++ code. However, while this development
I faced a design issue I want to discuss with you.
In libc++, all the string's API functions are defined in corresponding
header file. This allows ASan annotations to be placed there (and only
there) and thus not affect dso binary. In libstdc++, instead,
basic_string.h has both definitions and declarations of public API
functions. Therefore I had to put some ASan annotations into
basic_string.tcc file which becomes a part of libstdc++ binary.
As a result,
- Sanitized applications require sanitized libstdc++ to run, and vice
versa;
- Sanitized libstdc++ requires all applications and libraries using
std::string to be sanitized.
The only solution I see for now is to move definitions into
basic_string.h in libc++ manner. However this is not acceptable for
upstream, I assume, which is my aim. Could you suggest a better solution
or give me any pointers on the issue?
Thank you.
Regards,
Ivan
[1]
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20140505/104822.html
[2]
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20140901/113973.html
[3] https://reviews.llvm.org/D12577
[4] https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=207517
More information about the Libstdc++
mailing list