none/tests/fdleak_cmsg_supp.supp: Add suppressions for older glibc
[valgrind.git] / none / tests / solaris / coredump_many_threads.c
blob1b45a17c4e78030dff0806f0b554956993630813
1 /*
2 * Creates 8 threads. The fifth one (counting the main thread as well)
3 * causes a core dump.
4 */
6 #include <errno.h>
7 #include <pthread.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <unistd.h>
13 #define NEVERENDING_SLEEP 10000
15 static pthread_barrier_t barrier;
17 static void *thread_func2(void *arg) {
18 pthread_barrier_wait(&barrier);
19 sleep(NEVERENDING_SLEEP);
20 return NULL;
23 static void *thread_func3(void *arg) {
24 pthread_barrier_wait(&barrier);
25 sleep(NEVERENDING_SLEEP);
26 return NULL;
29 static void *thread_func4(void *arg) {
30 pthread_barrier_wait(&barrier);
31 sleep(NEVERENDING_SLEEP);
32 return NULL;
35 static void *thread_func5(void *arg) {
36 pthread_barrier_wait(&barrier);
37 sleep(2);
39 char *x = (char *) 0x1;
40 *x = 2;
41 return NULL;
44 static void *thread_func6(void *arg) {
45 pthread_barrier_wait(&barrier);
46 sleep(NEVERENDING_SLEEP);
47 return NULL;
50 static void *thread_func7(void *arg) {
51 pthread_barrier_wait(&barrier);
52 sleep(NEVERENDING_SLEEP);
53 return NULL;
56 static void *thread_func8(void *arg) {
57 pthread_barrier_wait(&barrier);
58 sleep(NEVERENDING_SLEEP);
59 return NULL;
62 static void *thread_func9(void *arg) {
63 pthread_barrier_wait(&barrier);
64 sleep(NEVERENDING_SLEEP);
65 return NULL;
68 static void create_thread(void *(*thread_func)(void *))
70 pthread_t thread;
72 int ret = pthread_create(&thread, NULL, thread_func, NULL);
73 if (ret != 0) {
74 fprintf(stderr, "pthread_create: %s (%d)\n", strerror(ret), ret);
75 exit(1);
79 int main(int argc, const char *argv[])
81 int ret = pthread_barrier_init(&barrier, NULL, 9);
82 if (ret != 0) {
83 fprintf(stderr, "pthread_barrier_init: %s (%d)\n",
84 strerror(ret), ret);
85 exit(1);
88 create_thread(thread_func2);
89 create_thread(thread_func3);
90 create_thread(thread_func4);
91 create_thread(thread_func5);
92 create_thread(thread_func6);
93 create_thread(thread_func7);
94 create_thread(thread_func8);
95 create_thread(thread_func9);
96 pthread_barrier_wait(&barrier);
98 sleep(NEVERENDING_SLEEP);
99 return 0;