[cfe-commits] r159161 - in /cfe/trunk: lib/AST/ExprConstant.cpp test/SemaCXX/constexpr-many-arguments.cpp
Matt Beaumont-Gay
matthewbg at google.com
Mon Jun 25 19:43:08 PDT 2012
Hi Eli,
I believe this change caused
test/SemaCXX/constant-expression-cxx11.cpp to fail with a Clang built
with ASan:
==21931== ERROR: AddressSanitizer heap-use-after-free on address
0x2ad4eff578a8 at pc 0x25f10e5 bp 0x7fff2fd5d5b0 sp 0x7fff2fd5d5a8
READ of size 4 at 0x2ad4eff578a8 thread T0
#0 0x25f10e5 std::swap<>()
#1 0x25eec25 clang::APValue::swap()
#2 0x121ca2e clang::APValue::operator=()
#3 0x2775cc8 (anonymous namespace)::IntExprEvaluator::Success()
#4 0x277625b (anonymous namespace)::IntExprEvaluator::Success()
#5 0x277824a (anonymous namespace)::ExprEvaluatorBase<>::VisitCallExpr()
#6 0x2773926 (anonymous namespace)::IntExprEvaluator::VisitCallExpr()
#7 0x273a604 clang::StmtVisitorBase<>::Visit()
#8 0x2738e65 Evaluate()
#9 0x274aefa (anonymous
namespace)::OpaqueValueEvaluation::OpaqueValueEvaluation()
#10 0x27705a1 (anonymous
namespace)::ExprEvaluatorBase<>::VisitBinaryConditionalOperator()
#11 0x2739cfc clang::StmtVisitorBase<>::Visit()
#12 0x2774e4c (anonymous namespace)::ExprEvaluatorBase<>::VisitParenExpr()
#13 0x273a96e clang::StmtVisitorBase<>::Visit()
#14 0x277dd16 (anonymous
namespace)::ExprEvaluatorBase<>::HandleConditionalOperator<>()
#15 0x2770798 (anonymous
namespace)::ExprEvaluatorBase<>::VisitConditionalOperator()
#16 0x273a41b clang::StmtVisitorBase<>::Visit()
#17 0x2738e65 Evaluate()
#18 0x2738899 EvaluateStmt()
#19 0x273886b EvaluateStmt()
#20 0x2737bb1 HandleFunctionCall()
#21 0x277822e (anonymous namespace)::ExprEvaluatorBase<>::VisitCallExpr()
#22 0x2773926 (anonymous namespace)::IntExprEvaluator::VisitCallExpr()
#23 0x273a604 clang::StmtVisitorBase<>::Visit()
#24 0x2738e65 Evaluate()
#25 0x274aefa (anonymous
namespace)::OpaqueValueEvaluation::OpaqueValueEvaluation()
#26 0x27705a1 (anonymous
namespace)::ExprEvaluatorBase<>::VisitBinaryConditionalOperator()
#27 0x2739cfc clang::StmtVisitorBase<>::Visit()
#28 0x2774e4c (anonymous namespace)::ExprEvaluatorBase<>::VisitParenExpr()
#29 0x273a96e clang::StmtVisitorBase<>::Visit()
#30 0x277dd16 (anonymous
namespace)::ExprEvaluatorBase<>::HandleConditionalOperator<>()
#31 0x2770798 (anonymous
namespace)::ExprEvaluatorBase<>::VisitConditionalOperator()
#32 0x273a41b clang::StmtVisitorBase<>::Visit()
#33 0x2738e65 Evaluate()
#34 0x2738899 EvaluateStmt()
#35 0x273886b EvaluateStmt()
#36 0x2737bb1 HandleFunctionCall()
#37 0x277822e (anonymous namespace)::ExprEvaluatorBase<>::VisitCallExpr()
#38 0x2773926 (anonymous namespace)::IntExprEvaluator::VisitCallExpr()
#39 0x273a604 clang::StmtVisitorBase<>::Visit()
#40 0x2738e65 Evaluate()
#41 0x274aefa (anonymous
namespace)::OpaqueValueEvaluation::OpaqueValueEvaluation()
#42 0x27705a1 (anonymous
namespace)::ExprEvaluatorBase<>::VisitBinaryConditionalOperator()
#43 0x2739cfc clang::StmtVisitorBase<>::Visit()
#44 0x2774e4c (anonymous namespace)::ExprEvaluatorBase<>::VisitParenExpr()
#45 0x273a96e clang::StmtVisitorBase<>::Visit()
#46 0x277dd16 (anonymous
namespace)::ExprEvaluatorBase<>::HandleConditionalOperator<>()
#47 0x2770798 (anonymous
namespace)::ExprEvaluatorBase<>::VisitConditionalOperator()
#48 0x273a41b clang::StmtVisitorBase<>::Visit()
#49 0x2738e65 Evaluate()
#50 0x2738899 EvaluateStmt()
#51 0x273886b EvaluateStmt()
#52 0x2737bb1 HandleFunctionCall()
#53 0x277822e (anonymous namespace)::ExprEvaluatorBase<>::VisitCallExpr()
#54 0x2773926 (anonymous namespace)::IntExprEvaluator::VisitCallExpr()
#55 0x273a604 clang::StmtVisitorBase<>::Visit()
#56 0x2738e65 Evaluate()
#57 0x274aefa (anonymous
namespace)::OpaqueValueEvaluation::OpaqueValueEvaluation()
#58 0x27705a1 (anonymous
namespace)::ExprEvaluatorBase<>::VisitBinaryConditionalOperator()
#59 0x2739cfc clang::StmtVisitorBase<>::Visit()
#60 0x2774e4c (anonymous namespace)::ExprEvaluatorBase<>::VisitParenExpr()
#61 0x273a96e clang::StmtVisitorBase<>::Visit()
#62 0x277dd16 (anonymous
namespace)::ExprEvaluatorBase<>::HandleConditionalOperator<>()
#63 0x2770798 (anonymous
namespace)::ExprEvaluatorBase<>::VisitConditionalOperator()
0x2ad4eff578a8 is located 40 bytes inside of 96-byte region
[0x2ad4eff57880,0x2ad4eff578e0)
freed by thread T0 here:
#0 0x3e2cc42 operator delete()
#1 0x278f2a9 std::_Rb_tree<>::_M_erase()
#2 0x278eedd std::_Rb_tree<>::clear()
#3 0x278eb5a std::_Rb_tree<>::_M_erase_aux()
#4 0x278e90d std::_Rb_tree<>::erase()
#5 0x278e4d4 std::_Rb_tree<>::erase()
#6 0x274ac06 (anonymous
namespace)::OpaqueValueEvaluation::~OpaqueValueEvaluation()
#7 0x27705c4 (anonymous
namespace)::ExprEvaluatorBase<>::VisitBinaryConditionalOperator()
#8 0x2739cfc clang::StmtVisitorBase<>::Visit()
#9 0x2774e4c (anonymous namespace)::ExprEvaluatorBase<>::VisitParenExpr()
#10 0x273a96e clang::StmtVisitorBase<>::Visit()
#11 0x277dd16 (anonymous
namespace)::ExprEvaluatorBase<>::HandleConditionalOperator<>()
#12 0x2770798 (anonymous
namespace)::ExprEvaluatorBase<>::VisitConditionalOperator()
#13 0x273a41b clang::StmtVisitorBase<>::Visit()
#14 0x2738e65 Evaluate()
#15 0x2738899 EvaluateStmt()
#16 0x273886b EvaluateStmt()
#17 0x2737bb1 HandleFunctionCall()
#18 0x277822e (anonymous namespace)::ExprEvaluatorBase<>::VisitCallExpr()
#19 0x2773926 (anonymous namespace)::IntExprEvaluator::VisitCallExpr()
#20 0x273a604 clang::StmtVisitorBase<>::Visit()
#21 0x2738e65 Evaluate()
#22 0x274aefa (anonymous
namespace)::OpaqueValueEvaluation::OpaqueValueEvaluation()
#23 0x27705a1 (anonymous
namespace)::ExprEvaluatorBase<>::VisitBinaryConditionalOperator()
#24 0x2739cfc clang::StmtVisitorBase<>::Visit()
#25 0x2774e4c (anonymous namespace)::ExprEvaluatorBase<>::VisitParenExpr()
#26 0x273a96e clang::StmtVisitorBase<>::Visit()
#27 0x277dd16 (anonymous
namespace)::ExprEvaluatorBase<>::HandleConditionalOperator<>()
#28 0x2770798 (anonymous
namespace)::ExprEvaluatorBase<>::VisitConditionalOperator()
#29 0x273a41b clang::StmtVisitorBase<>::Visit()
previously allocated by thread T0 here:
#0 0x3e2cac2 operator new()
#1 0x2790aef _ZNSt8_Rb_treeIPKN5clang15OpaqueValueExprESt4pairIKS3_NS0_7APValueEESt10_Select1stIS7_ESt4lessIS3_ESaIS7_EE14_M_create_nodeIJS4_IS3_S6_EEEEPSt13_Rb_tree_nodeIS7_EDpOT_
#2 0x279022a std::_Rb_tree<>::_M_insert_<>()
#3 0x27904ee std::_Rb_tree<>::_M_insert_unique<>()
#4 0x279008e std::_Rb_tree<>::_M_insert_unique_<>()
#5 0x278f8e2 std::map<>::operator[]()
#6 0x274aeec (anonymous
namespace)::OpaqueValueEvaluation::OpaqueValueEvaluation()
#7 0x27705a1 (anonymous
namespace)::ExprEvaluatorBase<>::VisitBinaryConditionalOperator()
#8 0x2739cfc clang::StmtVisitorBase<>::Visit()
#9 0x2774e4c (anonymous namespace)::ExprEvaluatorBase<>::VisitParenExpr()
#10 0x273a96e clang::StmtVisitorBase<>::Visit()
#11 0x277dd16 (anonymous
namespace)::ExprEvaluatorBase<>::HandleConditionalOperator<>()
#12 0x2770798 (anonymous
namespace)::ExprEvaluatorBase<>::VisitConditionalOperator()
#13 0x273a41b clang::StmtVisitorBase<>::Visit()
#14 0x2738e65 Evaluate()
#15 0x2738899 EvaluateStmt()
#16 0x273886b EvaluateStmt()
#17 0x2737bb1 HandleFunctionCall()
#18 0x277822e (anonymous namespace)::ExprEvaluatorBase<>::VisitCallExpr()
#19 0x2773926 (anonymous namespace)::IntExprEvaluator::VisitCallExpr()
#20 0x273a604 clang::StmtVisitorBase<>::Visit()
#21 0x2738e65 Evaluate()
#22 0x277abd2 (anonymous
namespace)::DataRecursiveIntBinOpEvaluator::EvaluateExpr()
#23 0x277aaba (anonymous namespace)::DataRecursiveIntBinOpEvaluator::process()
==21931== ABORTING
On Mon, Jun 25, 2012 at 2:21 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
> Author: efriedma
> Date: Mon Jun 25 16:21:08 2012
> New Revision: 159161
>
> URL: http://llvm.org/viewvc/llvm-project?rev=159161&view=rev
> Log:
> Use std::map instead of llvm::DenseMap because we rely on the stability of references to values in these maps. PR13197.
>
>
> Added:
> cfe/trunk/test/SemaCXX/constexpr-many-arguments.cpp
> Modified:
> cfe/trunk/lib/AST/ExprConstant.cpp
>
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=159161&r1=159160&r2=159161&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Jun 25 16:21:08 2012
> @@ -287,7 +287,9 @@
> /// parameters' function scope indices.
> const APValue *Arguments;
>
> - typedef llvm::DenseMap<const Expr*, APValue> MapTy;
> + // Note that we intentionally use std::map here so that references to
> + // values are stable.
> + typedef std::map<const Expr*, APValue> MapTy;
> typedef MapTy::const_iterator temp_iterator;
> /// Temporaries - Temporary lvalues materialized within this stack frame.
> MapTy Temporaries;
> @@ -361,7 +363,9 @@
> /// NextCallIndex - The next call index to assign.
> unsigned NextCallIndex;
>
> - typedef llvm::DenseMap<const OpaqueValueExpr*, APValue> MapTy;
> + // Note that we intentionally use std::map here so that references
> + // to values are stable.
> + typedef std::map<const OpaqueValueExpr*, APValue> MapTy;
> /// OpaqueValues - Values used as the common expression in a
> /// BinaryConditionalOperator.
> MapTy OpaqueValues;
>
> Added: cfe/trunk/test/SemaCXX/constexpr-many-arguments.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constexpr-many-arguments.cpp?rev=159161&view=auto
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/constexpr-many-arguments.cpp (added)
> +++ cfe/trunk/test/SemaCXX/constexpr-many-arguments.cpp Mon Jun 25 16:21:08 2012
> @@ -0,0 +1,42 @@
> +// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s
> +// PR13197
> +
> +struct type1
> +{
> + constexpr type1(int a0) : my_data{a0} {}
> + int my_data[1];
> +};
> +
> +struct type2
> +{
> + typedef type1 T;
> + constexpr type2(T a00, T a01, T a02, T a03, T a04, T a05, T a06, T a07, T a08, T a09,
> + T a10, T a11, T a12, T a13, T a14, T a15, T a16, T a17, T a18, T a19,
> + T a20, T a21, T a22)
> + : my_data{a00, a01, a02, a03, a04, a05, a06, a07, a08, a09,
> + a10, a11, a12, a13, a14, a15, a16, a17, a18, a19,
> + a20, a21, a22}
> + {}
> + type1 my_data[23];
> +};
> +
> +struct type3
> +{
> + constexpr type3(type2 a0, type2 a1) : my_data{a0, a1} {}
> + type2 my_data[2];
> +};
> +
> +constexpr type3 g
> +{
> + {
> + {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},
> + {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},
> + {0},{0},{0}
> + },
> + {
> + {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},
> + {0},{0},{0},{0},{0},{0},{0},{0},{0},{0},
> + {0},{0},{0}
> + }
> +};
> +
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list