Remi Meier avatar Remi Meier committed 89a1de5

add a constant to disable the madvise() nursery clearing for use with valgrind

Comments (0)

Files changed (3)

 C_FILES = et.c lists.c steal.c nursery.c gcpage.c \
           stmsync.c extra.c weakref.c dbgmem.c fprintcolor.c
 
-DEBUG = -g -DGC_NURSERY=0x10000 -D_GC_DEBUG=1 -DDUMP_EXTRA=1 -D_GC_DEBUGPRINTS=1 -DSTM_BARRIER_COUNT=1 -D_GC_MEMPROTECT=1
+DEBUG = -g -DGC_NURSERY=0x10000 -D_GC_DEBUG=1 -DDUMP_EXTRA=1 -D_GC_DEBUGPRINTS=1 -DSTM_BARRIER_COUNT=1 -D_GC_MEMPROTECT=1 -D_USE_VALGRIND=1
 
 
 # note that we don't say -DNDEBUG, so that asserts should still be compiled in
 # also, all debug code with extra checks but not the debugprints
 build-%: %.c ${H_FILES} ${C_FILES} stmgc.c
-	gcc -pthread -DGC_NURSERY=0x10000  -D_GC_DEBUG=1 -g $< -o build-$* -Wall stmgc.c -lrt
+	gcc -pthread -DGC_NURSERY=0x10000 -D_USE_VALGRIND   -g $< -o build-$* -Wall stmgc.c -lrt
+# gcc address sanitizer: -fPIE -pie -fsanitize=address -lasan -fno-omit-frame-pointer
 
 debug-%: %.c ${H_FILES} ${C_FILES}
 	gcc -pthread -DDUMP_EXTRA=1 ${DEBUG} $< -o debug-$* -Wall ${C_FILES} -lrt
     char *baseaddr = base;
     assert(already_cleared <= size);
 
+#if !defined(_USE_VALGRIND)
     if (size > 2 * PAGE_SIZE) {
         int lowbits = ((intptr_t)baseaddr) & (PAGE_SIZE-1);
         if (lowbits) {   /*  clear the initial misaligned part, if any */
             size -= length;
         }
     }
+#endif
     if (size > already_cleared) { /* clear the final misaligned part, if any */
         memset(baseaddr, 0, size - already_cleared);
     }
     *d->nursery_nextlimit_ref += GC_NURSERY_SECTION;
 
     /* Return the object from there */
-    gcptr P = (gcptr)*d->nursery_current_ref;
+    gcptr P = (gcptr)(*d->nursery_current_ref);
     *d->nursery_current_ref += allocate_size;
     assert(*d->nursery_current_ref <= *d->nursery_nextlimit_ref);
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.