From b136367d04bffb54f23db6f58962d3915a068517 Mon Sep 17 00:00:00 2001 From: vlefevre Date: Thu, 9 Apr 2015 15:30:58 +0000 Subject: [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 --- tests/tsum.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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 (); -- cgit v1.2.1