]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Debug: Allocate pages scattered to help catching out-of-range bugs mq-debug-alloc-scattered
authorMaria Matejka <mq@ucw.cz>
Tue, 27 Jan 2026 08:38:36 +0000 (09:38 +0100)
committerMaria Matejka <mq@ucw.cz>
Tue, 27 Jan 2026 08:38:36 +0000 (09:38 +0100)
sysdep/unix/alloc.c

index fcf855082eb75bf3126a793c30fdac423d8390f6..61c62b8f6356f9147c33e68e2b786951d12df943 100644 (file)
@@ -304,7 +304,12 @@ alloc_page(void)
   ajlog(ptr, NULL, 0, AJT_ALLOC_MMAP);
 
   for (int i=1; i<ALLOC_PAGES_AT_ONCE; i++)
-    free_page(ptr + page_size * i);
+#if DEBUGGING
+    if (i & 1)
+      mprotect(ptr + page_size * i, page_size, PROT_NONE);
+    else
+#endif
+      free_page(ptr + page_size * i);
 
   return ptr;
 #endif