Add AddressSanitizer annotations to std::string

Jonathan Wakely
Tue May 29 14:01:00 GMT 2018

On 29/05/18 16:47 +0300, Kashkarov Mikhail wrote:
>Jonathan Wakely <> writes:
>> On 29/05/18 09:51 +0300, Mikhail Kashkarov wrote:
>>>I'd like to propose following features for the review:
>>>[1] Add option to disable std::string small-string optimization usage.
>>>Add _GLIBCXX_DISABLE_SSO_USAGE define that disables c++11 std::string
>>>_M_local_buf usage to let AddressSanitizer poison string buffer correctly.
>>>[2] Add AddressSanitizer annotations to std::string.
>>>String annotations can be enabled with _GLIBCXX_ANNOTATE_STRING define.
>>>For COW-strings annotation we need to align the beginning of string
>>>buffer by 8
>>>(ASan requirements), so the layout change is applied if annotations in on.
>>>This work is based on Ivan Baravy draft patches for string annotations.
>> Thanks for the patches, I'll comment on the two emails individually.
>>>Also, while testing annotations for older compiler versions I managed to
>>>libstdc++ bugs in std::regex/std::basic_stringbuf that are fixed in
>>>upstream now so it could be useful not only for testing projects but for the
>>>library itself.
>> That's good to know.
>> Were there bugzilla reports for these bugs you found? I'd like to be
>> sure they were fixed intentionally and that we have tests to ensure
>> the bugs don't get re-introduced later.
>PR/81338 for std::basic_stringbuf (unused capacity from string).
>For std::regex i did't look for the reports, but there were failing tests
>for strings without sso usage that got resolved somewhere between
>f1717362 and current head.


More information about the Libstdc++ mailing list