diff options
author | Florian Mayer <fmayer@google.com> | 2023-05-12 14:24:14 -0700 |
---|---|---|
committer | Florian Mayer <fmayer@google.com> | 2023-05-12 15:06:31 -0700 |
commit | edd0981e71af87a686365d40e6410a8a377c153d (patch) | |
tree | 4a073a0869909b90088a6957749d3885b246789a /compiler-rt | |
parent | 39578264d0797fabb0d6dedaa7d1630ffbea6c9e (diff) | |
download | llvm-edd0981e71af87a686365d40e6410a8a377c153d.tar.gz |
[HWASan] unflake test
The short granule logic made this test flaky because with low
probability there would be no tag mismatch by coincidence.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D150484
Diffstat (limited to 'compiler-rt')
-rw-r--r-- | compiler-rt/test/hwasan/TestCases/global-with-reduction.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/compiler-rt/test/hwasan/TestCases/global-with-reduction.c b/compiler-rt/test/hwasan/TestCases/global-with-reduction.c index de682030ee88..b93e976c6f3f 100644 --- a/compiler-rt/test/hwasan/TestCases/global-with-reduction.c +++ b/compiler-rt/test/hwasan/TestCases/global-with-reduction.c @@ -22,29 +22,36 @@ // REQUIRES: pointer-tagging +#include <inttypes.h> #include <stdlib.h> +struct data { + uint64_t x; + uint64_t y; +}; + // GlobalOpt may replace the current GV with a new boolean-typed GV. Previously, // this resulted in the "nosanitize" getting dropped because while the data/code // references to the GV were updated, the old metadata references weren't. -int* f() { +struct data *f() { #ifdef USE_NOSANITIZE -__attribute__((no_sanitize("hwaddress"))) static int x = 1; + __attribute__((no_sanitize("hwaddress"))) static struct data x = {1, 0}; #else // USE_NOSANITIZE - static int x = 1; + static struct data x = {1, 0}; #endif // USE_NOSANITIZE - if (x == 1) x = 0; + if (x.x == 1) + x.x = 0; return &x; } int main(int argc, char **argv) { // CHECK: Cause: global-overflow - // RSYM: is located 0 bytes after a 4-byte global variable f.x {{.*}} in {{.*}}global-with-reduction.c.tmp - // RNOSYM: is located after a 4-byte global variable in + // RSYM: is located 0 bytes after a 16-byte global variable f.x {{.*}} in {{.*}}global-with-reduction.c.tmp + // RNOSYM: is located after a 16-byte global variable in // RNOSYM-NEXT: #0 0x{{.*}} ({{.*}}global-with-reduction.c.tmp+{{.*}}) - // LSYM: is located 4 bytes before a 4-byte global variable f.x {{.*}} in {{.*}}global-with-reduction.c.tmp - // LNOSYM: is located before a 4-byte global variable in + // LSYM: is located 16 bytes before a 16-byte global variable f.x {{.*}} in {{.*}}global-with-reduction.c.tmp + // LNOSYM: is located before a 16-byte global variable in // LNOSYM-NEXT: #0 0x{{.*}} ({{.*}}global-with-reduction.c.tmp+{{.*}}) // CHECK-NOT: can not describe - f()[atoi(argv[1])] = 1; + f()[atoi(argv[1])].x = 1; } |