summaryrefslogtreecommitdiff
path: root/tests/memory.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2021-01-14 17:09:05 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2021-01-14 17:09:05 +0000
commitb28c9408298cb2660d0446e40d8c0e856c060e3f (patch)
tree6c573bbbb6b65f6ce775f0954343717e4f6e63dd /tests/memory.c
parentc35f7372ea33339ddfbf06ae58a0ae6330516f49 (diff)
downloadmpfr-b28c9408298cb2660d0446e40d8c0e856c060e3f.tar.gz
[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
Diffstat (limited to 'tests/memory.c')
-rw-r--r--tests/memory.c10
1 files changed, 10 insertions, 0 deletions
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 ();
}
}