diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2015-04-09 15:30:58 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2015-04-09 15:30:58 +0000 |
commit | b136367d04bffb54f23db6f58962d3915a068517 (patch) | |
tree | 7d0f3efe2ba4b663d87275b35e1ebd1d8caffbeb | |
parent | 1164fe25c6cba4b8c1ed2e2fda6c61814749d202 (diff) | |
download | mpfr-b136367d04bffb54f23db6f58962d3915a068517.tar.gz |
[tests/tsum.c] Added a simple test that triggers a glibc free() error
or segmentation fault when MPFR is configured with GMP 6.0.0 built
with "--disable-alloca ABI=32". GCC's address sanitizer shows a
heap-buffer-overflow. This is mainly for debugging as this problem
also occurs in other tests (it is quite generic).
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/new-sum@9367 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | tests/tsum.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/tsum.c b/tests/tsum.c index 1e379aa92..e1f1c9fda 100644 --- a/tests/tsum.c +++ b/tests/tsum.c @@ -135,6 +135,35 @@ generic_tests (void) (*__gmp_free_func) (p, nmax * sizeof(mpfr_ptr)); } +/* glibc free() error or segmentation fault when configured + * with GMP 6.0.0 built with "--disable-alloca ABI=32". + * GCC's address sanitizer shows a heap-buffer-overflow. + */ +static +void check_simple (void) +{ + mpfr_t tab[3], r; + mpfr_ptr tabp[3]; + int i; + + mpfr_init2 (r, 16); + for (i = 0; i < 3; i++) + { + mpfr_init2 (tab[i], 16); + mpfr_set_ui (tab[i], 1, MPFR_RNDN); + tabp[i] = tab[i]; + } + + i = mpfr_sum (r, tabp, 3, MPFR_RNDN); + if (mpfr_cmp_ui (r, 3) || i != 0) + { + printf ("Error in check_simple\n"); + exit (1); + } + + mpfr_clears (tab[0], tab[1], tab[2], r, (mpfr_ptr) 0); +} + static void check_special (void) { @@ -1052,6 +1081,7 @@ main (void) { tests_start_mpfr (); + check_simple (); check_special (); check_more_special (); check1 (); |