From: Julian Seward Date: Wed, 19 Dec 2007 11:01:13 +0000 (+0000) Subject: Add a couple of regtests for large stack frame management. X-Git-Tag: svn/VALGRIND_3_4_0~1125 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0f3db08246d826d7f65ea6aa10d404aabbf2c9c5;p=thirdparty%2Fvalgrind.git Add a couple of regtests for large stack frame management. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7303 --- diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index ca83667ecb..b593d24831 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -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 \ diff --git a/memcheck/tests/lsframe1.c b/memcheck/tests/lsframe1.c new file mode 100644 index 0000000000..9133199a3f --- /dev/null +++ b/memcheck/tests/lsframe1.c @@ -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 + +#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; +} diff --git a/memcheck/tests/lsframe1.stderr.exp b/memcheck/tests/lsframe1.stderr.exp new file mode 100644 index 0000000000..e85ce38002 --- /dev/null +++ b/memcheck/tests/lsframe1.stderr.exp @@ -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 diff --git a/memcheck/tests/lsframe1.stdout.exp b/memcheck/tests/lsframe1.stdout.exp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/memcheck/tests/lsframe1.vgtest b/memcheck/tests/lsframe1.vgtest new file mode 100644 index 0000000000..fbdc190ceb --- /dev/null +++ b/memcheck/tests/lsframe1.vgtest @@ -0,0 +1,2 @@ +prog: lsframe1 +vgopts: --main-stacksize=67200000 --max-stackframe=67200000 diff --git a/memcheck/tests/lsframe2.c b/memcheck/tests/lsframe2.c new file mode 100644 index 0000000000..173440825e --- /dev/null +++ b/memcheck/tests/lsframe2.c @@ -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 + +#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; +} diff --git a/memcheck/tests/lsframe2.stderr.exp b/memcheck/tests/lsframe2.stderr.exp new file mode 100644 index 0000000000..2eb8c047b2 --- /dev/null +++ b/memcheck/tests/lsframe2.stderr.exp @@ -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 diff --git a/memcheck/tests/lsframe2.stdout.exp b/memcheck/tests/lsframe2.stdout.exp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/memcheck/tests/lsframe2.vgtest b/memcheck/tests/lsframe2.vgtest new file mode 100644 index 0000000000..690a4079e2 --- /dev/null +++ b/memcheck/tests/lsframe2.vgtest @@ -0,0 +1,2 @@ +prog: lsframe2 +vgopts: --main-stacksize=68500000