diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2020-06-29 13:57:32 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2020-06-29 13:57:32 +0000 |
commit | 71c1e7fa6173f4f04bcfef4ad0c6987e841ea815 (patch) | |
tree | 9c9e8b86d8ec8df131dd94b43322854f3adda2a3 | |
parent | e1efdcffd64e43149c2ea83e30afb36b0c4da4a8 (diff) | |
download | mpfr-71c1e7fa6173f4f04bcfef4ad0c6987e841ea815.tar.gz |
[tests/mpfr-test.h] Avoid a GCC bug on Sparc, at least when using TLS.
The MPFR library itself is not affected, only a particular test. Normal
code using the MPFR library should not be affected either, as the bug
occurs when accessing __gmpfr_flags directly (and the public mpfr.h
header file does not provide any macro that accesses an internal
variable directly). So a workaround for the tests is the best solution.
(merged changeset r14045 from the trunk)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/4.1@14046 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | tests/mpfr-test.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/mpfr-test.h b/tests/mpfr-test.h index e33fc19ae..7e8986f3f 100644 --- a/tests/mpfr-test.h +++ b/tests/mpfr-test.h @@ -37,6 +37,52 @@ https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., #include "mpfr-impl.h" +/* Avoid a GCC bug on Sparc, at least when using TLS. The MPFR library + * itself is not affected, only a particular test. Normal code using + * the MPFR library should not be affected either, as the bug occurs + * when accessing __gmpfr_flags directly (and the public mpfr.h header + * file does not provide any macro that accesses an internal variable + * directly). So a workaround for the tests is the best solution. + * + * This bug, which could be observed under Debian with GCC 4.5.3 and + * sparc-sun-solaris2.10 with GCC 5.5.0 when TLS and optimizations + * are used[*], makes test programs using bad_cases() crash (SIGSEGV) + * in this function at: + * + * if (mpfr_nanflag_p () || mpfr_overflow_p () || mpfr_underflow_p ()) + * + * Debugging shows that any attempt to access __gmpfr_flags directly + * in the loop makes the program crash at this moment. This bug is not + * present in the assembly code generated by -S, but is visible after a + * normal compilation + link, when tracing the assembly code with gdb. + * The workaround is to disable the macros from mpfr-impl.h that access + * __gmpfr_flags directly. This bug may have been fixed in more recent + * GCC versions, but it is safe to enable this workaround in all GCC + * versions. + * + * [*] This is the default. Disabling TLS or recompiling the tests + * without optimizations (-O0) makes the crash disappear. + * + * Mentions of these crashes: + * https://sympa.inria.fr/sympa/arc/mpfr/2011-10/msg00045.html [Debian] + * https://sympa.inria.fr/sympa/arc/mpfr/2011-10/msg00055.html [Debian] + * https://sympa.inria.fr/sympa/arc/mpfr/2011-12/msg00000.html [Solaris 10] + * https://sympa.inria.fr/sympa/arc/mpfr/2011-12/msg00001.html [Solaris 10] + * https://sympa.inria.fr/sympa/arc/mpfr/2011-12/msg00002.html + * https://sympa.inria.fr/sympa/arc/mpfr/2016-03/msg00061.html [Solaris 10] + * https://sympa.inria.fr/sympa/arc/mpfr/2016-03/msg00063.html + * https://sympa.inria.fr/sympa/arc/mpfr/2020-06/msg00015.html [Solaris 10] + * https://sympa.inria.fr/sympa/arc/mpfr/2020-06/msg00020.html + */ +#if defined(__GNUC__) && defined (__sparc__) +# undef mpfr_underflow_p +# undef mpfr_overflow_p +# undef mpfr_nanflag_p +# undef mpfr_inexflag_p +# undef mpfr_erangeflag_p +# undef mpfr_divby0_p +#endif + #ifdef MPFR_TESTS_ABORT # undef exit # define exit(C) ((C) != 1 ? (exit)(C) : \ |