<div dir="ltr">Thanks for the revert; looks like there was another bug in the interaction of lambdas an UBSan 'this' sanitization that was exposed by this (the lambda static invoker calls the operator() with a null this pointer, and the sanitizer doesn't know that's actually OK). Should be fixed in r311695.</div><div class="gmail_extra"><br><div class="gmail_quote">On 24 August 2017 at 11:20, Adrian Prantl via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I temporarily reverted the commit in r311680 to get the bots going again.<br>
<br>
-- adrian<br>
<div class="HOEnZb"><div class="h5"><br>
> On Aug 24, 2017, at 11:12 AM, Adrian Prantl via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br>
><br>
> It looks like this broke / found errors on the green dragon bot:<br>
><br>
> <a href="http://green.lab.llvm.org/green/job/clang-stage2-cmake-RgSan_check/4115/consoleFull#15752874848254eaf0-7326-4999-85b0-388101f2d404" rel="noreferrer" target="_blank">http://green.lab.llvm.org/<wbr>green/job/clang-stage2-cmake-<wbr>RgSan_check/4115/consoleFull#<wbr>15752874848254eaf0-7326-4999-<wbr>85b0-388101f2d404</a><br>
><br>
> ******************** TEST 'LLVM-Unit :: ADT/./ADTTests/<wbr>FilterIteratorTest.<wbr>FunctionPointer' FAILED ********************<br>
><br>
> Note: Google Test filter = FilterIteratorTest.<wbr>FunctionPointer<br>
> [==========] Running 1 test from 1 test case.<br>
> [----------] Global test environment set-up.<br>
> [----------] 1 test from FilterIteratorTest<br>
> [ RUN      ] FilterIteratorTest.<wbr>FunctionPointer<br>
> /Users/buildslave/jenkins/<wbr>sharedspace/clang-stage2-<wbr>cmake-RgSan@2/llvm/unittests/<wbr>ADT/IteratorTest.cpp:160:24: runtime error: load of null pointer of type 'const (lambda at /Users/buildslave/jenkins/<wbr>sharedspace/clang-stage2-<wbr>cmake-RgSan@2/llvm/unittests/<wbr>ADT/IteratorTest.cpp:160:24) *'<br>
> SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/buildslave/jenkins/<wbr>sharedspace/clang-stage2-<wbr>cmake-RgSan@2/llvm/unittests/<wbr>ADT/IteratorTest.cpp:160:24 in<br>
><br>
> ********************<br>
><br>
> -- adrian<br>
>> On Aug 23, 2017, at 12:39 PM, Richard Smith via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br>
>><br>
>> Author: rsmith<br>
>> Date: Wed Aug 23 12:39:04 2017<br>
>> New Revision: 311589<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=311589&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=311589&view=rev</a><br>
>> Log:<br>
>> [ubsan] PR34266: When sanitizing the 'this' value for a member function that happens to be a lambda call operator, use the lambda's 'this' pointer, not the captured enclosing 'this' pointer (if any).<br>
>><br>
>> Modified:<br>
>>   cfe/trunk/include/clang/AST/<wbr>DeclCXX.h<br>
>>   cfe/trunk/lib/CodeGen/<wbr>CodeGenFunction.cpp<br>
>>   cfe/trunk/test/CodeGenCXX/<wbr>catch-undef-behavior.cpp<br>
>><br>
>> Modified: cfe/trunk/include/clang/AST/<wbr>DeclCXX.h<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=311589&r1=311588&r2=311589&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/AST/DeclCXX.h?rev=<wbr>311589&r1=311588&r2=311589&<wbr>view=diff</a><br>
>> ==============================<wbr>==============================<wbr>==================<br>
>> --- cfe/trunk/include/clang/AST/<wbr>DeclCXX.h (original)<br>
>> +++ cfe/trunk/include/clang/AST/<wbr>DeclCXX.h Wed Aug 23 12:39:04 2017<br>
>> @@ -2027,7 +2027,10 @@ public:<br>
>><br>
>>  /// \brief Returns the type of the \c this pointer.<br>
>>  ///<br>
>> -  /// Should only be called for instance (i.e., non-static) methods.<br>
>> +  /// Should only be called for instance (i.e., non-static) methods. Note<br>
>> +  /// that for the call operator of a lambda closure type, this returns the<br>
>> +  /// desugared 'this' type (a pointer to the closure type), not the captured<br>
>> +  /// 'this' type.<br>
>>  QualType getThisType(ASTContext &C) const;<br>
>><br>
>>  unsigned getTypeQualifiers() const {<br>
>><br>
>> Modified: cfe/trunk/lib/CodeGen/<wbr>CodeGenFunction.cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=311589&r1=311588&r2=311589&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/CodeGen/<wbr>CodeGenFunction.cpp?rev=<wbr>311589&r1=311588&r2=311589&<wbr>view=diff</a><br>
>> ==============================<wbr>==============================<wbr>==================<br>
>> --- cfe/trunk/lib/CodeGen/<wbr>CodeGenFunction.cpp (original)<br>
>> +++ cfe/trunk/lib/CodeGen/<wbr>CodeGenFunction.cpp Wed Aug 23 12:39:04 2017<br>
>> @@ -1014,11 +1014,11 @@ void CodeGenFunction::<wbr>StartFunction(Glob<br>
>>    }<br>
>><br>
>>    // Check the 'this' pointer once per function, if it's available.<br>
>> -    if (CXXThisValue) {<br>
>> +    if (CXXABIThisValue) {<br>
>>      SanitizerSet SkippedChecks;<br>
>>      SkippedChecks.set(<wbr>SanitizerKind::ObjectSize, true);<br>
>>      QualType ThisTy = MD->getThisType(getContext());<br>
>> -      EmitTypeCheck(TCK_Load, Loc, CXXThisValue, ThisTy,<br>
>> +      EmitTypeCheck(TCK_Load, Loc, CXXABIThisValue, ThisTy,<br>
>>                    getContext().<wbr>getTypeAlignInChars(ThisTy-><wbr>getPointeeType()),<br>
>>                    SkippedChecks);<br>
>>    }<br>
>><br>
>> Modified: cfe/trunk/test/CodeGenCXX/<wbr>catch-undef-behavior.cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp?rev=311589&r1=311588&r2=311589&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/<wbr>CodeGenCXX/catch-undef-<wbr>behavior.cpp?rev=311589&r1=<wbr>311588&r2=311589&view=diff</a><br>
>> ==============================<wbr>==============================<wbr>==================<br>
>> --- cfe/trunk/test/CodeGenCXX/<wbr>catch-undef-behavior.cpp (original)<br>
>> +++ cfe/trunk/test/CodeGenCXX/<wbr>catch-undef-behavior.cpp Wed Aug 23 12:39:04 2017<br>
>> @@ -449,6 +449,27 @@ void upcast_to_vbase() {<br>
>> }<br>
>> }<br>
>><br>
>> +struct ThisAlign {<br>
>> +  void this_align_lambda();<br>
>> +};<br>
>> +void ThisAlign::this_align_lambda() {<br>
>> +  // CHECK-LABEL: define {{.*}}@"_ZZN9ThisAlign17this_<wbr>align_lambdaEvENK3$_0clEv"<br>
>> +  // CHECK-SAME: (%{{.*}}* %[[this:[^)]*]])<br>
>> +  // CHECK: %[[this_addr:.*]] = alloca<br>
>> +  // CHECK: store %{{.*}}* %[[this]], %{{.*}}** %[[this_addr]],<br>
>> +  // CHECK: %[[this_inner:.*]] = load %{{.*}}*, %{{.*}}** %[[this_addr]],<br>
>> +  // CHECK: %[[this_outer_addr:.*]] = getelementptr inbounds %{{.*}}, %{{.*}}* %[[this_inner]], i32 0, i32 0<br>
>> +  // CHECK: %[[this_outer:.*]] = load %{{.*}}*, %{{.*}}** %[[this_outer_addr]],<br>
>> +  //<br>
>> +  // CHECK: %[[this_inner_isnonnull:.*]] = icmp ne %{{.*}}* %[[this_inner]], null<br>
>> +  // CHECK: %[[this_inner_asint:.*]] = ptrtoint %{{.*}}* %[[this_inner]] to i<br>
>> +  // CHECK: %[[this_inner_misalignment:.*]<wbr>] = and i{{32|64}} %[[this_inner_asint]], {{3|7}},<br>
>> +  // CHECK: %[[this_inner_isaligned:.*]] = icmp eq i{{32|64}} %[[this_inner_misalignment]], 0<br>
>> +  // CHECK: %[[this_inner_valid:.*]] = and i1 %[[this_inner_isnonnull]], %[[this_inner_isaligned]],<br>
>> +  // CHECK: br i1 %[[this_inner_valid:.*]]<br>
>> +  [&] { return this; } ();<br>
>> +}<br>
>> +<br>
>> namespace CopyValueRepresentation {<br>
>>  // CHECK-LABEL: define {{.*}} @_<wbr>ZN23CopyValueRepresentation2S3<wbr>aSERKS0_<br>
>>  // CHECK-NOT: call {{.*}} @__ubsan_handle_load_invalid_<wbr>value<br>
>><br>
>><br>
>> ______________________________<wbr>_________________<br>
>> cfe-commits mailing list<br>
>> <a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
><br>
> ______________________________<wbr>_________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div>