detecting "container overflow" bugs in std::vector

Jonathan Wakely jwakely@redhat.com
Mon May 26 14:12:00 GMT 2014


On 26/05/14 17:40 +0400, Konstantin Serebryany wrote:
>Would you consider a patch similar to [4] for libstdc++ trunk?
>If yes, any comments on the patch?

+ // When sanitizer annotataions are off, avoid bazillion of no-op
                    ^^^^^^^^^^^^

I'd rather see the member functions use our consistent naming
conventions.

The function parameters in the __is_same_allocator<T,U> case should be
unnamed, to avoid warnings with -Wsystem-headers.

The __old_size variable should be marked __attribute((unused)) too, or
just get rid of it and pass size() - 1 to the annotate function.

>The current patch has a (minor) problem that affects only code with
>exceptions [5].

So "only" most C++ code then. That's not minor.
Not everyone turns off exceptions like Google.

>If the libstdc++ team is generally ok with the idea I will work on the
>updated patch
>and send it for review.

It does look useful but I'm concerned about a proliferation of
container checks, we already have the libstdc++ Debug Mode, and I'd
like to see some of the lightweight checks from the Google branch
added to trunk too.

The exception problem is a showstopper, but should be fixable with
some RAII.



More information about the Libstdc++ mailing list