diff options
Diffstat (limited to 'src/regress/lib/libc/malloc/malloc_threaderr')
-rw-r--r-- | src/regress/lib/libc/malloc/malloc_threaderr/Makefile | 13 | ||||
-rw-r--r-- | src/regress/lib/libc/malloc/malloc_threaderr/malloc_threaderr.c | 72 |
2 files changed, 0 insertions, 85 deletions
diff --git a/src/regress/lib/libc/malloc/malloc_threaderr/Makefile b/src/regress/lib/libc/malloc/malloc_threaderr/Makefile deleted file mode 100644 index 2d715af58b..0000000000 --- a/src/regress/lib/libc/malloc/malloc_threaderr/Makefile +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | # $OpenBSD: Makefile,v 1.2 2018/01/28 14:55:24 otto Exp $ | ||
2 | |||
3 | # This test is supposed to print a malloc error and create a core dump | ||
4 | |||
5 | REGRESS_TARGETS= t1 | ||
6 | PROG= malloc_threaderr | ||
7 | LDADD+= -pthread | ||
8 | DPADD+= ${LIBPTHREAD} | ||
9 | |||
10 | .include <bsd.regress.mk> | ||
11 | |||
12 | t1: malloc_threaderr | ||
13 | ${.OBJDIR}/malloc_threaderr 2>&1 | fgrep 'in free(): bogus pointer (double free?)' | ||
diff --git a/src/regress/lib/libc/malloc/malloc_threaderr/malloc_threaderr.c b/src/regress/lib/libc/malloc/malloc_threaderr/malloc_threaderr.c deleted file mode 100644 index 3c38604ede..0000000000 --- a/src/regress/lib/libc/malloc/malloc_threaderr/malloc_threaderr.c +++ /dev/null | |||
@@ -1,72 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2018 Otto Moerbeek <otto@drijf.net> | ||
3 | * | ||
4 | * Permission to use, copy, modify, and distribute this software for any | ||
5 | * purpose with or without fee is hereby granted, provided that the above | ||
6 | * copyright notice and this permission notice appear in all copies. | ||
7 | * | ||
8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
15 | */ | ||
16 | |||
17 | #include <err.h> | ||
18 | #include <pthread.h> | ||
19 | #include <signal.h> | ||
20 | #include <stdio.h> | ||
21 | #include <stdlib.h> | ||
22 | #include <unistd.h> | ||
23 | #include <sys/resource.h> | ||
24 | |||
25 | pthread_cond_t cond; | ||
26 | pthread_mutex_t mutex; | ||
27 | |||
28 | void *p; | ||
29 | |||
30 | void *m(void *arg) | ||
31 | { | ||
32 | p = malloc(100000); | ||
33 | if (p == NULL) | ||
34 | err(1, NULL); | ||
35 | return NULL; | ||
36 | } | ||
37 | |||
38 | void *f(void *arg) | ||
39 | { | ||
40 | free(p); | ||
41 | free(p); | ||
42 | return NULL; | ||
43 | } | ||
44 | |||
45 | void | ||
46 | catch(int x) | ||
47 | { | ||
48 | _exit(0); | ||
49 | } | ||
50 | |||
51 | int | ||
52 | main(void) | ||
53 | { | ||
54 | const struct rlimit lim = {0, 0}; | ||
55 | pthread_t t1, t2; | ||
56 | |||
57 | /* prevent coredumps */ | ||
58 | setrlimit(RLIMIT_CORE, &lim); | ||
59 | printf("This test is supposed to print a malloc error\n"); | ||
60 | |||
61 | signal(SIGABRT, catch); | ||
62 | |||
63 | if (pthread_create(&t1, NULL, m, NULL)) | ||
64 | err(1, "pthread_create"); | ||
65 | pthread_join(t1, NULL); | ||
66 | |||
67 | if (pthread_create(&t2, NULL, f, NULL)) | ||
68 | err(1, "pthread_create"); | ||
69 | pthread_join(t2, NULL); | ||
70 | |||
71 | return 1; | ||
72 | } | ||