Skip to content

Commit

Permalink
Fix-forward ASan on Windows.
Browse files Browse the repository at this point in the history
D127911 deleted llvm.asan.globals. This had a side effect that we no
longer generated the `name` field for the `__asan_global` descriptor
from clang's decscription of the name, but the demangled name from the
LLVM IR. On Linux, this is the same as the clang-provided name. On
Windows, this includes the type, as the name in the IR is the mangled
name.

Attempt #1 to fix-forward the Windows bots by making the tests glob both
sides of the global name, thereby allowing types in the descriptor name.
  • Loading branch information
hctim committed Jun 27, 2022
1 parent 53217ec commit 7b23552
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions compiler-rt/test/asan/TestCases/debug_locate.cpp
Expand Up @@ -23,14 +23,14 @@ int main() {

type = __asan_locate_address(&global_var, name, 100,
&region_address, &region_size);
assert(0 == strcmp(name, "global_var"));
assert(nullptr != strstr(name, "global_var"));
assert(0 == strcmp(type, "global"));
assert(region_address == &global_var);
assert(region_size == sizeof(global_var));

type = __asan_locate_address((char *)(&global_var)+1, name, 100,
&region_address, &region_size);
assert(0 == strcmp(name, "global_var"));
assert(nullptr != strstr(name, "global_var"));
assert(0 == strcmp(type, "global"));
assert(region_address == &global_var);
assert(region_size == sizeof(global_var));
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/asan/TestCases/describe_address.cpp
Expand Up @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) {
__asan_describe_address(&stack);
// CHECK: Address {{.*}} is located in stack of thread T{{.*}} at offset {{.*}}
__asan_describe_address(&global);
// CHECK: {{.*}} is located 0 bytes inside of global variable 'global'
// CHECK: {{.*}} is located 0 bytes inside of global variable '{{.*}}global{{.*}}'
delete[] heap;
return 0;
}
4 changes: 2 additions & 2 deletions compiler-rt/test/asan/TestCases/global-demangle.cpp
Expand Up @@ -12,6 +12,6 @@ int main(int argc, char **argv) {
return (int)XXX::YYY::ZZZ[argc + 5]; // BOOM
// CHECK: {{READ of size 1 at 0x.*}}
// CHECK: {{0x.* is located 2 bytes to the right of global variable}}
// CHECK: 'XXX::YYY::ZZZ' {{.*}} of size 4
// CHECK: 'XXX::YYY::ZZZ' is ascii string 'abc'
// CHECK: '{{.*}}XXX::YYY::ZZZ{{.*}}' {{.*}} of size 4
// CHECK: '{{.*}}XXX::YYY::ZZZ{{.*}}' is ascii string 'abc'
}
6 changes: 3 additions & 3 deletions compiler-rt/test/asan/TestCases/global-location-nodebug.cpp
Expand Up @@ -12,8 +12,8 @@
// XFAIL: solaris

// CHECK: AddressSanitizer: global-buffer-overflow
// CLASS_STATIC-NO-G: 0x{{.*}} is located 4 bytes to the right of global variable 'C::array' defined in '{{.*}}global-location.cpp' {{.*}} of size 40
// GLOB-NO-G: 0x{{.*}} is located 4 bytes to the right of global variable 'global' defined in '{{.*}}global-location.cpp' {{.*}} of size 40
// FUNC_STATIC-NO-G: 0x{{.*}} is located 4 bytes to the right of global variable 'main::array' defined in '{{.*}}global-location.cpp' {{.*}} of size 40
// CLASS_STATIC-NO-G: 0x{{.*}} is located 4 bytes to the right of global variable '{{.*}}C::array{{.*}}' defined in '{{.*}}global-location.cpp' {{.*}} of size 40
// GLOB-NO-G: 0x{{.*}} is located 4 bytes to the right of global variable '{{.*}}global{{.*}}' defined in '{{.*}}global-location.cpp' {{.*}} of size 40
// FUNC_STATIC-NO-G: 0x{{.*}} is located 4 bytes to the right of global variable '{{.*}}main::array{{.*}}' defined in '{{.*}}global-location.cpp' {{.*}} of size 40
// LITERAL-NO-G: 0x{{.*}} is located 0 bytes to the right of global variable {{.*}} defined in '{{.*}}global-location.cpp' {{.*}} of size 11
// CHECK: SUMMARY: AddressSanitizer: global-buffer-overflow

0 comments on commit 7b23552

Please sign in to comment.