[cfe-dev] Interesting behaviour with UBSAN+libc++

Richard Smith richard at metafoo.co.uk
Thu Dec 4 13:39:06 PST 2014


The UBSan runtime's support for type checks of virtual bases is new and
possibly incorrect.

On Thu, Dec 4, 2014 at 1:12 PM, Eric Fiselier <eric at efcs.ca> wrote:

> LLVM and libc++ always seem to use '-fno-sanitize=vptr,function' and
> '-fno-sanitize-recover' with UBSAN. I imagine adding these will remove
> the error.
> I would ask the compiler-rt people about the error on llvm-dev.
>
> /Eric
>
> On Thu, Dec 4, 2014 at 2:05 PM, Eric Fiselier <eric at efcs.ca> wrote:
> > Did you compile libc++ with UBSAN?
> >
> > /Eric
> >
> > On Thu, Dec 4, 2014 at 6:21 AM, İsmail Dönmez <ismail at donmez.ws> wrote:
> >> I got some very simple code, dumbed down from a larger one:
> >>
> >> [~]> cat wc.cpp
> >> #include <iostream>
> >>
> >> int wc() {
> >>     return 0;
> >> }
> >>
> >> int main()
> >> {
> >>     std::cout << wc() << std::endl;
> >> }
> >>
> >> [~]> /opt/clang/bin/clang++ -stdlib=libc++ -fsanitize=undefined wc.cpp
> >> [~]> ./a.out
> >> /opt/clang/bin/../include/c++/v1/ostream:1034:14: runtime error: member
> call
> >> on address 0x000000ef9858 which does not point to an object of type
> >> 'std::__1::basic_ios<char>'
> >> 0x000000ef9850: note: object is base class subobject at offset 8 within
> >> object of type 'std::__1::basic_ostream<char,
> std::__1::char_traits<char> >'
> >>  00 00 00 00  40 a3 b9 c6 b1 7f 00 00  68 a3 b9 c6 b1 7f 00 00  02 10
> 00 00
> >> 00 00 00 00  06 00 00 00
> >>               ^                        ~~~~~~~~~~~~~~~~~~~~~~~
> >>                                        vptr for '<unknown>' base class
> of
> >> 'std::__1::basic_ostream<char, std::__1::char_traits<char> >'
> >> /opt/clang/bin/../include/c++/v1/ios:734:41: runtime error: member call
> on
> >> address 0x000000ef9858 which does not point to an object of type
> >> 'std::__1::ios_base'
> >> 0x000000ef9850: note: object is base class subobject at offset 8 within
> >> object of type 'std::__1::basic_ostream<char,
> std::__1::char_traits<char> >'
> >>  00 00 00 00  40 a3 b9 c6 b1 7f 00 00  68 a3 b9 c6 b1 7f 00 00  02 10
> 00 00
> >> 00 00 00 00  06 00 00 00
> >>               ^                        ~~~~~~~~~~~~~~~~~~~~~~~
> >>                                        vptr for '<unknown>' base class
> of
> >> 'std::__1::basic_ostream<char, std::__1::char_traits<char> >'
> >> 0
> >>
> >>
> >> Works fine if I link to libstdc++. clang is r223341.
> >>
> >>
> >> _______________________________________________
> >> cfe-dev mailing list
> >> cfe-dev at cs.uiuc.edu
> >> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> >>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141204/946b3183/attachment.html>


More information about the cfe-dev mailing list