Re: [WIP][PATCH] pointer-overflow sanitizer

2014-11-04 Thread Will Dietz
Hi all! Attached are updated copies of the patches, previous ones no longer apply cleanly to ToT. Also cleaned up the clang patch a bit. Enjoy, feedback/review requested :). ~Will On Tue, Oct 28, 2014 at 7:42 PM, Will Dietz wdie...@illinois.edu wrote: Hi all, Attached are updated patches

Re: [WIP][PATCH] pointer-overflow sanitizer

2014-10-28 Thread Will Dietz
://wdtz.org/catching-pointer-overflow-bugs.html [2] http://wdtz.org/undefined-behavior-in-binutils-causes-segfault.html [3] http://llvm.org/viewvc/llvm-project?view=revisionrevision=216385 [4] https://trac.ffmpeg.org/ticket/3152 ~Will On Mon, Nov 18, 2013 at 11:13 PM, Will Dietz wdie...@illinois.edu

Re: r216463 - Switching from std::vector to llvm::ArrayRef per post-commit review suggestion.

2014-08-26 Thread Will Dietz
Thanks, apologies for the breakage! I'll review the Coding standards regarding the C++11 changes carefully... :). ~Will On Tue, Aug 26, 2014 at 12:05 PM, Aaron Ballman aa...@aaronballman.com wrote: Author: aaronballman Date: Tue Aug 26 12:05:57 2014 New Revision: 216463 URL:

r216385 - ASTVector: Fix return value of various insert() methods.

2014-08-25 Thread Will Dietz
Author: wdietz2 Date: Mon Aug 25 11:09:51 2014 New Revision: 216385 URL: http://llvm.org/viewvc/llvm-project?rev=216385view=rev Log: ASTVector: Fix return value of various insert() methods. Error caught using -fsanitize=pointer-overflow. Expand ASTVectorTest to verify basic behavior, test fails

Re: [PATCH] ASTVector: Fix return value of various insert() methods

2014-08-25 Thread Will Dietz
- this-begin(); if (I == this-end()) { // Important special case for empty vector. append(C, NumToInsert, Elt); - return this-begin() + InsertElt; + return this-begin(); } LGTM with one more test case for the above. On Thu, Aug 21, 2014 at 4:17 PM, Will Dietz wdie

Re: [PATCH] ASTVector: Fix return value of various insert() methods

2014-08-21 Thread Will Dietz
for more thorough testing in the future should someone tackle such a task :). Please let me know okay to commit or if there's any questions or comments :). Thanks! ~Will On Tue, Nov 19, 2013 at 9:18 AM, Will Dietz wdie...@illinois.edu wrote: Closest we have is a test to ensure ASTVector compiles

Re: [PATCH] ASTVector: Fix return value of various insert() methods

2013-11-19 Thread Will Dietz
. It'd be nice to have test coverage for this that doesn't require running a sanitizer. Do we have any direct tests for ASTVector? On Mon, Nov 18, 2013 at 9:35 PM, Will Dietz wdie...@illinois.edu wrote: Ping! :) ~Will On Mon, Nov 4, 2013 at 4:32 PM, Will Dietz wdie...@illinois.edu wrote: Ping

Re: [WIP][PATCH] pointer-overflow sanitizer

2013-11-18 Thread Will Dietz
in catching bugs in LLVM and elsewhere, as previously reported. Thanks! ~Will On Mon, Oct 28, 2013 at 7:56 PM, Will Dietz wdie...@illinois.edu wrote: Glad there's some interest. I have no test coverage of anything other than the Driver component, that will be included. I also need to do some

Re: [PATCH] ASTVector: Fix return value of various insert() methods

2013-11-18 Thread Will Dietz
Ping! :) ~Will On Mon, Nov 4, 2013 at 4:32 PM, Will Dietz wdie...@illinois.edu wrote: Ping. It's easy to get clang to trigger this bug which results in an invalid iterator to be returned (which the current code happens to ignore, but that's just a lucky coincidence), as this regularly

[PATCH] ubsan: Only emit constants for filenames and type descriptors once.

2013-11-07 Thread Will Dietz
: Will Dietz w...@wdtz.org Date: Thu, 7 Nov 2013 15:27:03 -0600 Subject: [PATCH] ubsan: Only emit constants for filenames and type descriptors once. Produces neater IR in significantly less time. (~18% faster -O0 compile time for sqlite3 with -fsanitize=undefined) --- lib/CodeGen/CGExpr.cpp

Re: [PATCH] Fix toolchain detection on SL6

2013-11-07 Thread Will Dietz
Looks like this is unnecessary and was actually only temporarily broken by r193528, which was reverted quickly and fixed shortly thereafter in r193554 and others. AFAICT --no-add-needed is not used by default, so it seems the default handling for an unknown target is appropriate. Thanks for the

r194231 - ubsan: Only emit constants for filenames and type descriptors once.

2013-11-07 Thread Will Dietz
Author: wdietz2 Date: Thu Nov 7 19:09:22 2013 New Revision: 194231 URL: http://llvm.org/viewvc/llvm-project?rev=194231view=rev Log: ubsan: Only emit constants for filenames and type descriptors once. Produces neater IR in significantly less time. (~18% faster -O0 compile time for sqlite3 with

Re: [PATCH] ubsan: Only emit constants for filenames and type descriptors once.

2013-11-07 Thread Will Dietz
My pleasure :). r194231, thanks! ~Will On Thu, Nov 7, 2013 at 7:07 PM, Richard Smith rich...@metafoo.co.uk wrote: On Thu, Nov 7, 2013 at 3:34 PM, Will Dietz wdie...@illinois.edu wrote: Produces neater IR in significantly less time. (~18% faster -O0 compile time for sqlite3 with -fsanitize

Re: [PATCH] ASTVector: Fix return value of various insert() methods

2013-11-04 Thread Will Dietz
a simple dummy ASTContext for testing? As noted in the commit that originally added ASTVectorTest.cpp (r186253) this blocks the creation of even basic functionality tests for this data structure. ~Will On Mon, Oct 28, 2013 at 5:11 PM, Will Dietz wdie...@illinois.edu wrote: Error caught -fsanitize

[PATCH] ASTVector: Fix return value of various insert() methods

2013-10-28 Thread Will Dietz
] Patches coming soon. [2] See the implementation of append(), for example. From d89275825fdfa88c78719df5489433277e56e735 Mon Sep 17 00:00:00 2001 From: Will Dietz w...@wdtz.org Date: Mon, 28 Oct 2013 08:10:34 -0500 Subject: [PATCH] ASTVector: Fix return value of various insert() methods. Error caught

[PATCH] Fix toolchain detection on SL6

2013-10-28 Thread Will Dietz
See attached, thanks! ~Will From 13bc7bb6b76cd884469004f864e5f53803554350 Mon Sep 17 00:00:00 2001 From: Will Dietz w...@wdtz.org Date: Mon, 28 Oct 2013 16:49:43 -0500 Subject: [PATCH] Fix toolchain detection on SL6. * Add SL6 Distro type, detect from /etc/redhat-release * Ignore /etc/lsb

[WIP][PATCH] pointer-overflow sanitizer

2013-10-28 Thread Will Dietz
bugs! :) ~Will [1] http://wdtz.org/undefined-behavior-in-binutils-causes-segfault.html [2] http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20131028/091878.html From bf46609c78ccdd27253dcaeee39ffcac7a156456 Mon Sep 17 00:00:00 2001 From: Will Dietz w...@wdtz.org Date: Sun, 27 Oct 2013

Re: [WIP][PATCH] pointer-overflow sanitizer

2013-10-28 Thread Will Dietz
on large codebases? Does this find many bugs? (I can imagine it would be effective when combined with fuzz testing...) On Mon, Oct 28, 2013 at 3:39 PM, Will Dietz wdie...@illinois.edu wrote: Hi all, Recently I thought it would be useful to have a sanitizer for detecting overflows in pointer

[clang-tools-extra] r192713 - ModuleAssistant: Fix warning, don't return bool as a pointer.

2013-10-15 Thread Will Dietz
Author: wdietz2 Date: Tue Oct 15 10:45:00 2013 New Revision: 192713 URL: http://llvm.org/viewvc/llvm-project?rev=192713view=rev Log: ModuleAssistant: Fix warning, don't return bool as a pointer. No functionality change intended. Modified:

[PATCH] [ubsan] Emit single check for Shl

2013-02-25 Thread Will Dietz
See attached. This is important to avoid warning twice on shifts that fail both checks, like 1 -1. The branching is done to avoid executing the second check's shift with invalid operands (poisoning the result), especially since we already know the shift is invalid. Thanks! ~Will

r176056 - [ubsan] Emit single check for left shift.

2013-02-25 Thread Will Dietz
Author: wdietz2 Date: Mon Feb 25 16:37:49 2013 New Revision: 176056 URL: http://llvm.org/viewvc/llvm-project?rev=176056view=rev Log: [ubsan] Emit single check for left shift. Avoids warning twice on same shift. Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp

Re: [PATCH] [ubsan] Emit single check for Shl

2013-02-25 Thread Will Dietz
at 1:02 PM, Will Dietz wdie...@illinois.edu wrote: See attached. This is important to avoid warning twice on shifts that fail both checks, like 1 -1. The branching is done to avoid executing the second check's shift with invalid operands (poisoning the result), especially since we already

Re: [PATCH] -fcatch-undefined-behavior with trapping implementation

2013-01-29 Thread Will Dietz
On Mon, Jan 28, 2013 at 7:10 PM, Richard Smith rich...@metafoo.co.uk wrote: On Mon, Jan 28, 2013 at 5:01 PM, Will Dietz wdie...@uiuc.edu wrote: Glad this is going in, although I would prefer to see compiler-rt become more widely used (shipped by default, etc) instead. However, that's

Re: [PATCH] -fcatch-undefined-behavior with trapping implementation

2013-01-28 Thread Will Dietz
Glad this is going in, although I would prefer to see compiler-rt become more widely used (shipped by default, etc) instead. However, that's not the case yet and it's good to make these checks available to users that either don't want to or can't use it (kernel work, no compiler-rt readily

Re: [cfe-commits] [PATCH] [ubsan] Add support for -fsanitize-blacklist

2013-01-19 Thread Will Dietz
, due to try to match whole DOSish path without escaping with Regex. Two tests have been suppressed on win32 since r172820, FYI. ...Takumi 2013/1/18 Will Dietz wdie...@illinois.edu: Committed as r172806 (llvm) and r172808 (clang). Thanks! ~Will On Fri, Jan 18, 2013 at 2:28 AM, Alexey

[cfe-commits] r172808 - in /cfe/trunk: include/clang/Basic/ lib/Basic/ lib/CodeGen/ lib/Frontend/ lib/Lex/ lib/Serialization/ test/CodeGen/

2013-01-18 Thread Will Dietz
Author: wdietz2 Date: Fri Jan 18 05:30:38 2013 New Revision: 172808 URL: http://llvm.org/viewvc/llvm-project?rev=172808view=rev Log: [ubsan] Add support for -fsanitize-blacklist Added: cfe/trunk/test/CodeGen/ubsan-blacklist.c Modified: cfe/trunk/include/clang/Basic/LangOptions.def

Re: [cfe-commits] [PATCH] [ubsan] Add support for -fsanitize-blacklist

2013-01-18 Thread Will Dietz
this look OK from your end? On Thu, Jan 17, 2013 at 8:53 AM, Will Dietz wdie...@illinois.edu wrote: Great, thank you both for your feedback. I also agree the approach originally submitted was messy, and Richard you nailed the conflict that drove me to accept it. Thank you for giving me a better

[cfe-commits] [PATCH] [ubsan] Add support for -fsanitize-blacklist

2013-01-16 Thread Will Dietz
Attached are two patches. First applies to clang and uses the blacklist to avoid instrumenting the source files or functions specified. Lit test included. The other is a small change to llvm to make the Blacklist class visible to Clang. Not sure I understand the header organization system well

Re: [cfe-commits] [PATCH] [ubsan] Add support for -fsanitize-blacklist

2013-01-16 Thread Will Dietz
Minor touchup to clang patch, thanks! ~Will On Wed, Jan 16, 2013 at 11:37 AM, Will Dietz wdie...@illinois.edu wrote: Attached are two patches. First applies to clang and uses the blacklist to avoid instrumenting the source files or functions specified. Lit test included. The other

Re: [cfe-commits] [Review] [ubsan] Deduplication

2013-01-14 Thread Will Dietz
On Mon, Jan 14, 2013 at 1:27 AM, Alexey Samsonov samso...@google.com wrote: On Wed, Jan 9, 2013 at 6:01 AM, Will Dietz wdie...@illinois.edu wrote: On Tue, Jan 8, 2013 at 3:02 PM, Richard Smith rich...@metafoo.co.uk wrote: On Tue, Jan 8, 2013 at 12:21 AM, Will Dietz wdie...@illinois.edu

[cfe-commits] [PATCH] ToolsChains: Minor touchup to use correct type, avoid truncation

2013-01-10 Thread Will Dietz
Please see attached. ~Will 0001-ToolChains-Minor-touchup-to-use-correct-type-avoid-t.patch Description: Binary data ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Re: [cfe-commits] [PATCH] ToolsChains: Minor touchup to use correct type, avoid truncation

2013-01-10 Thread Will Dietz
Heh, agreed. r172127, thanks! ~Will On Thu, Jan 10, 2013 at 4:19 PM, Richard Smith rich...@metafoo.co.uk wrote: It would be alarming if this made a difference in practice, but LGTM On Thu, Jan 10, 2013 at 2:13 PM, Will Dietz wdie...@uiuc.edu wrote: Please see attached

[cfe-commits] r172127 - /cfe/trunk/lib/Driver/ToolChains.cpp

2013-01-10 Thread Will Dietz
Author: wdietz2 Date: Thu Jan 10 16:20:02 2013 New Revision: 172127 URL: http://llvm.org/viewvc/llvm-project?rev=172127view=rev Log: ToolChains: Minor touchup to use correct type, avoid truncation. Truncation happens regularly when find_first_not_of returns npos, strings long enough to trigger

Re: [cfe-commits] r171801 - in /cfe/trunk: lib/CodeGen/CGExprScalar.cpp test/CodeGen/compound-assign-overflow.c

2013-01-09 Thread Will Dietz
Sorry about that! Can you apply the attached patch (patch -p1 patchfile) and confirm this fixes the issue for you? Thanks! ~Will On Wed, Jan 9, 2013 at 8:08 AM, İsmail Dönmez ism...@donmez.ws wrote: Hi; On Mon, Jan 7, 2013 at 11:25 PM, Will Dietz wdie...@illinois.edu wrote: Author

Re: [cfe-commits] r171801 - in /cfe/trunk: lib/CodeGen/CGExprScalar.cpp test/CodeGen/compound-assign-overflow.c

2013-01-09 Thread Will Dietz
Poor internet here, my apologies for skipping a message in the thread. Can you check if this still fails on trunk as Dmitri suggested? Thanks! ~Will On Wed, Jan 9, 2013 at 1:48 PM, Will Dietz wdie...@illinois.edu wrote: Sorry about that! Can you apply the attached patch (patch -p1

Re: [cfe-commits] [Review] [ubsan] Deduplication

2013-01-08 Thread Will Dietz
duplicate overflows. Does this seem valid to you? It's the primary reason for having any of the non-atomic accesses to the Columns field in this code. Thank you for your time, ~Will On Mon, Jan 7, 2013 at 3:17 PM, Will Dietz wdie...@illinois.edu wrote: Updated, slightly neater patches attached

Re: [cfe-commits] [Review] [ubsan] Deduplication

2013-01-08 Thread Will Dietz
On Tue, Jan 8, 2013 at 3:02 PM, Richard Smith rich...@metafoo.co.uk wrote: On Tue, Jan 8, 2013 at 12:21 AM, Will Dietz wdie...@illinois.edu wrote: Thanks for taking a look. Responses inline. On Mon, Jan 7, 2013 at 10:16 PM, Richard Smith rich...@metafoo.co.uk wrote: Thanks! This patch

[cfe-commits] r171947 - in /cfe/trunk: lib/CodeGen/CGExpr.cpp test/CodeGen/catch-undef-behavior.c test/CodeGen/compound-assign-overflow.c

2013-01-08 Thread Will Dietz
Author: wdietz2 Date: Tue Jan 8 21:39:41 2013 New Revision: 171947 URL: http://llvm.org/viewvc/llvm-project?rev=171947view=rev Log: [ubsan] Make static check data non-const so it can be used for deduplication. Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp

Re: [cfe-commits] r171947 - in /cfe/trunk: lib/CodeGen/CGExpr.cpp test/CodeGen/catch-undef-behavior.c test/CodeGen/compound-assign-overflow.c

2013-01-08 Thread Will Dietz
On Tue, Jan 8, 2013 at 9:46 PM, Eli Friedman eli.fried...@gmail.com wrote: On Tue, Jan 8, 2013 at 7:39 PM, Will Dietz wdie...@illinois.edu wrote: Author: wdietz2 Date: Tue Jan 8 21:39:41 2013 New Revision: 171947 URL: http://llvm.org/viewvc/llvm-project?rev=171947view=rev Log: [ubsan

[cfe-commits] r171718 - in /cfe/trunk: lib/Analysis/CFG.cpp test/Analysis/cfg.cpp

2013-01-07 Thread Will Dietz
Author: wdietz2 Date: Mon Jan 7 03:51:17 2013 New Revision: 171718 URL: http://llvm.org/viewvc/llvm-project?rev=171718view=rev Log: CFG.cpp: Fix wrapping logic when printing block preds/succs. First check only wrapped with i==8, second wrapped at i==2,8,18,28,... This fix restores the intended

Re: [cfe-commits] [Review] [ubsan] Fix type reported in compound assignment operations

2013-01-07 Thread Will Dietz
Ping :). Updated patches for ToT attached. ~Will On Sun, Dec 30, 2012 at 4:13 PM, Will Dietz wdie...@uiuc.edu wrote: Thanks for the feedback, updated patches attached. Moved regression test to clang, and also fix similar issue with /= using the wrong type. On Sun, Dec 30, 2012 at 2:48 AM

[cfe-commits] r171801 - in /cfe/trunk: lib/CodeGen/CGExprScalar.cpp test/CodeGen/compound-assign-overflow.c

2013-01-07 Thread Will Dietz
Author: wdietz2 Date: Mon Jan 7 16:25:52 2013 New Revision: 171801 URL: http://llvm.org/viewvc/llvm-project?rev=171801view=rev Log: [ubsan] Use correct type for compound assignment ops. Added: cfe/trunk/test/CodeGen/compound-assign-overflow.c Modified:

Re: [cfe-commits] [Review] [ubsan] Deduplication

2013-01-07 Thread Will Dietz
Updated, slightly neater patches attached. Thanks! ~Will On Tue, Jan 1, 2013 at 9:49 PM, Will Dietz wdie...@illinois.edu wrote: Updated to apply cleanly to latest clang/compiler-rt. Thanks! ~Will On Sun, Dec 30, 2012 at 6:22 PM, Will Dietz wdie...@illinois.edu wrote: (Moving to cfe

Re: [cfe-commits] [Review] [ubsan] Deduplication

2013-01-01 Thread Will Dietz
Updated to apply cleanly to latest clang/compiler-rt. Thanks! ~Will On Sun, Dec 30, 2012 at 6:22 PM, Will Dietz wdie...@illinois.edu wrote: (Moving to cfe-commits@, was previously: http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-December/026519.html) Please see attached! :) Thank you

[cfe-commits] [PATCH] CFG.cpp: Fix wrapping logic when printing block preds/succs.

2013-01-01 Thread Will Dietz
Attached, testcase included. Found with -fsanitize=integer. ~Will 0001-CFG.cpp-Fix-wrapping-logic-when-printing-block-preds.patch Description: Binary data ___ cfe-commits mailing list cfe-commits@cs.uiuc.edu

[cfe-commits] [PATCH] DiagnosticIds: Fix offset/ID calculation, no impact outside this code.

2013-01-01 Thread Will Dietz
See attached. Minor code touchup, no externally-visible functionality change. Assert added causes major check-clang failures without the corresponding code change in the patch. Found with -fsanitize=integer. ~Will 0001-DiagnosticIds-Fix-offset-ID-calculation-no-impact-ou.patch Description:

[cfe-commits] [Review] [ubsan] Fix type reported in compound assignment operations

2012-12-30 Thread Will Dietz
See attached patches, thanks! Description: When checking a += b we were using the type of 'a' in the diagnostic, instead of the type of the overflowing expression a+b. This was particularly problematic when 'a' was signed and 'b' was unsigned. Okay to commit? ~Will

[cfe-commits] r171264 - in /cfe/trunk: include/clang/Driver/CC1Options.td include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.def lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation

2012-12-30 Thread Will Dietz
Author: wdietz2 Date: Sun Dec 30 14:53:28 2012 New Revision: 171264 URL: http://llvm.org/viewvc/llvm-project?rev=171264view=rev Log: [ubsan] Recover by default, use -fno-sanitize-recover to disable. Modified: cfe/trunk/include/clang/Driver/CC1Options.td

Re: [cfe-commits] [Review] [ubsan] Fix type reported in compound assignment operations

2012-12-30 Thread Will Dietz
refactor Clang's IRGen without running the compiler-rt tests). Understood, thanks for the explanation. Makes good sense. On Sun, Dec 30, 2012 at 12:13 AM, Will Dietz wdie...@uiuc.edu wrote: See attached patches, thanks! Description: When checking a += b we were using the type

[cfe-commits] [Review] [ubsan] Deduplication

2012-12-30 Thread Will Dietz
(Moving to cfe-commits@, was previously: http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-December/026519.html) Please see attached! :) Thank you, ~Will 0001-ubsan-Add-deduplication-functionality-always-enabled.patch Description: Binary data

[cfe-commits] r170263 - in /cfe/trunk: lib/CodeGen/CGExpr.cpp test/CodeGen/catch-undef-behavior.c

2012-12-14 Thread Will Dietz
Author: wdietz2 Date: Fri Dec 14 19:39:14 2012 New Revision: 170263 URL: http://llvm.org/viewvc/llvm-project?rev=170263view=rev Log: [ubsan] Emit branch weight metadata to hint towards common case. Results in better block placement that helps close the performance gap when making ubsan checks

[cfe-commits] r169114 - in /cfe/trunk: include/clang/Driver/CC1Options.td include/clang/Frontend/CodeGenOptions.def lib/CodeGen/CGBuiltin.cpp lib/CodeGen/CGExpr.cpp lib/CodeGen/CGExprScalar.cpp lib/Co

2012-12-02 Thread Will Dietz
Author: wdietz2 Date: Sun Dec 2 13:50:33 2012 New Revision: 169114 URL: http://llvm.org/viewvc/llvm-project?rev=169114view=rev Log: [ubsan] Add flag to enable recovery from checks when possible. Added: cfe/trunk/test/CodeGen/sanitize-recover.c Modified:

[cfe-commits] r168701 - in /cfe/trunk: docs/UsersManual.html include/clang/Basic/Sanitizers.def lib/CodeGen/CGExprScalar.cpp lib/Driver/SanitizerArgs.h test/CodeGen/catch-undef-behavior.c test/CodeGen

2012-11-27 Thread Will Dietz
Author: wdietz2 Date: Tue Nov 27 09:01:55 2012 New Revision: 168701 URL: http://llvm.org/viewvc/llvm-project?rev=168701view=rev Log: Add -fsanitize=integer for reporting suspicious integer behaviors. Introduces new sanitizer unsigned-integer-overflow. Added: