summaryrefslogtreecommitdiff
path: root/regress/lib/libc
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2006-04-18 19:03:31 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2006-04-18 19:03:31 +0000
commit14d8b1a4ce4bf501fadb7b37f01d346e207736bb (patch)
tree211288b6474bd5b5fd9fbfba0192382fe3b775c1 /regress/lib/libc
parent939584fef88ea83d5126ff046d9d329ae42ff43f (diff)
Near ulimit test case 1
Diffstat (limited to 'regress/lib/libc')
-rw-r--r--regress/lib/libc/malloc/malloc_ulimit1/Makefile5
-rw-r--r--regress/lib/libc/malloc/malloc_ulimit1/malloc_ulimit1.c43
2 files changed, 48 insertions, 0 deletions
diff --git a/regress/lib/libc/malloc/malloc_ulimit1/Makefile b/regress/lib/libc/malloc/malloc_ulimit1/Makefile
new file mode 100644
index 00000000000..46ced27a983
--- /dev/null
+++ b/regress/lib/libc/malloc/malloc_ulimit1/Makefile
@@ -0,0 +1,5 @@
+# $OpenBSD: Makefile,v 1.1 2006/04/18 19:03:30 otto Exp $
+
+PROG= malloc_ulimit1
+
+.include <bsd.regress.mk>
diff --git a/regress/lib/libc/malloc/malloc_ulimit1/malloc_ulimit1.c b/regress/lib/libc/malloc/malloc_ulimit1/malloc_ulimit1.c
new file mode 100644
index 00000000000..faa98c7bd62
--- /dev/null
+++ b/regress/lib/libc/malloc/malloc_ulimit1/malloc_ulimit1.c
@@ -0,0 +1,43 @@
+/* $OpenBSD: malloc_ulimit1.c,v 1.1 2006/04/18 19:03:30 otto Exp $ */
+
+/* Public Domain, 2006, Otto Moerbeek <otto@drijf.net> */
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <err.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+/*
+ * 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
+
+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));
+ }
+}