[cfe-dev] [PATCH] Integer Sanitizer Initial Patches

Will Dietz willdtz at gmail.com
Wed Nov 7 17:15:44 PST 2012


Hi all,

Attached are patches that add a new 'sanitizer' to clang for detecting
and reporting integer overfllows.  Unlike the checks added by
-fcatch-undefined-behavior, these also include non-undefined-behavior
checks.

The attached clang patch adds:

-fsanitize=unsigned-integer-overflow
and
-fsanitize=integer

The first adds support for inserting checks for unsigned integer
overflow, the latter is a new 'sanitizer group' which is used to
enable all integer-related checking.  In the future I'd like to
include value-losing conversions, but for now this includes the
existing checks (signed overflow, divide-by-zero, shifts) as well as
the new unsigned overflow checks.

Also attached is a corresponding patch for compiler-rt that extends
ubsan to include support for reporting unsigned as well as signed
overflows.

Two issues with this that I'm hoping can be discussed:
* As per PR14247 (http://llvm.org/bugs/show_bug.cgi?id=14247), the
ubsan checks presently aren't recoverable.  This reduces these checks'
utility for quickly getting a new large codebase into shape as
mentioned in that bug, but this is of course even more important to be
made optional when reporting unsigned overflows is enabled as well.

* Extending "ubsan" is unfortunate given its name, but these checks
don't seem to merit a separate library either.  Thoughts?

Thank you for your time and looking forward to your comments.

~Will

**Written during the LLVM Hacker's Lab :) **
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-unsigned-integer-overflow-sanitizer.patch
Type: application/octet-stream
Size: 5562 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121107/c6ffb37f/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Add-fsanitizer-integer-group-for-all-integer-related.patch
Type: application/octet-stream
Size: 2567 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121107/c6ffb37f/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-support-for-unsigned-overflow-diagnostic-reporti.patch
Type: application/octet-stream
Size: 9306 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121107/c6ffb37f/attachment-0002.obj>


More information about the cfe-dev mailing list