Loading...
tests/region_cookie_test.c libmalloc-715.100.22 libmalloc-283
--- libmalloc/libmalloc-715.100.22/tests/region_cookie_test.c
+++ libmalloc/libmalloc-283/tests/region_cookie_test.c
@@ -11,7 +11,6 @@
 T_GLOBAL_META(T_META_RUN_CONCURRENTLY(true));
 
 T_DECL(tiny_region_cookie_test, "Crash on corruption of tiny region cookie",
-		T_META_TAG_VM_NOT_PREFERRED,
 		T_META_ENVVAR("MallocNanoZone=0"),
 		T_META_ENVVAR("MallocMaxMagazines=1"),
 		T_META_IGNORECRASHES("region_cookie_test"))
@@ -30,10 +29,14 @@
 		// Corrupt the region cookie for both pointers (just in case they
 		// are in different regions).
 		void *region = TINY_REGION_FOR_PTR(ptr1);
-		REGION_COOKIE_FOR_TINY_REGION(region)++;
+		region_trailer_t *trailer = REGION_TRAILER_FOR_TINY_REGION(region);
+		T_ASSERT_NOTNULL(trailer, "Trailer pointer #1 set");
+		trailer->region_cookie++;
 
 		region = TINY_REGION_FOR_PTR(ptr2);
-		REGION_COOKIE_FOR_TINY_REGION(region)++;
+		trailer = REGION_TRAILER_FOR_TINY_REGION(region);
+		T_ASSERT_NOTNULL(trailer, "Trailer pointer #2 set");
+		trailer->region_cookie++;
 
 		free(ptr1);
 		free(ptr2);
@@ -50,7 +53,6 @@
 }
 
 T_DECL(small_region_cookie_test, "Crash on corruption of small region cookie",
-		T_META_TAG_VM_NOT_PREFERRED,
 		T_META_ENVVAR("MallocNanoZone=0"),
 		T_META_ENVVAR("MallocMaxMagazines=1"),
 		T_META_IGNORECRASHES("region_cookie_test"))
@@ -61,18 +63,22 @@
 	if (!child_pid) {
 		// MallocMaxMagazines=1 ensures these allocations come from the
 		// same magazine.
-		void *ptr1 = malloc(TINY_LIMIT_THRESHOLD + 1);
-		void *ptr2 = malloc(TINY_LIMIT_THRESHOLD + 1);
+		void *ptr1 = malloc(1024);
+		void *ptr2 = malloc(1024);
 		T_ASSERT_NOTNULL(ptr1, "Allocation #1 succeeded");
 		T_ASSERT_NOTNULL(ptr2, "Allocation #2 succeeded");
 
 		// Corrupt the region cookie for both pointers (just in case they
 		// are in different regions).
 		void *region = SMALL_REGION_FOR_PTR(ptr1);
-		REGION_COOKIE_FOR_SMALL_REGION(region)++;
+		region_trailer_t *trailer = REGION_TRAILER_FOR_SMALL_REGION(region);
+		T_ASSERT_NOTNULL(trailer, "Trailer pointer #1 set");
+		trailer->region_cookie++;
 
 		region = TINY_REGION_FOR_PTR(ptr2);
-		REGION_COOKIE_FOR_SMALL_REGION(region)++;
+		trailer = REGION_TRAILER_FOR_TINY_REGION(region);
+		T_ASSERT_NOTNULL(trailer, "Trailer pointer #2 set");
+		trailer->region_cookie++;
 
 		free(ptr1);
 		free(ptr2);
@@ -87,4 +93,3 @@
 		T_ASSERT_EQ(WTERMSIG(status), SIGABRT, "Child aborted");
 	}
 }
-