From b28c9408298cb2660d0446e40d8c0e856c060e3f Mon Sep 17 00:00:00 2001 From: vlefevre Date: Thu, 14 Jan 2021 17:09:05 +0000 Subject: [tests/memory.c] Call "fflush (NULL)" before abort() in order to flush all the output streams, in particular the log file (when there is one), so that setting MPFR_LOG_FLUSH (which may be inefficient) is not needed to debug tests that end with a memory error. This fixes a regression with glibc 2.27+: the streams are no longer flushed by abort(), as permitted by POSIX; see the abort(3) man page. git-svn-id: https://scm.gforge.inria.fr/anonscm/svn/mpfr/trunk@14258 280ebfd0-de03-0410-8827-d642c229c3f4 --- tests/memory.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/memory.c') diff --git a/tests/memory.c b/tests/memory.c index c97e26632..99c768087 100644 --- a/tests/memory.c +++ b/tests/memory.c @@ -72,6 +72,7 @@ mpfr_default_allocate (size_t size) fprintf (stderr, "[MPFR] mpfr_default_allocate(): " "can't allocate memory (size=%" MPFR_INTMAX_FSPEC "u)\n", (mpfr_uintmax_t) size); + fflush (NULL); abort (); } return ret; @@ -88,6 +89,7 @@ mpfr_default_reallocate (void *oldptr, size_t old_size, size_t new_size) "can't reallocate memory (old_size=%" MPFR_INTMAX_FSPEC "u new_size=%" MPFR_INTMAX_FSPEC "u)\n", (mpfr_uintmax_t) old_size, (mpfr_uintmax_t) new_size); + fflush (NULL); abort (); } return ret; @@ -134,6 +136,7 @@ tests_addsize (size_t size) fprintf (stderr, "[MPFR] tests_addsize(): " "too much memory (%" MPFR_INTMAX_FSPEC "u bytes)\n", (mpfr_uintmax_t) tests_total_size); + fflush (NULL); abort (); } } @@ -149,6 +152,7 @@ tests_allocate (size_t size) { fprintf (stderr, "[MPFR] tests_allocate(): " "attempt to allocate 0 bytes\n"); + fflush (NULL); abort (); } @@ -182,6 +186,7 @@ tests_reallocate (void *ptr, size_t old_size, size_t new_size) fprintf (stderr, "[MPFR] tests_reallocate(): " "attempt to reallocate 0x%" MPFR_INTMAX_FSPEC "X to 0 bytes\n", (mpfr_uintmax_t) (uintptr_t) ptr); + fflush (NULL); abort (); } @@ -191,6 +196,7 @@ tests_reallocate (void *ptr, size_t old_size, size_t new_size) fprintf (stderr, "[MPFR] tests_reallocate(): " "attempt to reallocate bad pointer 0x%" MPFR_INTMAX_FSPEC "X\n", (mpfr_uintmax_t) (uintptr_t) ptr); + fflush (NULL); abort (); } h = *hp; @@ -203,6 +209,7 @@ tests_reallocate (void *ptr, size_t old_size, size_t new_size) "bad old size %" MPFR_INTMAX_FSPEC "u, should be %" MPFR_INTMAX_FSPEC "u\n", (mpfr_uintmax_t) old_size, (mpfr_uintmax_t) h->size); + fflush (NULL); abort (); } @@ -226,6 +233,7 @@ tests_free_find (void *ptr) fprintf (stderr, "[MPFR] tests_free(): " "attempt to free bad pointer 0x%" MPFR_INTMAX_FSPEC "X\n", (mpfr_uintmax_t) (uintptr_t) ptr); + fflush (NULL); abort (); } return hp; @@ -261,6 +269,7 @@ tests_free (void *ptr, size_t size) fprintf (stderr, "[MPFR] tests_free(): bad size %" MPFR_INTMAX_FSPEC "u, should be %" MPFR_INTMAX_FSPEC "u\n", (mpfr_uintmax_t) size, (mpfr_uintmax_t) h->size); + fflush (NULL); abort (); } @@ -302,6 +311,7 @@ tests_memory_end (void) count++; fprintf (stderr, "[MPFR] %u blocks remaining\n", count); + fflush (NULL); abort (); } } -- cgit v1.2.1