Skip to content

Commit 8ed2928

Browse files
committedMar 30, 2017
[asan] Support line numbers in StackVarDescr
When -fsanitize-address-use-after-scope is used, the instrumentation produces line numbers in stack frame descriptions. This patch make sure the ASan runtime supports this format (ParseFrameDescription needs to be able to parse "varname:line") and prepares lit tests to allow line numbers in ASan report output. Differential Revision: https://reviews.llvm.org/D31484 llvm-svn: 299043
1 parent 51c1365 commit 8ed2928

32 files changed

+63
-51
lines changed
 

‎compiler-rt/lib/asan/asan_descriptions.cc

+3
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ static void PrintAccessAndVarIntersection(const StackVarDescr &var, uptr addr,
252252
str.append("%c", var.name_pos[i]);
253253
}
254254
str.append("'");
255+
if (var.line > 0) {
256+
str.append(" (line %d)", var.line);
257+
}
255258
if (pos_descr) {
256259
Decorator d;
257260
// FIXME: we may want to also print the size of the access here,

‎compiler-rt/lib/asan/asan_report.cc

+10-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ bool ParseFrameDescription(const char *frame_descr,
8888
char *p;
8989
// This string is created by the compiler and has the following form:
9090
// "n alloc_1 alloc_2 ... alloc_n"
91-
// where alloc_i looks like "offset size len ObjectName".
91+
// where alloc_i looks like "offset size len ObjectName"
92+
// or "offset size len ObjectName:line".
9293
uptr n_objects = (uptr)internal_simple_strtoll(frame_descr, &p, 10);
9394
if (n_objects == 0)
9495
return false;
@@ -101,7 +102,14 @@ bool ParseFrameDescription(const char *frame_descr,
101102
return false;
102103
}
103104
p++;
104-
StackVarDescr var = {beg, size, p, len};
105+
char *colon_pos = internal_strchr(p, ':');
106+
uptr line = 0;
107+
uptr name_len = len;
108+
if (colon_pos != nullptr && colon_pos < p + len) {
109+
name_len = colon_pos - p;
110+
line = (uptr)internal_simple_strtoll(colon_pos + 1, nullptr, 10);
111+
}
112+
StackVarDescr var = {beg, size, p, name_len, line};
105113
vars->push_back(var);
106114
p += len;
107115
}

‎compiler-rt/lib/asan/asan_report.h

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ struct StackVarDescr {
2323
uptr size;
2424
const char *name_pos;
2525
uptr name_len;
26+
uptr line;
2627
};
2728

2829
// Returns the number of globals close to the provided address and copies

‎compiler-rt/test/asan/TestCases/Linux/memmem_test.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ int main(int argc, char **argv) {
1515
// A1: AddressSanitizer: stack-buffer-overflow
1616
// A1: {{#0.*memmem}}
1717
// A1-NEXT: {{#1.*main}}
18-
// A1: 'a1' <== Memory access at offset
18+
// A1: 'a1'{{.*}} <== Memory access at offset
1919
//
2020
// A2: AddressSanitizer: stack-buffer-overflow
2121
// A2: {{#0.*memmem}}
22-
// A2: 'a2' <== Memory access at offset
22+
// A2: 'a2'{{.*}} <== Memory access at offset
2323
return res == NULL;
2424
}

‎compiler-rt/test/asan/TestCases/Posix/stack-use-after-return.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ void Func2(char *x) {
5353
// CHECK: WRITE of size 1 {{.*}} thread T0
5454
// CHECK: #0{{.*}}Func2{{.*}}stack-use-after-return.cc:[[@LINE-2]]
5555
// CHECK: is located in stack of thread T0 at offset
56-
// CHECK: 'local' <== Memory access at offset {{16|32}} is inside this variable
56+
// CHECK: 'local'{{.*}} <== Memory access at offset {{16|32}} is inside this variable
5757
// THREAD: WRITE of size 1 {{.*}} thread T{{[1-9]}}
5858
// THREAD: #0{{.*}}Func2{{.*}}stack-use-after-return.cc:[[@LINE-6]]
5959
// THREAD: is located in stack of thread T{{[1-9]}} at offset
60-
// THREAD: 'local' <== Memory access at offset {{16|32}} is inside this variable
60+
// THREAD: 'local'{{.*}} <== Memory access at offset {{16|32}} is inside this variable
6161
// CHECK-20: T0: FakeStack created:{{.*}} stack_size_log: 20
6262
// CHECK-24: T0: FakeStack created:{{.*}} stack_size_log: 24
6363
}

‎compiler-rt/test/asan/TestCases/Windows/dll_intercept_memchr.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ int test_function() {
2222
// CHECK-NEXT: test_function {{.*}}dll_intercept_memchr.cc:[[@LINE-5]]
2323
// CHECK: Address [[ADDR]] is located in stack of thread T0 at offset {{.*}} in frame
2424
// CHECK-NEXT: test_function {{.*}}dll_intercept_memchr.cc
25-
// CHECK: 'buff' <== Memory access at offset {{.*}} overflows this variable
25+
// CHECK: 'buff'{{.*}} <== Memory access at offset {{.*}} overflows this variable
2626
return 0;
2727
}

‎compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ int test_function() {
2727
// CHECK-NEXT: test_function {{.*}}dll_intercept_memcpy.cc:[[@LINE-4]]
2828
// CHECK: Address [[ADDR]] is located in stack of thread T0 at offset {{.*}} in frame
2929
// CHECK-NEXT: test_function {{.*}}dll_intercept_memcpy.cc
30-
// CHECK: 'buff2' <== Memory access at offset {{.*}} overflows this variable
30+
// CHECK: 'buff2'{{.*}} <== Memory access at offset {{.*}} overflows this variable
3131
return 0;
3232
}

‎compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy_indirect.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ int test_function() {
2929
// CHECK-NEXT: test_function {{.*}}dll_intercept_memcpy_indirect.cc:[[@LINE-5]]
3030
// CHECK: Address [[ADDR]] is located in stack of thread T0 at offset {{.*}} in frame
3131
// CHECK-NEXT: test_function {{.*}}dll_intercept_memcpy_indirect.cc
32-
// CHECK: 'buff2' <== Memory access at offset {{.*}} overflows this variable
32+
// CHECK: 'buff2'{{.*}} <== Memory access at offset {{.*}} overflows this variable
3333
return 0;
3434
}

‎compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ int test_function() {
2727
// CHECK-NEXT: test_function {{.*}}dll_intercept_memset.cc:[[@LINE-4]]
2828
// CHECK: Address [[ADDR]] is located in stack of thread T0 at offset {{.*}} in frame
2929
// CHECK-NEXT: test_function {{.*}}dll_intercept_memset.cc
30-
// CHECK: 'buff' <== Memory access at offset {{.*}} overflows this variable
30+
// CHECK: 'buff'{{.*}} <== Memory access at offset {{.*}} overflows this variable
3131
return 0;
3232
}

‎compiler-rt/test/asan/TestCases/Windows/dll_noreturn.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void noreturn_f() {
1717
//
1818
// CHECK: Address [[ADDR]] is located in stack of thread T0 at offset [[OFFSET:.*]] in frame
1919
// CHECK-NEXT: noreturn_f{{.*}}dll_noreturn.cc
20-
// CHECK: 'buffer' <== Memory access at offset [[OFFSET]] underflows this variable
20+
// CHECK: 'buffer'{{.*}} <== Memory access at offset [[OFFSET]] underflows this variable
2121
// CHECK-LABEL: SUMMARY
2222
}
2323

‎compiler-rt/test/asan/TestCases/Windows/dll_poison_unpoison.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ int test_function() {
3030
//
3131
// CHECK: [[ADDR]] is located in stack of thread T0 at offset [[OFFSET:.*]] in frame
3232
// CHECK-NEXT: test_function{{.*}}\dll_poison_unpoison.cc
33-
// CHECK: 'buffer' <== Memory access at offset [[OFFSET]] is inside this variable
33+
// CHECK: 'buffer'{{.*}} <== Memory access at offset [[OFFSET]] is inside this variable
3434
return 0;
3535
}

‎compiler-rt/test/asan/TestCases/Windows/dll_stack_use_after_return.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ int test_function() {
2222
//
2323
// CHECK: Address [[ADDR]] is located in stack of thread T0 at offset [[OFFSET:.*]] in frame
2424
// CHECK-NEXT: #0 {{.*}} foo{{.*}}dll_stack_use_after_return.cc
25-
// CHECK: 'stack_buffer' <== Memory access at offset [[OFFSET]] is inside this variable
25+
// CHECK: 'stack_buffer'{{.*}} <== Memory access at offset [[OFFSET]] is inside this variable
2626
return 0;
2727
}
2828

‎compiler-rt/test/asan/TestCases/Windows/dll_thread_stack_array_left_oob.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ DWORD WINAPI thread_proc(void *context) {
1616
// CHECK: Address [[ADDR]] is located in stack of thread T1 at offset [[OFFSET:.*]] in frame
1717
// CHECK-NEXT: thread_proc{{.*}}dll_thread_stack_array_left_oob.cc
1818
//
19-
// CHECK: 'stack_buffer' <== Memory access at offset [[OFFSET]] underflows this variable
19+
// CHECK: 'stack_buffer'{{.*}} <== Memory access at offset [[OFFSET]] underflows this variable
2020

2121
return 0;
2222
}

‎compiler-rt/test/asan/TestCases/Windows/intercept_memcpy.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ int main() {
2727
// CHECK-NEXT: main {{.*}}intercept_memcpy.cc:[[@LINE-5]]
2828
// CHECK: Address [[ADDR]] is located in stack of thread T0 at offset {{.*}} in frame
2929
// CHECK-NEXT: #0 {{.*}} main
30-
// CHECK: 'buff2' <== Memory access at offset {{.*}} overflows this variable
30+
// CHECK: 'buff2'{{.*}} <== Memory access at offset {{.*}} overflows this variable
3131
}

‎compiler-rt/test/asan/TestCases/Windows/intercept_strlen.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ int main() {
2222
// CHECK-NEXT: main {{.*}}intercept_strlen.cc:[[@LINE-5]]
2323
// CHECK: Address [[ADDR]] is located in stack of thread T0 at offset {{.*}} in frame
2424
// CHECK-NEXT: main {{.*}}intercept_strlen.cc
25-
// CHECK: 'str' <== Memory access at offset {{.*}} overflows this variable
25+
// CHECK: 'str'{{.*}} <== Memory access at offset {{.*}} overflows this variable
2626
return len < 6;
2727
}

‎compiler-rt/test/asan/TestCases/Windows/stack_array_left_oob.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ int main() {
1212
// CHECK-NEXT: {{#0 .* main .*stack_array_left_oob.cc}}:[[@LINE-3]]
1313
// CHECK: Address [[ADDR]] is located in stack of thread T0 at offset [[OFFSET:.*]] in frame
1414
// CHECK-NEXT: {{#0 .* main .*stack_array_left_oob.cc}}
15-
// CHECK: 'buffer' <== Memory access at offset [[OFFSET]] underflows this variable
15+
// CHECK: 'buffer'{{.*}} <== Memory access at offset [[OFFSET]] underflows this variable
1616
}

‎compiler-rt/test/asan/TestCases/Windows/stack_array_right_oob.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ int main() {
1212
// CHECK-NEXT: {{#0 .* main .*stack_array_right_oob.cc}}:[[@LINE-3]]
1313
// CHECK: Address [[ADDR]] is located in stack of thread T0 at offset [[OFFSET:.*]] in frame
1414
// CHECK-NEXT: {{#0 .* main .*stack_array_right_oob.cc}}
15-
// CHECK: 'buffer' <== Memory access at offset [[OFFSET]] overflows this variable
15+
// CHECK: 'buffer'{{.*}} <== Memory access at offset [[OFFSET]] overflows this variable
1616
}

‎compiler-rt/test/asan/TestCases/Windows/stack_use_after_return.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ int main() {
1818
// CHECK: is located in stack of thread T0 at offset [[OFFSET:.*]] in frame
1919
// CHECK-NEXT: {{#0 0x.* in foo.*stack_use_after_return.cc}}
2020
//
21-
// CHECK: 'stack_buffer' <== Memory access at offset [[OFFSET]] is inside this variable
21+
// CHECK: 'stack_buffer'{{.*}} <== Memory access at offset [[OFFSET]] is inside this variable
2222
}

‎compiler-rt/test/asan/TestCases/Windows/wrong_downcast_on_stack.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ int main(void) {
2020
// CHECK-NEXT: {{#0 0x[0-9a-f]* in main .*wrong_downcast_on_stack.cc}}:[[@LINE-3]]
2121
// CHECK: [[ADDR]] is located in stack of thread T0 at offset [[OFFSET:[0-9]+]] in frame
2222
// CHECK-NEXT: {{#0 0x[0-9a-f]* in main }}
23-
// CHECK: 'p' <== Memory access at offset [[OFFSET]] overflows this variable
23+
// CHECK: 'p'{{.*}} <== Memory access at offset [[OFFSET]] overflows this variable
2424
return 0;
2525
}
2626

‎compiler-rt/test/asan/TestCases/stack-buffer-overflow-with-position.cc

+12-12
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ int main(int argc, char **argv) {
3030
// make sure BBB and CCC are not removed;
3131
return *(short*)(p) + BBB[argc % 2] + CCC[argc % 2];
3232
}
33-
// CHECK-m2: 'AAA' <== {{.*}}underflows this variable
34-
// CHECK-m1: 'AAA' <== {{.*}}partially underflows this variable
35-
// CHECK-9: 'AAA' <== {{.*}}partially overflows this variable
36-
// CHECK-10: 'AAA' <== {{.*}}overflows this variable
37-
// CHECK-30: 'BBB' <== {{.*}}underflows this variable
38-
// CHECK-31: 'BBB' <== {{.*}}partially underflows this variable
39-
// CHECK-41: 'BBB' <== {{.*}}partially overflows this variable
40-
// CHECK-42: 'BBB' <== {{.*}}overflows this variable
41-
// CHECK-62: 'CCC' <== {{.*}}underflows this variable
42-
// CHECK-63: 'CCC' <== {{.*}}partially underflows this variable
43-
// CHECK-73: 'CCC' <== {{.*}}partially overflows this variable
44-
// CHECK-74: 'CCC' <== {{.*}}overflows this variable
33+
// CHECK-m2: 'AAA'{{.*}} <== {{.*}}underflows this variable
34+
// CHECK-m1: 'AAA'{{.*}} <== {{.*}}partially underflows this variable
35+
// CHECK-9: 'AAA'{{.*}} <== {{.*}}partially overflows this variable
36+
// CHECK-10: 'AAA'{{.*}} <== {{.*}}overflows this variable
37+
// CHECK-30: 'BBB'{{.*}} <== {{.*}}underflows this variable
38+
// CHECK-31: 'BBB'{{.*}} <== {{.*}}partially underflows this variable
39+
// CHECK-41: 'BBB'{{.*}} <== {{.*}}partially overflows this variable
40+
// CHECK-42: 'BBB'{{.*}} <== {{.*}}overflows this variable
41+
// CHECK-62: 'CCC'{{.*}} <== {{.*}}underflows this variable
42+
// CHECK-63: 'CCC'{{.*}} <== {{.*}}partially underflows this variable
43+
// CHECK-73: 'CCC'{{.*}} <== {{.*}}partially overflows this variable
44+
// CHECK-74: 'CCC'{{.*}} <== {{.*}}overflows this variable

‎compiler-rt/test/asan/TestCases/strcasestr-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ int main(int argc, char **argv) {
1919
char s1[4] = "abC";
2020
__asan_poison_memory_region ((char *)&s1[2], 2);
2121
r = strcasestr(s1, s2);
22-
// CHECK:'s1' <== Memory access at offset {{[0-9]+}} partially overflows this variable
22+
// CHECK:'s1'{{.*}} <== Memory access at offset {{[0-9]+}} partially overflows this variable
2323
assert(r == s1 + 2);
2424
return 0;
2525
}

‎compiler-rt/test/asan/TestCases/strcasestr-2.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ int main(int argc, char **argv) {
2020
__asan_poison_memory_region ((char *)&s2[2], 2);
2121
r = strcasestr(s1, s2);
2222
assert(r == 0);
23-
// CHECK:'s2' <== Memory access at offset {{[0-9]+}} partially overflows this variable
23+
// CHECK:'s2'{{.*}} <== Memory access at offset {{[0-9]+}} partially overflows this variable
2424
return 0;
2525
}

‎compiler-rt/test/asan/TestCases/strcspn-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ int main(int argc, char **argv) {
1414
char s1[4] = "caB";
1515
__asan_poison_memory_region ((char *)&s1[2], 2);
1616
r = strcspn(s1, s2);
17-
// CHECK:'s1' <== Memory access at offset {{[0-9]+}} partially overflows this variable
17+
// CHECK:'s1'{{.*}} <== Memory access at offset {{[0-9]+}} partially overflows this variable
1818
assert(r == 1);
1919
return 0;
2020
}

‎compiler-rt/test/asan/TestCases/strcspn-2.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ int main(int argc, char **argv) {
1414
char s2[4] = "abc";
1515
__asan_poison_memory_region ((char *)&s2[2], 2);
1616
r = strcspn(s1, s2);
17-
// CHECK:'s2' <== Memory access at offset {{[0-9]+}} partially overflows this variable
17+
// CHECK:'s2'{{.*}} <== Memory access at offset {{[0-9]+}} partially overflows this variable
1818
assert(r == 0);
1919
return 0;
2020
}

‎compiler-rt/test/asan/TestCases/strpbrk-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ int main(int argc, char **argv) {
1414
char s1[4] = "cab";
1515
__asan_poison_memory_region ((char *)&s1[2], 2);
1616
r = strpbrk(s1, s2);
17-
// CHECK:'s1' <== Memory access at offset {{[0-9]+}} partially overflows this variable
17+
// CHECK:'s1'{{.*}} <== Memory access at offset {{[0-9]+}} partially overflows this variable
1818
assert(r == s1 + 1);
1919
return 0;
2020
}

‎compiler-rt/test/asan/TestCases/strpbrk-2.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ int main(int argc, char **argv) {
1414
char s2[4] = "bca";
1515
__asan_poison_memory_region ((char *)&s2[2], 2);
1616
r = strpbrk(s1, s2);
17-
// CHECK:'s2' <== Memory access at offset {{[0-9]+}} partially overflows this variable
17+
// CHECK:'s2'{{.*}} <== Memory access at offset {{[0-9]+}} partially overflows this variable
1818
assert(r == s1);
1919
return 0;
2020
}

‎compiler-rt/test/asan/TestCases/strspn-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ int main(int argc, char **argv) {
1414
char s1[4] = "acb";
1515
__asan_poison_memory_region ((char *)&s1[2], 2);
1616
r = strspn(s1, s2);
17-
// CHECK:'s1' <== Memory access at offset {{[0-9]+}} partially overflows this variable
17+
// CHECK:'s1'{{.*}} <== Memory access at offset {{[0-9]+}} partially overflows this variable
1818
assert(r == 1);
1919
return 0;
2020
}

‎compiler-rt/test/asan/TestCases/strspn-2.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ int main(int argc, char **argv) {
1414
char s2[5] = "abcd";
1515
__asan_poison_memory_region ((char *)&s2[3], 2);
1616
r = strspn(s1, s2);
17-
// CHECK:'s2' <== Memory access at offset {{[0-9]+}} partially overflows this variable
17+
// CHECK:'s2'{{.*}} <== Memory access at offset {{[0-9]+}} partially overflows this variable
1818
assert(r >= 2);
1919
return 0;
2020
}

‎compiler-rt/test/asan/TestCases/strstr-1.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ int main(int argc, char **argv) {
1515
char s1[4] = "acb";
1616
__asan_poison_memory_region ((char *)&s1[2], 2);
1717
r = strstr(s1, s2);
18-
// CHECK:'s1' <== Memory access at offset {{[0-9]+}} {{partially overflows this variable|is inside this variable}}
18+
// CHECK:'s1'{{.*}} <== Memory access at offset {{[0-9]+}} {{partially overflows this variable|is inside this variable}}
1919
assert(r == s1 + 1);
2020
return 0;
2121
}

‎compiler-rt/test/asan/TestCases/strstr-2.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ int main(int argc, char **argv) {
1515
char s2[4] = "cab";
1616
__asan_poison_memory_region ((char *)&s2[2], 2);
1717
r = strstr(s1, s2);
18-
// CHECK:'s2' <== Memory access at offset {{[0-9]+}} partially overflows this variable
18+
// CHECK:'s2'{{.*}} <== Memory access at offset {{[0-9]+}} partially overflows this variable
1919
assert(r == 0);
2020
return 0;
2121
}

‎compiler-rt/test/asan/TestCases/strtok.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void test1() {
3535
char token_delimiter[2] = "b";
3636
__asan_poison_memory_region ((char *)&token_delimiter[1], 2);
3737
token = strtok(s, token_delimiter);
38-
// CHECK1:'token_delimiter' <== Memory access at offset {{[0-9]+}} partially overflows this variable
38+
// CHECK1: 'token_delimiter'{{.*}} <== Memory access at offset {{[0-9]+}} partially overflows this variable
3939
}
4040

4141
// Check that we find overflows in the delimiters on the second call (str == NULL)
@@ -48,7 +48,7 @@ void test2() {
4848
assert(strcmp(token, "a") == 0);
4949
__asan_poison_memory_region ((char *)&token_delimiter[1], 2);
5050
token = strtok(NULL, token_delimiter);
51-
// CHECK2:'token_delimiter' <== Memory access at offset {{[0-9]+}} partially overflows this variable
51+
// CHECK2: 'token_delimiter'{{.*}} <== Memory access at offset {{[0-9]+}} partially overflows this variable
5252
}
5353

5454
// Check that we find overflows in the string (only on the first call) with strict_string_checks.
@@ -58,7 +58,7 @@ void test3() {
5858
char token_delimiter[2] = "b";
5959
__asan_poison_memory_region ((char *)&s[3], 2);
6060
token = strtok(s, token_delimiter);
61-
// CHECK3:'s' <== Memory access at offset {{[0-9]+}} partially overflows this variable
61+
// CHECK3: 's'{{.*}} <== Memory access at offset {{[0-9]+}} partially overflows this variable
6262
}
6363

6464
// Check that we do not crash when strtok returns NULL with strict_string_checks.
@@ -78,7 +78,7 @@ void test5() {
7878
__asan_poison_memory_region ((char *)&s[2], 2);
7979
__asan_poison_memory_region ((char *)&token_delimiter[1], 2);
8080
token = strtok(s, token_delimiter);
81-
// CHECK5:'s' <== Memory access at offset {{[0-9]+}} partially overflows this variable
81+
// CHECK5: 's'{{.*}} <== Memory access at offset {{[0-9]+}} partially overflows this variable
8282
}
8383

8484
// Check that we find overflows in the delimiters (only on the first call) with !strict_string_checks.
@@ -88,7 +88,7 @@ void test6() {
8888
char token_delimiter[1] = {'d'};
8989
__asan_poison_memory_region ((char *)&token_delimiter[1], 2);
9090
token = strtok(s, &token_delimiter[1]);
91-
// CHECK6:'token_delimiter' <== Memory access at offset {{[0-9]+}} overflows this variable
91+
// CHECK6: 'token_delimiter'{{.*}} <== Memory access at offset {{[0-9]+}} overflows this variable
9292
}
9393

9494
int main(int argc, char **argv) {

‎compiler-rt/test/asan/TestCases/use-after-scope-inlined.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ int main(int argc, char *argv[]) {
2121
// CHECK: READ of size 4 at 0x{{.*}} thread T0
2222
// CHECK: #0 0x{{.*}} in main
2323
// CHECK: {{.*}}use-after-scope-inlined.cc:[[@LINE-4]]
24-
// CHECK: Address 0x{{.*}} is located in stack of thread T0 at offset
25-
// CHECK: [[OFFSET:[^ ]*]] in frame
26-
// CHECK: main
27-
// CHECK: {{\[}}[[OFFSET]], {{.*}}) 'x.i:[[@LINE-15]]'
24+
// CHECK: Address 0x{{.*}} is located in stack of thread T0 at offset [[OFFSET:[^ ]*]] in frame
25+
// CHECK: {{.*}} in main
26+
// CHECK: This frame has
27+
// CHECK: {{\[}}[[OFFSET]], {{.*}}) 'x.i' (line [[@LINE-15]])
2828
}

0 commit comments

Comments
 (0)
Please sign in to comment.