[pypy-commit] stmgc default: Fix running test_zdemo_random, at least on some Linuxes where too many mprotect() eventually fail.
arigo
noreply at buildbot.pypy.org
Mon Sep 23 17:34:42 CEST 2013
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r532:6184784a65a0
Date: 2013-09-23 17:34 +0200
http://bitbucket.org/pypy/stmgc/changeset/6184784a65a0/
Log: Fix running test_zdemo_random, at least on some Linuxes where too
many mprotect() eventually fail.
diff --git a/c4/dbgmem.c b/c4/dbgmem.c
--- a/c4/dbgmem.c
+++ b/c4/dbgmem.c
@@ -14,6 +14,7 @@
static char *zone_start, *zone_current = NULL, *zone_end = NULL;
static signed char accessible_pages[MMAP_TOTAL / PAGE_SIZE] = {0};
+int stm_use_mprotect = 1;
static void _stm_dbgmem(void *p, size_t sz, int prot)
{
@@ -24,9 +25,11 @@
intptr_t align = ((intptr_t)p) & (PAGE_SIZE-1);
p = ((char *)p) - align;
sz += align;
- dprintf(("dbgmem: %p, %ld, %d\n", p, (long)sz, prot));
- int err = mprotect(p, sz, prot);
- assert(err == 0);
+ if (stm_use_mprotect) {
+ dprintf(("dbgmem: %p, %ld, %d\n", p, (long)sz, prot));
+ int err = mprotect(p, sz, prot);
+ assert(err == 0);
+ }
}
void *stm_malloc(size_t sz)
@@ -36,7 +39,7 @@
#ifdef _GC_MEMPROTECT
pthread_mutex_lock(&malloc_mutex);
if (zone_current == NULL) {
- zone_start = mmap(NULL, MMAP_TOTAL, PROT_NONE,
+ zone_start = mmap(NULL, MMAP_TOTAL, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (zone_start == NULL || zone_start == MAP_FAILED) {
stm_fatalerror("not enough memory: mmap() failed\n");
diff --git a/c4/demo_random.c b/c4/demo_random.c
--- a/c4/demo_random.c
+++ b/c4/demo_random.c
@@ -782,11 +782,17 @@
printf("started new thread\n");
}
+#ifdef _GC_MEMPROTECT
+extern int stm_use_mprotect;
+#endif
int main(void)
{
int i, status;
+#ifdef _GC_MEMPROTECT
+ stm_use_mprotect = 0; /* uses too much memory */
+#endif
/* pick a random seed from the time in seconds.
A bit pointless for now... because the interleaving of the
More information about the pypy-commit
mailing list