Add the helgrind/tests/bug322621 regression test
[valgrind.git] / cachegrind / tests / dlclose.c
blob9fee03088bd849d8ee0f9acc9f97d19ce679fa5f
1 /* This exercises the code that was causing this bug:
3 valgrind: vg_cachesim.c:389 (get_BBCC): Assertion `((Bool)0) == remove'
4 failed.
6 in Cachegrind 1.0.0 and 1.0.1, that was caused by unloading symbols before
7 invalidating translations.
8 */
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <dlfcn.h>
14 int main(int argc, char **argv) {
15 void *handle;
16 void (*myprint)(void);
17 char *error;
19 handle = dlopen ("./myprint.so", RTLD_LAZY);
20 if (!handle) {
21 fputs (dlerror(), stderr);
22 exit(1);
25 myprint = dlsym(handle, "myprint");
26 if ((error = dlerror()) != NULL) {
27 fprintf (stderr, "%s\n", error);
28 exit(1);
31 (*myprint)();
33 /* Assertion failure was happening here */
34 dlclose(handle);
36 return 0;