Skip to content

Commit 4411c72

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.4
1 parent f327d6d commit 4411c72

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Make sure dlerror is not classified as a leak even if we use dynamic TLS.
2+
// RUN: %clangxx_hwasan -O0 %s -o %t && HWASAN_OPTIONS=detect_leaks=1 %run %t
3+
// XFAIL: *
4+
5+
#include <assert.h>
6+
#include <dlfcn.h>
7+
#include <pthread.h>
8+
#include <sanitizer/hwasan_interface.h>
9+
#include <stdlib.h>
10+
#include <string.h>
11+
#include <unistd.h>
12+
13+
constexpr auto kKeys = 100;
14+
15+
int main(int argc, char **argv) {
16+
__hwasan_enable_allocator_tagging();
17+
// Exhaust static TLS slots to force use of dynamic TLS.
18+
pthread_key_t keys[kKeys];
19+
for (int i = 0; i < kKeys; ++i) {
20+
assert(pthread_key_create(&keys[i], nullptr) == 0);
21+
}
22+
void* o = dlopen("invalid_file_name.so", 0);
23+
const char* err = dlerror();
24+
for (int i = 0; i < kKeys; ++i) {
25+
assert(pthread_key_delete(keys[i]) == 0);
26+
}
27+
return 0;
28+
}

0 commit comments

Comments
 (0)