[compiler-rt] r203916 - [ASan] Fix https://code.google.com/p/address-sanitizer/issues/detail?id=274
Alexander Potapenko
glider at google.com
Fri Mar 14 03:41:49 PDT 2014
Author: glider
Date: Fri Mar 14 05:41:49 2014
New Revision: 203916
URL: http://llvm.org/viewvc/llvm-project?rev=203916&view=rev
Log:
[ASan] Fix https://code.google.com/p/address-sanitizer/issues/detail?id=274
by ignoring globals from __TEXT,__cstring,cstring_literals during instrumenation.
Add a regression test.
Added:
compiler-rt/trunk/test/asan/TestCases/Darwin/cstring_literals_regtest.mm (with props)
Modified:
compiler-rt/trunk/test/asan/lit.cfg
Added: compiler-rt/trunk/test/asan/TestCases/Darwin/cstring_literals_regtest.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Darwin/cstring_literals_regtest.mm?rev=203916&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Darwin/cstring_literals_regtest.mm (added)
+++ compiler-rt/trunk/test/asan/TestCases/Darwin/cstring_literals_regtest.mm Fri Mar 14 05:41:49 2014
@@ -0,0 +1,23 @@
+// Regression test for
+// https://code.google.com/p/address-sanitizer/issues/detail?id=274.
+
+// RUN: %clang_asan %s -framework Foundation -o %t
+// RUN: %t 2>&1 | FileCheck %s
+#import <Foundation/Foundation.h>
+
+#include <stdio.h>
+
+int main() {
+ NSString* version_file = @"MAJOR=35\n";
+ int major = 0, minor = 0, build = 0, patch = 0;
+ NSScanner* scanner = [NSScanner scannerWithString:version_file];
+ NSString *res = nil;
+ if ([scanner scanString:@"MAJOR=" intoString:nil] &&
+ [scanner scanInt:&major]) {
+ res = [NSString stringWithFormat:@"%d.%d.%d.%d",
+ major, minor, build, patch];
+ }
+ printf("%s\n", [res UTF8String]);
+ // CHECK: 35.0.0.0
+ return 0;
+}
Propchange: compiler-rt/trunk/test/asan/TestCases/Darwin/cstring_literals_regtest.mm
------------------------------------------------------------------------------
svn:eol-style = LF
Modified: compiler-rt/trunk/test/asan/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/lit.cfg?rev=203916&r1=203915&r2=203916&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/lit.cfg (original)
+++ compiler-rt/trunk/test/asan/lit.cfg Fri Mar 14 05:41:49 2014
@@ -81,6 +81,9 @@ if config.compiler_id == 'GNU':
# Default test suffixes.
config.suffixes = ['.c', '.cc', '.cpp']
+if config.host_os == 'Darwin':
+ config.suffixes.append('.mm')
+
# AddressSanitizer tests are currently supported on Linux and Darwin only.
if config.host_os not in ['Linux', 'Darwin']:
config.unsupported = True
More information about the llvm-commits
mailing list