<div dir="ltr">Sean it was a pleasure to have you, thanks for the hard work.<div>W</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Feb 28, 2013 at 2:38 PM, Sean McBride <span dir="ltr"><<a href="mailto:sean@rogue-research.com" target="_blank">sean@rogue-research.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
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:<br>
<br>
<<a href="http://clang.llvm.org/get_started.html" target="_blank">http://clang.llvm.org/get_started.html</a>><br>
<br>
I recommend setting CMAKE_BUILD_TYPE=Release and LLVM_ENABLE_ASSERTIONS=ON.<br>
<br>
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:<br>
<br>
<<a href="http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation" target="_blank">http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation</a>><br>
<br>
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:<br>
<br>
<<a href="http://review.source.kitware.com/10021" target="_blank">http://review.source.kitware.com/10021</a>><br>
<<a href="http://review.source.kitware.com/10026" target="_blank">http://review.source.kitware.com/10026</a>><br>
<br>
Notice that its output nicely pinpoints the problem:<br>
<br>
vtkOOGLExporter.cxx:228:3: runtime error: index -4 out of bounds for type 'char [256]'<br>
vtkOrderedTriangulator.cxx:1609 runtime error: index 8 out of bounds for type 'TemplateIDType [8]'<br>
<br>
And we found one false-positive (so you should maybe not use 'float-cast-overflow' for now):<br>
<br>
<<a href="http://llvm.org/PR15383" target="_blank">http://llvm.org/PR15383</a>><br>
<br>
I'll be turning these on on my Rogue7 dashboard bit by bit...<br>
<br>
(clang also has AddressSanitizer, ThreadSanitizer, and MemorySanitizer, which look very interesting too, but I have not yet tried them.)<br>
<br>
Cheers,<br>
<br>
--<br>
____________________________________________________________<br>
Sean McBride, B. Eng <a href="mailto:sean@rogue-research.com">sean@rogue-research.com</a><br>
Rogue Research <a href="http://www.rogue-research.com" target="_blank">www.rogue-research.com</a><br>
Mac Software Developer Montréal, Québec, Canada<br>
<br>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtk-developers" target="_blank">http://www.vtk.org/mailman/listinfo/vtk-developers</a><br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>William J. Schroeder, PhD<br>Kitware, Inc.<br>28 Corporate Drive<br>Clifton Park, NY 12065<br><a href="mailto:will.schroeder@kitware.com">will.schroeder@kitware.com</a><br>
<a href="http://www.kitware.com">http://www.kitware.com</a><br>(518) 881-4902
</div>