/* Layout of an in-use block:
this block total szB (sizeof(SizeT) bytes)
- red zone bytes (depends on Arena.rz_szB, but > sizeof(void*))
+ red zone bytes (depends on Arena.rz_szB, but >= sizeof(void*))
(payload bytes)
- red zone bytes (depends on Arena.rz_szB, but > sizeof(void*))
+ red zone bytes (depends on Arena.rz_szB, but >= sizeof(void*))
this block total szB (sizeof(SizeT) bytes)
Layout of a block on the free list:
SizeT i;
Arena* a = arenaId_to_ArenaP(aid);
- vg_assert(rz_szB < 128); // ensure reasonable size
+ // Ensure redzones are a reasonable size. They must always be at least
+ // the size of a pointer, for holding the prev/next pointer (see the layout
+ // details at the top of this file).
+ vg_assert(rz_szB < 128);
+ if (rz_szB < sizeof(void*)) rz_szB = sizeof(void*);
+
vg_assert((min_sblock_szB % VKI_PAGE_SIZE) == 0);
a->name = name;
a->clientmem = ( VG_AR_CLIENT == aid ? True : False );
noinst_SCRIPTS = filter_stderr
EXTRA_DIST = $(noinst_SCRIPTS) \
+ basic_malloc.stderr.exp basic_malloc.vgtest \
toobig-allocs.stderr.exp toobig-allocs.vgtest \
true_html.stderr.exp true_html.vgtest \
true_text.stderr.exp true_text.vgtest
+AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -g
+
+check_PROGRAMS = \
+ basic_malloc
+
--- /dev/null
+// In 3.0.0, Massif was badly broken on 64-bit platforms because it asked
+// zero-sized redzones, and the allocator was forgetting to round the size
+// up to sizeof(void*), which is the minimum. This caused bugs #111090 and
+// #111285. This test is just a gentle allocation exercise which was
+// failing.
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#define NN 100
+
+int main(void)
+{
+ int i;
+ char* a[NN];
+
+ for (i = i; i < NN; i++) {
+ a[i] = malloc(i);
+ }
+
+ for (i = i; i < NN; i++) {
+ a[i] = realloc(a[i], NN - i);
+ }
+
+ for (i = i; i < NN; i++) {
+ free(a[i]);
+ }
+
+ return 0;
+}
+