r226375 - [msan] Fix a uninitialized-use bug in the template argument diffing

Chandler Carruth chandlerc at gmail.com
Sat Jan 17 06:20:14 PST 2015


Author: chandlerc
Date: Sat Jan 17 08:20:14 2015
New Revision: 226375

URL: http://llvm.org/viewvc/llvm-project?rev=226375&view=rev
Log:
[msan] Fix a uninitialized-use bug in the template argument diffing
logic.

In one place we would try to check for the difference between integers
even if we were missing one of the integers. This would eventually end
up reading uninitialized data out of the APSInt objects. The fix is to
short circuit the sameness test when we don't have integers on both
sides.

This fixes a test failure I was seeing with MSan. Not sure whether other
bots were seeing it or not, but yay MSan. In particular the feature to
very carefully track origins back through stores throughout the program
was invaluable.

Modified:
    cfe/trunk/lib/AST/ASTDiagnostic.cpp

Modified: cfe/trunk/lib/AST/ASTDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDiagnostic.cpp?rev=226375&r1=226374&r2=226375&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTDiagnostic.cpp (original)
+++ cfe/trunk/lib/AST/ASTDiagnostic.cpp Sat Jan 17 08:20:14 2015
@@ -1034,7 +1034,8 @@ class TemplateDiff {
       if (!HasToInt && ToExpr)
         HasToInt = GetInt(Context, ToIter, ToExpr, ToInt);
       Tree.SetNode(FromInt, ToInt, HasFromInt, HasToInt);
-      Tree.SetSame(IsSameConvertedInt(ParamWidth, FromInt, ToInt));
+      Tree.SetSame(HasFromInt && HasToInt &&
+                   IsSameConvertedInt(ParamWidth, FromInt, ToInt));
       Tree.SetDefault(FromIter.isEnd() && HasFromInt,
                       ToIter.isEnd() && HasToInt);
       Tree.SetKind(DiffTree::Integer);





More information about the cfe-commits mailing list