From eb8dd9dca1228af0cd132f515509051ecfabf6f6 Mon Sep 17 00:00:00 2001 From: cvs2svn Date: Mon, 14 Apr 2025 17:32:06 +0000 Subject: This commit was manufactured by cvs2git to create tag 'tb_20250414'. --- src/regress/lib/libc/malloc/Makefile | 8 - src/regress/lib/libc/malloc/malloc0test/Makefile | 11 - .../lib/libc/malloc/malloc0test/malloc0test.c | 120 -------- src/regress/lib/libc/malloc/malloc_errno/Makefile | 5 - .../lib/libc/malloc/malloc_errno/malloc_errno.c | 49 ---- src/regress/lib/libc/malloc/malloc_errs/Makefile | 5 - .../lib/libc/malloc/malloc_errs/malloc_errs.c | 325 --------------------- .../lib/libc/malloc/malloc_general/Makefile | 43 --- .../libc/malloc/malloc_general/malloc_general.c | 123 -------- .../lib/libc/malloc/malloc_threaderr/Makefile | 13 - .../malloc/malloc_threaderr/malloc_threaderr.c | 72 ----- .../lib/libc/malloc/malloc_ulimit1/Makefile | 5 - .../libc/malloc/malloc_ulimit1/malloc_ulimit1.c | 48 --- .../lib/libc/malloc/malloc_ulimit2/Makefile | 5 - .../libc/malloc/malloc_ulimit2/malloc_ulimit2.c | 46 --- 15 files changed, 878 deletions(-) delete mode 100644 src/regress/lib/libc/malloc/Makefile delete mode 100644 src/regress/lib/libc/malloc/malloc0test/Makefile delete mode 100644 src/regress/lib/libc/malloc/malloc0test/malloc0test.c delete mode 100644 src/regress/lib/libc/malloc/malloc_errno/Makefile delete mode 100644 src/regress/lib/libc/malloc/malloc_errno/malloc_errno.c delete mode 100644 src/regress/lib/libc/malloc/malloc_errs/Makefile delete mode 100644 src/regress/lib/libc/malloc/malloc_errs/malloc_errs.c delete mode 100644 src/regress/lib/libc/malloc/malloc_general/Makefile delete mode 100644 src/regress/lib/libc/malloc/malloc_general/malloc_general.c delete mode 100644 src/regress/lib/libc/malloc/malloc_threaderr/Makefile delete mode 100644 src/regress/lib/libc/malloc/malloc_threaderr/malloc_threaderr.c delete mode 100644 src/regress/lib/libc/malloc/malloc_ulimit1/Makefile delete mode 100644 src/regress/lib/libc/malloc/malloc_ulimit1/malloc_ulimit1.c delete mode 100644 src/regress/lib/libc/malloc/malloc_ulimit2/Makefile delete mode 100644 src/regress/lib/libc/malloc/malloc_ulimit2/malloc_ulimit2.c (limited to 'src/regress/lib/libc/malloc') diff --git a/src/regress/lib/libc/malloc/Makefile b/src/regress/lib/libc/malloc/Makefile deleted file mode 100644 index 546d67f6ca..0000000000 --- a/src/regress/lib/libc/malloc/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# $OpenBSD: Makefile,v 1.8 2023/05/08 11:13:30 otto Exp $ - -SUBDIR+= malloc_general malloc0test malloc_errno malloc_ulimit1 malloc_ulimit2 -SUBDIR+= malloc_threaderr malloc_errs - -install: - -.include diff --git a/src/regress/lib/libc/malloc/malloc0test/Makefile b/src/regress/lib/libc/malloc/malloc0test/Makefile deleted file mode 100644 index fc2295c091..0000000000 --- a/src/regress/lib/libc/malloc/malloc0test/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# $OpenBSD: Makefile,v 1.2 2017/07/08 00:08:26 bluhm Exp $ - -PROG= malloc0test - -.for m in C D F G J j R S U X << >>> -REGRESS_TARGETS += run-regress-${PROG}-${m:S//+/g} -run-regress-${PROG}-${m:S//+/g}: ${PROG} - MALLOC_OPTIONS='${m}' ./${PROG} -.endfor - -.include diff --git a/src/regress/lib/libc/malloc/malloc0test/malloc0test.c b/src/regress/lib/libc/malloc/malloc0test/malloc0test.c deleted file mode 100644 index 06ff0996ee..0000000000 --- a/src/regress/lib/libc/malloc/malloc0test/malloc0test.c +++ /dev/null @@ -1,120 +0,0 @@ -/* $OpenBSD: malloc0test.c,v 1.5 2008/04/13 00:22:17 djm Exp $ */ -/* - * Public domain. 2001, Theo de Raadt - */ -#include -#include -#include -#include -#include -#include -#include -#include - -volatile sig_atomic_t got; -jmp_buf jmp; - -static void -catch(int signo) -{ - got++; - longjmp(jmp, 1); -} - -static int -test(char *p, int size) -{ - signal(SIGSEGV, catch); - got = 0; - if (setjmp(jmp) == 0) - *p = 0; - if (setjmp(jmp) == 0) - *(p+size-1) = 0; - return (got); -} - -char *prot_table[] = { - "unprotected", - "fuckup", - "protected" -}; - -#define SIZE 10 - -/* - * Do random memory allocations. - * - * For each one, ensure that it is at least 16 bytes in size (that - * being what our current malloc returns for the minsize of an - * object, alignment wise); - * - * For zero-byte allocations, check that they are still aligned. - * - * For each object, ensure that they are correctly protected or not - * protected. - * - * Does not regress test malloc + free combinations ... it should. - */ -int -main(int argc, char *argv[]) -{ - caddr_t blob; - int size, tsize; - int prot; - int rval = 0, fuckup = 0; - long limit = 200000, count; - int ch, silent = 0; - char *ep; - extern char *__progname; - - while ((ch = getopt(argc, argv, "sn:")) != -1) { - switch (ch) { - case 's': - silent = 1; - break; - case 'n': - errno = 0; - limit = strtol(optarg, &ep, 10); - if (optarg[0] == '\0' || *ep != '\0' || - (errno == ERANGE && - (limit == LONG_MAX || limit == LONG_MIN))) - goto usage; - break; - default: -usage: - fprintf(stderr, "Usage: %s [-s][-n ]\n", - __progname); - exit(1); - } - } - - if (limit == 0) - limit = LONG_MAX; - - for (count = 0; count < limit; count++) { - size = arc4random_uniform(SIZE); - blob = malloc(size); - if (blob == NULL) { - fprintf(stderr, "success: out of memory\n"); - exit(rval); - } - - tsize = size == 0 ? 16 : size; - fuckup = 0; - prot = test(blob, tsize); - - if (size == 0 && prot < 2) - fuckup = 1; - - if (fuckup) { - printf("%8p %6d %20s %10s\n", blob, size, - prot_table[prot], fuckup ? "fuckup" : ""); - rval = 1; - } - - if (!silent && count % 100000 == 0 && count != 0) - fprintf(stderr, "count = %ld\n", count); - } - - return rval; -} diff --git a/src/regress/lib/libc/malloc/malloc_errno/Makefile b/src/regress/lib/libc/malloc/malloc_errno/Makefile deleted file mode 100644 index 73ebe37491..0000000000 --- a/src/regress/lib/libc/malloc/malloc_errno/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# $OpenBSD: Makefile,v 1.1 2003/07/15 10:06:31 otto Exp $ - -PROG= malloc_errno - -.include diff --git a/src/regress/lib/libc/malloc/malloc_errno/malloc_errno.c b/src/regress/lib/libc/malloc/malloc_errno/malloc_errno.c deleted file mode 100644 index 1759291f38..0000000000 --- a/src/regress/lib/libc/malloc/malloc_errno/malloc_errno.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD: malloc_errno.c,v 1.5 2019/06/11 22:16:13 bluhm Exp $ */ -/* - * Public domain. 2003, Otto Moerbeek - */ -#include -#include -#include -#include - -/* On arm64 with 2G of memory this test hangs while junking. */ -char *malloc_options = "jj"; - -static void -testerrno(size_t sz) -{ - void *p; - - errno = -1; - p = malloc(sz); - - if (p == NULL && errno != ENOMEM) - errx(1, "fail: %lx %p %d", (unsigned long)sz, p, errno); - - /* if alloc succeeded, test if errno did not change */ - if (p != NULL && errno != -1) - errx(1, "fail: %lx %p %d", (unsigned long)sz, p, errno); - - free(p); -} - -/* - * Provide some (silly) arguments to malloc(), and check if ERRNO is set - * correctly. - */ -int -main(int argc, char *argv[]) -{ - size_t i; - - testerrno(1); - testerrno(100000); - testerrno(-1); - testerrno(-1000); - testerrno(-10000); - testerrno(-10000000); - for (i = 0; i < 0x10; i++) - testerrno(i * 0x10000000); - return 0; -} diff --git a/src/regress/lib/libc/malloc/malloc_errs/Makefile b/src/regress/lib/libc/malloc/malloc_errs/Makefile deleted file mode 100644 index 150f30e671..0000000000 --- a/src/regress/lib/libc/malloc/malloc_errs/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# $OpenBSD: Makefile,v 1.1 2023/05/08 11:12:44 otto Exp $ - -PROG= malloc_errs - -.include diff --git a/src/regress/lib/libc/malloc/malloc_errs/malloc_errs.c b/src/regress/lib/libc/malloc/malloc_errs/malloc_errs.c deleted file mode 100644 index 486c247f0d..0000000000 --- a/src/regress/lib/libc/malloc/malloc_errs/malloc_errs.c +++ /dev/null @@ -1,325 +0,0 @@ -/* $OpenBSD: malloc_errs.c,v 1.5 2024/04/14 17:47:41 otto Exp $ */ -/* - * Copyright (c) 2023 Otto Moerbeek - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -/* Test erroneous use of API and heap that malloc should catch */ - -void -clearq(void *p) -{ - int i; - void *q; - - /* Clear delayed free queue */ - for (i = 0; i < 400; i++) { - q = malloc(100); - free(q); - if (p == q) { - fprintf(stderr, "Re-use\n"); - abort(); - } - } -} - -/* test the test setup */ -void -t0(void) -{ - abort(); -} - -/* double free >= page size */ -void -t1(void) -{ - void *p = malloc(10000); - free(p); - free(p); -} - -/* double free chunks are different, have a delayed free list */ -void -t2(void) -{ - void *p, *q; - int i; - - p = malloc(100); - free(p); - clearq(p); - free(p); -} - -/* double free without clearing delayed free list, needs F */ -void -t3(void) -{ - void *p = malloc(100); - free(p); - free(p); -} - -/* free without prior allocation */ -void -t4(void) -{ - free((void*)1); -} - -/* realloc of bogus pointer */ -void -t5(void) -{ - realloc((void*)1, 10); -} - -/* write after free for chunk */ -void -t6(void) -{ - char *p = malloc(32); - free(p); - p[0] = ~p[0]; - clearq(NULL); -} - -/* write after free large alloction */ -void -t7(void) -{ - char *p, *q; - int i; - - p = malloc(10000); - free(p); - p[0] = ~p[0]; - /* force re-use from the cache */ - for (i = 0; i < 100; i++) { - q = malloc(10000); - free(q); - } -} - -/* write after free for chunk, no clearing of delayed free queue */ -void -t8(void) -{ - char *p, *q; - - p = malloc(32); - q = malloc(32); - free(p); - p[0] = ~p[0]; - free(q); -} - -/* canary check */ -void -t9(void) -{ - char *p = malloc(100); - p[100] = 0; - free(p); -} - -/* t10 is the same as t9 with different flags */ - -/* modified chunk pointer */ -void -t11(void) -{ - char *p = malloc(100); - free(p + 1); -} - -/* free chunk pointer */ -void -t12(void) -{ - char *p = malloc(16); - free(p + 16); -} - -/* freezero with wrong size */ -void -t13(void) -{ - char *p = malloc(16); - freezero(p, 17); -} - -/* freezero with wrong size 2 */ -void -t14(void) -{ - char *p = malloc(15); - freezero(p, 16); -} - -/* freezero with wrong size, pages */ -void -t15(void) -{ - char *p = malloc(getpagesize()); - freezero(p, getpagesize() + 1); -} - -/* recallocarray with wrong size */ -void -t16(void) -{ - char *p = recallocarray(NULL, 0, 16, 1); - char *q = recallocarray(p, 2, 3, 16); -} - -/* recallocarray with wrong size 2 */ -void -t17(void) -{ - char *p = recallocarray(NULL, 0, 15, 1); - char *q = recallocarray(p, 2, 3, 15); -} - -/* recallocarray with wrong size, pages */ -void -t18(void) -{ - char *p = recallocarray(NULL, 0, 1, getpagesize()); - char *q = recallocarray(p, 2, 3, getpagesize()); -} - -/* recallocarray with wrong size, pages */ -void -t19(void) -{ - char *p = recallocarray(NULL, 0, 1, 10 * getpagesize()); - char *q = recallocarray(p, 1, 2, 4 * getpagesize()); -} - -/* canary check pages */ -void -t20(void) -{ - char *p = malloc(2*getpagesize() - 100); - p[2*getpagesize() - 100] = 0; - free(p); -} - -/* out-of-bound write preceding chunk */ -void -t22(void) -{ - int i, j; - unsigned char *p; - while (1) { - uintptr_t address; - p = malloc(32); - address = (uintptr_t)(void *)p; - /* we don't want to have a chunk on the last slot of a page */ - if (address / getpagesize() == (address + 32) / getpagesize()) - break; - free(p); - } - p[32] = 0; - for (i = 0; i < 10000; i++) - p = malloc(32); -} - -struct test { - void (*test)(void); - const char *flags; -}; - -struct test tests[] = { - { t0, "" }, - { t1, "" }, - { t2, "" }, - { t3, "F" }, - { t4, "" }, - { t5, "" }, - { t6, "J" }, - { t7, "JJ" }, - { t8, "FJ" }, - { t9, "C" }, - { t9, "JC" }, /* t10 re-uses code from t9 */ - { t11, "" }, - { t12, "" }, - { t13, "" }, - { t14, "C" }, - { t15, "" }, - { t16, "" }, - { t17, "C" }, - { t18, "" }, - { t19, "" }, - { t20, "C" }, - { t8, "FJD" }, /* t21 re-uses code from t8 */ - { t22, "J" }, - { t22, "JD" }, /* t23 re-uses code from t22 */ -}; - -int main(int argc, char *argv[]) -{ - - const struct rlimit lim = {0, 0}; - int i, status; - pid_t pid; - char num[10]; - char options[10]; - extern char* malloc_options; - - if (argc == 3) { - malloc_options = argv[2]; - /* prevent coredumps */ - setrlimit(RLIMIT_CORE, &lim); - i = atoi(argv[1]); - fprintf(stderr, "Test %d\n", i); - (*tests[i].test)(); - return 0; - } - - for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) { - pid = fork(); - switch (pid) { - case 0: - snprintf(options, sizeof(options), "us%s", tests[i].flags); - snprintf(num, sizeof(num), "%d", i); - execl(argv[0], argv[0], num, options, NULL); - err(1, "exec"); - break; - case -1: - err(1, "fork"); - break; - default: - if (waitpid(pid, &status, 0) == -1) - err(1, "wait"); - if (!WIFSIGNALED(status) || - WTERMSIG(status) != SIGABRT) - errx(1, "Test %d did not abort", i); - break; - } - } - return 0; -} - diff --git a/src/regress/lib/libc/malloc/malloc_general/Makefile b/src/regress/lib/libc/malloc/malloc_general/Makefile deleted file mode 100644 index 367b33b9c5..0000000000 --- a/src/regress/lib/libc/malloc/malloc_general/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -# $OpenBSD: Makefile,v 1.7 2023/05/09 19:07:37 otto Exp $ - -REGRESS_TARGETS= t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 -PROG= malloc_general - -.include - -t1: malloc_general - MALLOC_OPTIONS=su ${.OBJDIR}/malloc_general - -t2: malloc_general - MALLOC_OPTIONS=suC ${.OBJDIR}/malloc_general - -t3: malloc_general - MALLOC_OPTIONS=suJ ${.OBJDIR}/malloc_general - -t4: malloc_general - MALLOC_OPTIONS=suF ${.OBJDIR}/malloc_general - -t5: malloc_general - MALLOC_OPTIONS=suG ${.OBJDIR}/malloc_general - -t6: malloc_general - MALLOC_OPTIONS=suS ${.OBJDIR}/malloc_general - -t7: malloc_general - MALLOC_OPTIONS=suFGJ ${.OBJDIR}/malloc_general - -t8: malloc_general - MALLOC_OPTIONS=suCJ ${.OBJDIR}/malloc_general - -t9: malloc_general - MALLOC_OPTIONS=suCJJ ${.OBJDIR}/malloc_general - -t10: malloc_general - MALLOC_OPTIONS=suJS ${.OBJDIR}/malloc_general - -t11: malloc_general - MALLOC_OPTIONS=suFGJJ ${.OBJDIR}/malloc_general - -t12: malloc_general - MALLOC_OPTIONS=suFCJJ ${.OBJDIR}/malloc_general - diff --git a/src/regress/lib/libc/malloc/malloc_general/malloc_general.c b/src/regress/lib/libc/malloc/malloc_general/malloc_general.c deleted file mode 100644 index b243787bcf..0000000000 --- a/src/regress/lib/libc/malloc/malloc_general/malloc_general.c +++ /dev/null @@ -1,123 +0,0 @@ -/* $OpenBSD: malloc_general.c,v 1.7 2022/01/09 07:18:50 otto Exp $ */ -/* - * Copyright (c) 2017 Otto Moerbeek - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include -#include - -/* #define VERBOSE */ - -#define N 1000 - -size_t -size(void) -{ - int p = arc4random_uniform(17) + 3; - return arc4random_uniform(1 << p); -} - -struct { void *p; size_t sz; } a[N]; - -void -fill(u_char *p, size_t sz) -{ - size_t i; - - for (i = 0; i < sz; i++) - p[i] = i % 256; -} - -void -check(u_char *p, size_t sz) -{ - size_t i; - - for (i = 0; i < sz; i++) - if (p[i] != i % 256) - errx(1, "check"); -} - -int -main(int argc, char *argv[]) -{ - int count, p, r, i; - void * q; - size_t sz; - - for (count = 0; count < 800000; count++) { - if (count % 10000 == 0) { - printf("."); - fflush(stdout); - } - p = arc4random_uniform(2); - i = arc4random_uniform(N); - switch (p) { - case 0: - if (a[i].p) { -#ifdef VERBOSE - printf("F %p\n", a[i].p); -#endif - if (a[i].p) - check(a[i].p, a[i].sz); - free(a[i].p); - a[i].p = NULL; - } - sz = size(); -#ifdef VERBOSE - printf("M %zu=", sz); -#endif - r = arc4random_uniform(2); - a[i].p = r == 0 ? malloc_conceal(sz) : malloc(sz); - a[i].sz = sz; -#ifdef VERBOSE - printf("%p\n", a[i].p); -#endif - if (a[i].p) - fill(a[i].p, sz); - break; - case 1: - sz = size(); -#ifdef VERBOSE - printf("R %p %zu=", a[i].p, sz); -#endif - q = realloc(a[i].p, sz); -#ifdef VERBOSE - printf("%p\n", q); -#endif - if (a[i].p && q) - check(q, a[i].sz < sz ? a[i].sz : sz); - if (q) { - a[i].p = q; - a[i].sz = sz; - fill(a[i].p, sz); - } - break; - } - } - for (i = 0; i < N; i++) { - if (a[i].p) - check(a[i].p, a[i].sz); - r = arc4random_uniform(2); - if (r) - free(a[i].p); - else - freezero(a[i].p, a[i].sz); - } - printf("\n"); - return 0; -} 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 @@ -# $OpenBSD: Makefile,v 1.2 2018/01/28 14:55:24 otto Exp $ - -# This test is supposed to print a malloc error and create a core dump - -REGRESS_TARGETS= t1 -PROG= malloc_threaderr -LDADD+= -pthread -DPADD+= ${LIBPTHREAD} - -.include - -t1: malloc_threaderr - ${.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 @@ -/* - * Copyright (c) 2018 Otto Moerbeek - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include - -pthread_cond_t cond; -pthread_mutex_t mutex; - -void *p; - -void *m(void *arg) -{ - p = malloc(100000); - if (p == NULL) - err(1, NULL); - return NULL; -} - -void *f(void *arg) -{ - free(p); - free(p); - return NULL; -} - -void -catch(int x) -{ - _exit(0); -} - -int -main(void) -{ - const struct rlimit lim = {0, 0}; - pthread_t t1, t2; - - /* prevent coredumps */ - setrlimit(RLIMIT_CORE, &lim); - printf("This test is supposed to print a malloc error\n"); - - signal(SIGABRT, catch); - - if (pthread_create(&t1, NULL, m, NULL)) - err(1, "pthread_create"); - pthread_join(t1, NULL); - - if (pthread_create(&t2, NULL, f, NULL)) - err(1, "pthread_create"); - pthread_join(t2, NULL); - - return 1; -} diff --git a/src/regress/lib/libc/malloc/malloc_ulimit1/Makefile b/src/regress/lib/libc/malloc/malloc_ulimit1/Makefile deleted file mode 100644 index 46ced27a98..0000000000 --- a/src/regress/lib/libc/malloc/malloc_ulimit1/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# $OpenBSD: Makefile,v 1.1 2006/04/18 19:03:30 otto Exp $ - -PROG= malloc_ulimit1 - -.include diff --git a/src/regress/lib/libc/malloc/malloc_ulimit1/malloc_ulimit1.c b/src/regress/lib/libc/malloc/malloc_ulimit1/malloc_ulimit1.c deleted file mode 100644 index 799d2b9117..0000000000 --- a/src/regress/lib/libc/malloc/malloc_ulimit1/malloc_ulimit1.c +++ /dev/null @@ -1,48 +0,0 @@ -/* $OpenBSD: malloc_ulimit1.c,v 1.5 2019/06/12 11:31:36 bluhm Exp $ */ - -/* Public Domain, 2006, Otto Moerbeek */ - -#include -#include -#include -#include -#include -#include - -/* - * This code tries to trigger the case present in -current as of April - * 2006) where the allocation of the region itself succeeds, but the - * page dir entry pages fails. - * This in turn trips a "hole in directories" error. - * Having a large (512M) ulimit -m helps a lot in triggering the - * problem. Note that you may need to run this test multiple times to - * see the error. -*/ - -#define STARTI 1300 -#define FACTOR 1024 - -/* This test takes forever with junking turned on. */ -char *malloc_options = "jj"; - -int -main() -{ - struct rlimit lim; - size_t sz; - int i; - void *p; - - if (getrlimit(RLIMIT_DATA, &lim) == -1) - err(1, "getrlimit"); - - sz = lim.rlim_cur / FACTOR; - - for (i = STARTI; i >= 0; i--) { - size_t len = (sz-i) * FACTOR; - p = malloc(len); - free(p); - free(malloc(4096)); - } - return (0); -} diff --git a/src/regress/lib/libc/malloc/malloc_ulimit2/Makefile b/src/regress/lib/libc/malloc/malloc_ulimit2/Makefile deleted file mode 100644 index bc83666415..0000000000 --- a/src/regress/lib/libc/malloc/malloc_ulimit2/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# $OpenBSD: Makefile,v 1.1 2006/04/18 19:04:03 otto Exp $ - -PROG= malloc_ulimit2 - -.include diff --git a/src/regress/lib/libc/malloc/malloc_ulimit2/malloc_ulimit2.c b/src/regress/lib/libc/malloc/malloc_ulimit2/malloc_ulimit2.c deleted file mode 100644 index 5d9e3774e7..0000000000 --- a/src/regress/lib/libc/malloc/malloc_ulimit2/malloc_ulimit2.c +++ /dev/null @@ -1,46 +0,0 @@ -/* $OpenBSD: malloc_ulimit2.c,v 1.5 2019/06/12 11:31:36 bluhm Exp $ */ - -/* Public Domain, 2006, Otto Moerbeek */ - -#include -#include -#include -#include -#include -#include - -#define FACTOR 1024 - -/* This test takes forever with junking turned on. */ -char *malloc_options = "jj"; - -int -main() -{ - struct rlimit lim; - size_t sz; - int i; - void *p; - - if (getrlimit(RLIMIT_DATA, &lim) == -1) - err(1, "getrlimit"); - - sz = lim.rlim_cur / FACTOR; - - for (i = 0; ; i++) { - size_t len = (sz-i) * FACTOR; - p = malloc(len); - if (p != NULL) { - free(p); - break; - } - } - i += 10; - for (; i >= 0; i--) { - size_t len = (sz-i) * FACTOR; - p = malloc(len); - free(p); - free(malloc(4096)); - } - return (0); -} -- cgit v1.2.3-55-g6feb