Add a couple of regtests for large stack frame management.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7303
This commit is contained in:
Julian Seward 2007-12-19 11:01:13 +00:00
parent 4f282e99ce
commit 0f3db08246
9 changed files with 85 additions and 0 deletions

View File

@ -66,6 +66,8 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
leakotron.vgtest leakotron.stdout.exp leakotron.stderr.exp \
long_namespace_xml.vgtest long_namespace_xml.stdout.exp \
long_namespace_xml.stderr.exp \
lsframe1.vgtest lsframe1.stdout.exp lsframe1.stderr.exp \
lsframe2.vgtest lsframe2.stdout.exp lsframe2.stderr.exp \
malloc_free_fill.vgtest malloc_free_fill.stdout.exp \
malloc_free_fill.stderr.exp-glibc25-amd64 \
malloc_free_fill.stderr.exp-glibc25-x86 \
@ -160,6 +162,7 @@ check_PROGRAMS = \
fprw fwrite hello inits inline \
leak-0 leak-cycle leak-pool leak-tree leak-regroot leakotron \
long_namespace_xml \
lsframe1 lsframe2 \
malloc_free_fill \
malloc_usable malloc1 malloc2 malloc3 manuel1 manuel2 manuel3 \
match-overrun \

26
memcheck/tests/lsframe1.c Normal file
View File

@ -0,0 +1,26 @@
/* Demonstrate Memcheck correctly handling a 64M array on the stack.
Requires --max-stackframe=67108884 or above. And since it
generates a very large stack, --main-stacksize=67200000
(approximately) is also required. */
#include <stdio.h>
#define N_MBYTES 64
#define N_INTS ((N_MBYTES * 1048576) / sizeof(int))
int main ( void )
{
int i, sum;
int arr[N_INTS];
fprintf(stderr, "lsframe1: start\n");
for (i = 0; i < N_INTS; i++)
arr[i] = i;
sum = 0;
for (i = 0; i < N_INTS; i++)
sum += arr[i];
fprintf(stderr, "lsframe1: done, result is %d\n", sum);
return 0;
}

View File

@ -0,0 +1,9 @@
lsframe1: start
lsframe1: done, result is -8388608
ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
malloc/free: in use at exit: 0 bytes in 0 blocks.
malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
For a detailed leak analysis, rerun with: --leak-check=yes
For counts of detected errors, rerun with: -v

View File

View File

@ -0,0 +1,2 @@
prog: lsframe1
vgopts: --main-stacksize=67200000 --max-stackframe=67200000

34
memcheck/tests/lsframe2.c Normal file
View File

@ -0,0 +1,34 @@
/* Demonstrate Memcheck correctly handling chain of 64 recursive
calls, each of which allocates a 1 M array on the stack. Requires
--main-stacksize=67117057 (on amd64-linux) or above, but works fine
if you specify that. */
#include <stdio.h>
#define N_MBYTES 64
#define N_INTS_PER_MBYTE (1048576 / sizeof(int))
int rec ( int depth )
{
int i, zzz;
int arr[N_INTS_PER_MBYTE];
if (depth == 0) return 0;
for (i = 0; i < N_INTS_PER_MBYTE; i++)
arr[i] = i * depth;
zzz = rec(depth-1);
for (i = 0; i < N_INTS_PER_MBYTE; i++)
zzz += arr[i];
return zzz;
}
int main ( void )
{
int sum;
fprintf(stderr, "lsframe2: start\n");
sum = rec(N_MBYTES);
fprintf(stderr, "lsframe2: done, result is %d\n", sum);
return 0;
}

View File

@ -0,0 +1,9 @@
lsframe2: start
lsframe2: done, result is -272629760
ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
malloc/free: in use at exit: 0 bytes in 0 blocks.
malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
For a detailed leak analysis, rerun with: --leak-check=yes
For counts of detected errors, rerun with: -v

View File

View File

@ -0,0 +1,2 @@
prog: lsframe2
vgopts: --main-stacksize=68500000