[compiler-rt] r317723 - [ThinLTO] Ensure sanitizer passes are run

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 8 13:44:20 PST 2017


Thanks, somehow I completely missed that. Will fix.

Teresa

On Wed, Nov 8, 2017 at 1:06 PM, Peter Collingbourne <peter at pcc.me.uk> wrote:

> This isn't enough. As I mentioned in the review comment, you need to check
> that LTO is available.
>
> Peter
>
> On Wed, Nov 8, 2017 at 12:27 PM, Teresa Johnson via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> Author: tejohnson
>> Date: Wed Nov  8 12:27:28 2017
>> New Revision: 317723
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=317723&view=rev
>> Log:
>> [ThinLTO] Ensure sanitizer passes are run
>>
>> Recommit new test as linux-only.
>>
>> Added:
>>     compiler-rt/trunk/test/asan/TestCases/Linux/contiguous_conta
>> iner_crash_thinlto.cc
>>
>> Added: compiler-rt/trunk/test/asan/TestCases/Linux/contiguous_conta
>> iner_crash_thinlto.cc
>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/
>> asan/TestCases/Linux/contiguous_container_crash_thinlto.cc?
>> rev=317723&view=auto
>> ============================================================
>> ==================
>> --- compiler-rt/trunk/test/asan/TestCases/Linux/contiguous_container_crash_thinlto.cc
>> (added)
>> +++ compiler-rt/trunk/test/asan/TestCases/Linux/contiguous_container_crash_thinlto.cc
>> Wed Nov  8 12:27:28 2017
>> @@ -0,0 +1,53 @@
>> +// RUN: %clangxx_asan -flto=thin -O %s -o %t.thinlto
>> +// RUN: not %run %t.thinlto crash 2>&1 | FileCheck
>> --check-prefix=CHECK-CRASH %s
>> +// RUN: not %run %t.thinlto bad-bounds 2>&1 | FileCheck
>> --check-prefix=CHECK-BAD-BOUNDS %s
>> +// RUN: not %run %t.thinlto bad-alignment 2>&1 | FileCheck
>> --check-prefix=CHECK-BAD-ALIGNMENT %s
>> +// RUN: %env_asan_opts=detect_container_overflow=0 %run %t.thinlto crash
>> +//
>> +// Test crash due to __sanitizer_annotate_contiguous_container.
>> +
>> +#include <assert.h>
>> +#include <string.h>
>> +
>> +extern "C" {
>> +void __sanitizer_annotate_contiguous_container(const void *beg, const
>> void *end,
>> +                                               const void *old_mid,
>> +                                               const void *new_mid);
>> +}  // extern "C"
>> +
>> +static volatile int one = 1;
>> +
>> +int TestCrash() {
>> +  long t[100];
>> +  t[60] = 0;
>> +  __sanitizer_annotate_contiguous_container(&t[0], &t[0] + 100, &t[0] +
>> 100,
>> +                                            &t[0] + 50);
>> +// CHECK-CRASH: AddressSanitizer: container-overflow
>> +// CHECK-CRASH: if you don't care about these errors you may set
>> ASAN_OPTIONS=detect_container_overflow=0
>> +  return (int)t[60 * one];  // Touches the poisoned memory.
>> +}
>> +
>> +void BadBounds() {
>> +  long t[100];
>> +// CHECK-BAD-BOUNDS: ERROR: AddressSanitizer: bad parameters to
>> __sanitizer_annotate_contiguous_container
>> +  __sanitizer_annotate_contiguous_container(&t[0], &t[0] + 100, &t[0] +
>> 101,
>> +                                            &t[0] + 50);
>> +}
>> +
>> +void BadAlignment() {
>> +  int t[100];
>> +// CHECK-BAD-ALIGNMENT: ERROR: AddressSanitizer: bad parameters to
>> __sanitizer_annotate_contiguous_container
>> +// CHECK-BAD-ALIGNMENT: ERROR: beg is not aligned by 8
>> +  __sanitizer_annotate_contiguous_container(&t[1], &t[0] + 100, &t[1] +
>> 10,
>> +                                            &t[0] + 50);
>> +}
>> +
>> +int main(int argc, char **argv) {
>> +  assert(argc == 2);
>> +  if (!strcmp(argv[1], "crash"))
>> +    return TestCrash();
>> +  else if (!strcmp(argv[1], "bad-bounds"))
>> +    BadBounds();
>> +  else if (!strcmp(argv[1], "bad-alignment"))
>> +    BadAlignment();
>> +}
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>
>
> --
> --
> Peter
>



-- 
Teresa Johnson |  Software Engineer |  tejohnson at google.com |  408-460-2413
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171108/73b4f7b6/attachment.html>


More information about the llvm-commits mailing list