1 #include <dlfcn.h>
2 #include <pthread.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 
6 
7 static void *
start_routine(void * args)8 start_routine (void *args)
9 {
10   int i;
11   void **addrs = (void **) args;
12   for (i = 0; i < 10000; ++i)
13     addrs[i % 1024] = dlsym (NULL, "does_not_exist");
14 
15   return addrs;
16 }
17 
18 
19 static int
do_test(void)20 do_test (void)
21 {
22   pthread_t tid1, tid2, tid3;
23 
24   void *addrs1[1024];
25   void *addrs2[1024];
26   void *addrs3[1024];
27 
28   if (pthread_create (&tid1, NULL, start_routine, addrs1) != 0)
29     {
30       puts ("1st create failed");
31       exit (1);
32     }
33   if (pthread_create (&tid2, NULL, start_routine, addrs2) != 0)
34     {
35       puts ("2nd create failed");
36       exit (1);
37     }
38   if (pthread_create (&tid3, NULL, start_routine, addrs3) != 0)
39     {
40       puts ("3rd create failed");
41       exit (1);
42     }
43 
44   if (pthread_join (tid1, NULL) != 0)
45     {
46       puts ("1st join failed");
47       exit (1);
48     }
49   if (pthread_join (tid2, NULL) != 0)
50     {
51       puts ("2nd join failed");
52       exit (1);
53     }
54   if (pthread_join (tid3, NULL) != 0)
55     {
56       puts ("2rd join failed");
57       exit (1);
58     }
59 
60   return 0;
61 }
62 
63 
64 #define TEST_FUNCTION do_test ()
65 #include "../test-skeleton.c"
66