Skip to content

Commit 50f3672

Browse files
committed
[PR] vitalybuka - nested disabler test
1 parent ec20696 commit 50f3672

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

compiler-rt/test/rtsan/disabler.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@ void violation() [[clang::nonblocking]] {
1717
printf("ptr: %p\n", ptr); // ensure we don't optimize out the malloc
1818
}
1919

20+
// ensure nested disablers don't interfere with one another
21+
void *ptr2;
22+
{
23+
__rtsan::ScopedDisabler disabler{};
24+
{
25+
__rtsan::ScopedDisabler disabler2{};
26+
ptr2 = malloc(2);
27+
printf("ptr: %p\n", ptr); // ensure we don't optimize out the malloc
28+
}
29+
30+
free(ptr2);
31+
printf("Free'd second pointer in disabled context without crashing\n");
32+
}
33+
2034
free(ptr);
2135
}
2236

@@ -25,7 +39,8 @@ int main() {
2539
return 0;
2640
// CHECK: {{.*Real-time violation.*}}
2741
// CHECK-NOT: {{.*malloc*}}
28-
// CHECK: {{.*free*}}
42+
// CHECK: Free'd second pointer in disabled context without crashing
43+
// CHECK: {{.*real-time unsafe function `free`.*}}
2944
}
3045

3146
// CHECK-ENABLED-IR: {{.*@__rtsan_disable.*}}

0 commit comments

Comments
 (0)