ftmemsim-valgrind/massif/tests/basic_malloc.c
Nicholas Nethercote 281297db9f Fix a problem I introduced in r4208 when reducing the space used by
heap blocks.  The minimum size for redzones is now sizeof(void*), but
I forgot to ensure this.  Massif was asking for 0 byte redzones, and this
was screwing things up on 64-bit platforms, and Massif was dying very
quickly.  This should fix bugs #111090 and #111285.

The fact that Massif was this badly broken but there were only 2 bug reports
indicates that not many people are using it, at least not on AMD64.

I also added a regtest that does some basic malloc/realloc/free testing
for Massif, which would have caught this problem.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4492
2005-08-24 22:38:00 +00:00

32 lines
621 B
C

// 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;
}