[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Buggy ceill on OpenBSD, and possible gnulib test problem
From: |
Assaf Gordon |
Subject: |
Buggy ceill on OpenBSD, and possible gnulib test problem |
Date: |
Wed, 12 Aug 2015 18:08:11 +0000 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Hello,
Two somewhat-related issue:
1. On OpenBSD (at least 5.6,5.7, but likely since 5.4), ceill() is
buggy, and returns wrong results for some values.
2. But, the gnulib tests do not detect this error, and I suspect (if I
debugged it correctly), that GCC uses its built-in ceill implementation
to optimize away the ceill calls, thus rendering the test suite
ineffective.
comments and feedback are appreciated.
-assaf
More details:
1. The OpenBSD/ceill bug is reported here
http://marc.info/?l=openbsd-misc&m=143888790517523
and confirmed by few other people.
possible fix for OpenBSD's libm is suggested here:
http://marc.info/?l=openbsd-tech&m=143889843320681
http://marc.info/?l=openbsd-misc&m=143931434715031
I encountered it with in my program (datamash) that returned wrong
results on OpenBSD. Datamash uses gnulib, but gnulib's ceill.m4
determined it is OK to use the system's ceill version).
2. To see why gnulib didn't notice the buggy ceill,
I used the following (on OpenBSD):
git clone git://git.sv.gnu.org/gnulib.git
cd gnulib/
./gnulib-tool --test --create-testdir --dir foobar ceill
cd foobar/
./configure CFLAGS="-g -O0"
make
make check
which gives:
===============================
Testsuite summary for dummy 0
===============================
# TOTAL: 18
# PASS: 18
When repeating the test with disabled GCC built-ins, the ceill indeed
fails (as it should, because it is buggy in OpenBSD):
./configure CFLAGS="-g -O0 -fno-builtin"
make
make check
Which gives:
FAIL: test-ceill
================
test-ceill.c:46: assertion 'ceill (0.3L) == 1.0L' failed
Abort trap (core dumped)
FAIL test-ceill (exit status: 134)
This can also be observed if one disassemble the generated code for
'test-ceill':
./configure CFLAGS="-g -O0"
make
objdump -S -d -M intel gltests/test-ceill.o
You'll see that for most of the ASSER(ceill()) calls, no code is
generated at all. It is only generated for calls such as
ASSERT (ceill (minus_zerol) == 0.0L);
ASSERT (ceill (Infinityl ()) == Infinityl ())
ASSERT (isnanl (ceill (NaNl ())));
ASSERT (ceill (- Infinityl ()) == - Infinityl ());
for which (I guess) the GCC builtins don't work.
-----
Suggested fix:
1. Based on a long list of GCC builtins
(https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html), perhaps add
"-fno-builtin" to all the gnulib tests? or at least the math related
ones?
2. Similar to 'gl_cv_func_expl_buggy' in 'm4/expl.m4',
add 'gl_cv_func_ceill_buggy' in 'm4/ceill.m4'.
Possible patch attached (tested on OpenBSD5.7+gcc 4.2.1, but not much
elsewhere).
gnulib-ceill-buggy.patch
Description: Text Data
- Buggy ceill on OpenBSD, and possible gnulib test problem,
Assaf Gordon <=