[compiler-rt] r225234 - [ubsan] partially enable -fsanitize-coverage=N with ubsan. It will work as usual in most cases but will not dump coverage on error with -fno-sanitize-recover (that'll be a separate fix)

Steven Wu stevenwu at apple.com
Tue Jan 6 10:52:47 PST 2015


Thanks! Let me know if you need any help to figure out the problem.

Steven

> On Jan 6, 2015, at 10:51 AM, Kostya Serebryany <kcc at google.com> wrote:
> 
> r225281 marks the test as XFAIL: darwin, hopefully it should fix the bot. 
> We'll investigate what's wrong with the test on OSX a bit later
> Sorry for the breakage. 
> 
> --kcc
> 
> On Tue, Jan 6, 2015 at 10:36 AM, Kostya Serebryany <kcc at google.com <mailto:kcc at google.com>> wrote:
> Looking... 
> 
> On Tue, Jan 6, 2015 at 9:01 AM, Steven Wu <stevenwu at apple.com <mailto:stevenwu at apple.com>> wrote:
> Hi Kostya
> 
> The test cases you added broke the jenkins: http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA_check/533/consoleFull#19223059818254eaf0-7326-4999-85b0-388101f2d404 <http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA_check/533/consoleFull#19223059818254eaf0-7326-4999-85b0-388101f2d404>
> Can you take a look at it? If you can quickly fix it or revert it, it will be great.
> 
> Thanks
> 
> Steven
> 
>> On Jan 5, 2015, at 5:31 PM, Kostya Serebryany <kcc at google.com <mailto:kcc at google.com>> wrote:
>> 
>> Author: kcc
>> Date: Mon Jan  5 19:31:23 2015
>> New Revision: 225234
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=225234&view=rev <http://llvm.org/viewvc/llvm-project?rev=225234&view=rev>
>> Log:
>> [ubsan] partially enable -fsanitize-coverage=N with ubsan. It will work as usual in most cases but will not dump coverage on error with -fno-sanitize-recover (that'll be a separate fix)
>> 
>> Added:
>>    compiler-rt/trunk/test/ubsan/TestCases/Misc/coverage-levels.cc <http://coverage-levels.cc/>
>> Modified:
>>    compiler-rt/trunk/lib/ubsan/ubsan_init.cc
>> 
>> Modified: compiler-rt/trunk/lib/ubsan/ubsan_init.cc
>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/ubsan_init.cc?rev=225234&r1=225233&r2=225234&view=diff <http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/ubsan_init.cc?rev=225234&r1=225233&r2=225234&view=diff>
>> ==============================================================================
>> --- compiler-rt/trunk/lib/ubsan/ubsan_init.cc (original)
>> +++ compiler-rt/trunk/lib/ubsan/ubsan_init.cc Mon Jan  5 19:31:23 2015
>> @@ -43,6 +43,7 @@ void __ubsan::InitIfNecessary() {
>>   // Initialize UBSan-specific flags.
>>   InitializeFlags();
>>   SuppressionContext::InitIfNecessary();
>> +  InitializeCoverage(common_flags()->coverage, common_flags()->coverage_dir);
>>   ubsan_inited = true;
>> }
>> 
>> 
>> Added: compiler-rt/trunk/test/ubsan/TestCases/Misc/coverage-levels.cc <http://coverage-levels.cc/>
>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Misc/coverage-levels.cc?rev=225234&view=auto <http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/TestCases/Misc/coverage-levels.cc?rev=225234&view=auto>
>> ==============================================================================
>> --- compiler-rt/trunk/test/ubsan/TestCases/Misc/coverage-levels.cc <http://coverage-levels.cc/> (added)
>> +++ compiler-rt/trunk/test/ubsan/TestCases/Misc/coverage-levels.cc <http://coverage-levels.cc/> Mon Jan  5 19:31:23 2015
>> @@ -0,0 +1,36 @@
>> +// Test various levels of coverage
>> +//
>> +// RUN: mkdir -p %T/coverage-levels
>> +// RUN: OPT=coverage=1:verbosity=1:coverage_dir=%T/coverage-levels
>> +// RUN: %clangxx -fsanitize=shift                        -DGOOD_SHIFT=1 -O1 -fsanitize-coverage=1  %s -o %t
>> +// RUN: UBSAN_OPTIONS=$OPT ASAN_OPTIONS=$OPT %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_NOWARN
>> +// RUN: %clangxx -fsanitize=undefined                    -DGOOD_SHIFT=1 -O1 -fsanitize-coverage=1  %s -o %t
>> +// RUN: UBSAN_OPTIONS=$OPT ASAN_OPTIONS=$OPT %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_NOWARN
>> +
>> +// RUN: %clangxx -fsanitize=shift -O1 -fsanitize-coverage=1  %s -o %t
>> +// RUN: UBSAN_OPTIONS=$OPT ASAN_OPTIONS=$OPT %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_WARN
>> +// RUN: %clangxx -fsanitize=shift -O1 -fsanitize-coverage=2  %s -o %t
>> +// RUN: UBSAN_OPTIONS=$OPT ASAN_OPTIONS=$OPT %run %t 2>&1 | FileCheck %s --check-prefix=CHECK2 --check-prefix=CHECK_WARN
>> +// RUN: %clangxx -fsanitize=shift -O1 -fsanitize-coverage=3  %s -o %t
>> +// RUN: UBSAN_OPTIONS=$OPT ASAN_OPTIONS=$OPT %run %t 2>&1 | FileCheck %s --check-prefix=CHECK3 --check-prefix=CHECK_WARN
>> +
>> +volatile int sink;
>> +int main(int argc, char **argv) {
>> +  int shift = argc * 32;
>> +#if GOOD_SHIFT
>> +  shift = 3;
>> +#endif
>> +  if ((argc << shift) == 16)  // False.
>> +    return 1;
>> +  return 0;
>> +}
>> +
>> +// CHECK_WARN: shift exponent 32 is too large
>> +// CHECK_NOWARN-NOT: ERROR
>> +// FIXME: Currently, coverage instrumentation kicks in after ubsan, so we get
>> +// more than the minimal number of instrumented blocks.
>> +// FIXME: Currently, ubsan with -fno-sanitize-recover and w/o asan will fail
>> +// to dump coverage.
>> +// CHECK1:  1 PCs written
>> +// CHECK2:  3 PCs written
>> +// CHECK3:  4 PCs written
>> 
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu <mailto:llvm-commits at cs.uiuc.edu>
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits <http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits>
> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150106/4a4587d3/attachment.html>


More information about the llvm-commits mailing list