[vtk-developers] clang undefined behaviour sanitizer overview

Will Schroeder will.schroeder at kitware.com
Thu Feb 28 14:40:16 EST 2013


Sean it was a pleasure to have you, thanks for the hard work.
W


On Thu, Feb 28, 2013 at 2:38 PM, Sean McBride <sean at rogue-research.com>wrote:

> Hi all,
>
> So at the VTK hack-a-thon yesterday I showed some of you clang's
> 'undefined behaviour sanitizer' (abbreviated 'ubsan').  If you want to try
> it yourself, you need to build clang from svn, which is easy and can be
> done with CMake:
>
> <http://clang.llvm.org/get_started.html>
>
> I recommend setting CMAKE_BUILD_TYPE=Release and LLVM_ENABLE_ASSERTIONS=ON.
>
> Then you just use your new clang executable with "-fsanitize=undefined" as
> a C/C++ flag.  Should work on linux or OS X.  It's described here:
>
> <http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation>
>
> It may report many things, and can be too noisy, so you can specify a
> subset of checks.  For VTK, I've been using
> "-fsanitize=bool,bounds,float-cast-overflow,integer-divide-by-zero,null,object-size,return,shift,signed-integer-overflow,unreachable,vla-bound"
> and this triggers only a few issues, some of which we fixed at the
> hack-a-thon:
>
> <http://review.source.kitware.com/10021>
> <http://review.source.kitware.com/10026>
>
> Notice that its output nicely pinpoints the problem:
>
> vtkOOGLExporter.cxx:228:3: runtime error: index -4 out of bounds for type
> 'char [256]'
> vtkOrderedTriangulator.cxx:1609  runtime error: index 8 out of bounds for
> type 'TemplateIDType [8]'
>
> And we found one false-positive (so you should maybe not use
> 'float-cast-overflow' for now):
>
> <http://llvm.org/PR15383>
>
> I'll be turning these on on my Rogue7 dashboard bit by bit...
>
> (clang also has AddressSanitizer, ThreadSanitizer, and MemorySanitizer,
> which look very interesting too, but I have not yet tried them.)
>
> Cheers,
>
> --
> ____________________________________________________________
> Sean McBride, B. Eng                 sean at rogue-research.com
> Rogue Research                        www.rogue-research.com
> Mac Software Developer              Montréal, Québec, Canada
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>


-- 
William J. Schroeder, PhD
Kitware, Inc.
28 Corporate Drive
Clifton Park, NY 12065
will.schroeder at kitware.com
http://www.kitware.com
(518) 881-4902
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20130228/b2c0ac40/attachment.html>


More information about the vtk-developers mailing list