1. Pypy
  2. Untitled project
  3. stmgc

Commits

Armin Rigo  committed 6184784

Fix running test_zdemo_random, at least on some Linuxes where too many mprotect() eventually fail.

  • Participants
  • Parent commits 0581363
  • Branches default

Comments (0)

Files changed (2)

File c4/dbgmem.c

View file
  • Ignore whitespace
 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)
 {
     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)
 #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");

File c4/demo_random.c

View file
  • Ignore whitespace
     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