[PATCH] D32374: [asan] Close all loaded libs in stress_dtls.c test.
Aleksey Shlyapnikov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 21 14:29:37 PDT 2017
alekseyshl created this revision.
Herald added a subscriber: kubamracek.
.
https://reviews.llvm.org/D32374
Files:
test/asan/TestCases/Linux/stress_dtls.c
Index: test/asan/TestCases/Linux/stress_dtls.c
===================================================================
--- test/asan/TestCases/Linux/stress_dtls.c
+++ test/asan/TestCases/Linux/stress_dtls.c
@@ -78,17 +78,18 @@
num_libs = atoi(argv[2]);
assert(num_libs <= MAX_N_FUNCTIONS);
+ void* handles[MAX_N_FUNCTIONS];
int lib;
for (lib = 0; lib < num_libs; lib++) {
char buf[4096];
snprintf(buf, sizeof(buf), "%s-f%d.so", argv[0], lib);
- void *handle = dlopen(buf, RTLD_LAZY);
- if (!handle) {
+ handles[lib] = dlopen(buf, RTLD_LAZY);
+ if (!handles[lib]) {
fprintf(stderr, "%s\n", dlerror());
exit(1);
}
snprintf(buf, sizeof(buf), "f%d", lib);
- Functions[lib] = (f_t)dlsym(handle, buf);
+ Functions[lib] = (f_t)dlsym(handles[lib], buf);
if (!Functions[lib]) {
fprintf(stderr, "%s\n", dlerror());
exit(1);
@@ -104,6 +105,12 @@
pthread_join(t, 0);
}
}
+
+ // Close all loaded libs to prevent the possible TLS leak described in
+ // https://sourceware.org/bugzilla/show_bug.cgi?id=12650.
+ for (lib = 0; lib < num_libs; lib++)
+ dlclose(handles[lib]);
+
return 0;
}
#else // SO_NAME
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32374.96235.patch
Type: text/x-patch
Size: 1200 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170421/16f929c1/attachment.bin>
More information about the llvm-commits
mailing list