float.impure.test fails on OpenBSD

Bug #1137924 reported by zmyrgel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Low
Unassigned

Bug Description

I compiled the git checkout of sbcl and run the tests.
It reported that the float.impure.test fails.

$ ./run-sbcl.sh --version
(running SBCL from: /home/zmyrgel/git/sbcl)
SBCL 1.1.5.0-8f78db1
 $ uname -a
OpenBSD mandrake.wickedbsd.net 5.3 GENERIC.MP#46 amd64
$ ./run-sbcl.sh
(running SBCL from: /home/zmyrgel/git/sbcl)
This is SBCL 1.1.5.0-8f78db1, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
* *features*

(:QUICKLISP :SB-BSD-SOCKETS-ADDRINFO :ASDF2 :ASDF :ASDF-UNICODE
 :ALIEN-CALLBACKS :ANSI-CL :BSD :C-STACK-IS-CONTROL-STACK :COMMON-LISP
 :COMPARE-AND-SWAP-VOPS :COMPLEX-FLOAT-VOPS :CYCLE-COUNTER :ELF :FLOAT-EQL-VOPS
 :GENCGC :IEEE-FLOATING-POINT :INLINE-CONSTANTS :LINKAGE-TABLE :LITTLE-ENDIAN
 :MEMORY-BARRIER-VOPS :MULTIPLY-HIGH-VOPS :OPENBSD :OS-PROVIDES-DLADDR
 :OS-PROVIDES-DLOPEN :OS-PROVIDES-POLL :OS-PROVIDES-PUTWC
 :OS-PROVIDES-SUSECONDS-T :PACKAGE-LOCAL-NICKNAMES :RAW-INSTANCE-INIT-VOPS
 :SB-DOC :SB-EVAL :SB-LDB :SB-PACKAGE-LOCKS :SB-SOURCE-LOCATIONS :SB-TEST
 :SB-UNICODE :SBCL :STACK-ALLOCATABLE-CLOSURES :STACK-ALLOCATABLE-FIXED-OBJECTS
 :STACK-ALLOCATABLE-LISTS :STACK-ALLOCATABLE-VECTORS
 :STACK-GROWS-DOWNWARD-NOT-UPWARD :UNIX :UNWIND-TO-FRAME-AND-CALL-VOP :X86-64)
*

$ sh run-tests.sh float.impure.lisp
/running tests on '/home/zmyrgel/git/sbcl/tests/../src/runtime/sbcl --core /home/zmyrgel/git/sbcl/tests/../output/sbcl.core --noinform --no-sysinit --no-userinit --noprint --disable-debugger'

; file: /home/zmyrgel/git/sbcl/tests/test-util.lisp
; in: DEFMACRO WITH-TEST
; (LET ((TEST-UTIL::BLOCK-NAME (GENSYM))
; (TEST-UTIL::THREADS (GENSYM "THREADS")))
; `(PROGN
; (TEST-UTIL::START-TEST)
; (COND
; ((TEST-UTIL::BROKEN-P ,TEST-UTIL::BROKEN-ON)
; (TEST-UTIL::FAIL-TEST :SKIPPED-BROKEN ',TEST-UTIL::NAME
; "Test broken on this platform"))
; ((TEST-UTIL::SKIPPED-P ,TEST-UTIL::SKIPPED-ON)
; (TEST-UTIL::FAIL-TEST :SKIPPED-DISABLED ',TEST-UTIL::NAME
; "Test disabled for this combination of platform and features"))
; (T
; (LET #
; #)))))
;
; caught STYLE-WARNING:
; The variable THREADS is defined but never used.
;
; compilation unit finished
; caught 1 STYLE-WARNING condition
// Running pure tests (#<FUNCTION RUN-TESTS::LOAD-TEST>)
// Running pure tests (#<FUNCTION RUN-TESTS::CLOAD-TEST>)
// Running impure tests (#<FUNCTION RUN-TESTS::LOAD-TEST>)

; file: /home/zmyrgel/git/sbcl/tests/test-util.lisp
; in: DEFMACRO WITH-TEST
; (LET ((TEST-UTIL::BLOCK-NAME (GENSYM))
; (TEST-UTIL::THREADS (GENSYM "THREADS")))
; `(PROGN
; (TEST-UTIL::START-TEST)
; (COND
; ((TEST-UTIL::BROKEN-P ,TEST-UTIL::BROKEN-ON)
; (TEST-UTIL::FAIL-TEST :SKIPPED-BROKEN ',TEST-UTIL::NAME
; "Test broken on this platform"))
; ((TEST-UTIL::SKIPPED-P ,TEST-UTIL::SKIPPED-ON)
; (TEST-UTIL::FAIL-TEST :SKIPPED-DISABLED ',TEST-UTIL::NAME
; "Test disabled for this combination of platform and features"))
; (T
; (LET #
; #)))))
; ; caught STYLE-WARNING:
; The variable THREADS is defined but never used.
;
; compilation unit finished
; caught 1 STYLE-WARNING condition
// Running /home/zmyrgel/git/sbcl/tests/float.impure.lisp
::: SKIPPED-DISABLED (:RANGE-REDUCTION :X87)
    Test disabled for this combination of platform and features
::: Running (:RANGE-REDUCTION :PRECISE-PI)
::: UNEXPECTED-FAILURE (:RANGE-REDUCTION :PRECISE-PI)
    due to #<SIMPLE-ERROR "Inaccurate result for ~a: expected ~a, got ~a"
             {100364AD83}>:
        "Inaccurate result for (SIN
                                4.611686018427388d18): expected -0.7029224436192087d0, got -0.7071329274527789d0"
// Running impure tests (#<FUNCTION RUN-TESTS::CLOAD-TEST>)
// Running impure tests (#<FUNCTION RUN-TESTS::SH-TEST>)

Finished running tests.
Status:
 Failure: float.impure.lisp / (RANGE-REDUCTION PRECISE-PI)
 (1 tests skipped for this combination of platform and features)
test failed, expected 104 return code, got 1
$

Lutz Euler (lutz-euler)
Changed in sbcl:
status: New → Triaged
importance: Undecided → Low
Revision history for this message
Lutz Euler (lutz-euler) wrote :

zmyrgel, thanks for running the tests and for the report!

It seems your system's math library implements the trigonometric functions using the x87 FPU instructions instead of SSE, at least the result for (SIN 4.611686018427388d18) you get is the one that one gets on a 32-bit x86 SBCL, which uses x87. As your system is x86-64 this is surprising (to me - I haven't seen a 64-bit system using x87 yet).

Could you please verify that your system gets the correct results as x87 would calculate them, as follows:

In the file tests/float.impure.lisp activate the test ":range-reduction :x87" and deactivate the test ":range-reduction :precise-pi", for example by exchanging the ":skipped-on" clauses between the two tests, then run "sh run-tests.sh float.impure.lisp" again and report the result. Thanks!

Revision history for this message
zmyrgel (timo-myyra) wrote :

The test fails still when reversing the tests:

/running tests on '/home/zmyrgel/git/sbcl/tests/../src/runtime/sbcl --core /home/zmyrgel/git/sbcl/tests/../output/sbcl.core --noinform --no-sysinit --no-userinit --noprint --disable-debugger'

; file: /home/zmyrgel/git/sbcl/tests/test-util.lisp
; in: DEFMACRO WITH-TEST
; (LET ((TEST-UTIL::BLOCK-NAME (GENSYM))
; (TEST-UTIL::THREADS (GENSYM "THREADS")))
; `(PROGN
; (TEST-UTIL::START-TEST)
; (COND
; ((TEST-UTIL::BROKEN-P ,TEST-UTIL::BROKEN-ON)
; (TEST-UTIL::FAIL-TEST :SKIPPED-BROKEN ',TEST-UTIL::NAME
; "Test broken on this platform"))
; ((TEST-UTIL::SKIPPED-P ,TEST-UTIL::SKIPPED-ON)
; (TEST-UTIL::FAIL-TEST :SKIPPED-DISABLED ',TEST-UTIL::NAME
; "Test disabled for this combination of platform and features"))
; (T
; (LET #
; #)))))
;
; caught STYLE-WARNING:
; The variable THREADS is defined but never used.
;
; compilation unit finished
; caught 1 STYLE-WARNING condition
// Running pure tests (#<FUNCTION RUN-TESTS::LOAD-TEST>)
// Running pure tests (#<FUNCTION RUN-TESTS::CLOAD-TEST>)
// Running impure tests (#<FUNCTION RUN-TESTS::LOAD-TEST>)

; file: /home/zmyrgel/git/sbcl/tests/test-util.lisp
; in: DEFMACRO WITH-TEST
; (LET ((TEST-UTIL::BLOCK-NAME (GENSYM))
; (TEST-UTIL::THREADS (GENSYM "THREADS")))
; `(PROGN
; (TEST-UTIL::START-TEST)
; (COND
; ((TEST-UTIL::BROKEN-P ,TEST-UTIL::BROKEN-ON)
; (TEST-UTIL::FAIL-TEST :SKIPPED-BROKEN ',TEST-UTIL::NAME
; "Test broken on this platform"))
; ((TEST-UTIL::SKIPPED-P ,TEST-UTIL::SKIPPED-ON)
; (TEST-UTIL::FAIL-TEST :SKIPPED-DISABLED ',TEST-UTIL::NAME
; "Test disabled for this combination of platform and features"))
; (T
; (LET #
; #)))))
;
; caught STYLE-WARNING:
; The variable THREADS is defined but never used.
;
; compilation unit finished
; caught 1 STYLE-WARNING condition
// Running /home/zmyrgel/git/sbcl/tests/float.impure.lisp
::: Running (:RANGE-REDUCTION :X87)
::: UNEXPECTED-FAILURE (:RANGE-REDUCTION :X87)
    due to #<SIMPLE-ERROR "The assertion ~S failed." {10036C1E73}>:
        "The assertion (ALMOST= (SIN (MOD BIG (* 2 PI))) (SIN BIG)) failed."
::: SKIPPED-DISABLED (:RANGE-REDUCTION :PRECISE-PI)
    Test disabled for this combination of platform and features
// Running impure tests (#<FUNCTION RUN-TESTS::CLOAD-TEST>)
// Running impure tests (#<FUNCTION RUN-TESTS::SH-TEST>)

Finished running tests.
Status:
 Failure: float.impure.lisp / (RANGE-REDUCTION X87)
 (1 tests skipped for this combination of platform and features)
test failed, expected 104 return code, got 1

Revision history for this message
Lutz Euler (lutz-euler) wrote :

Fine. So my suspicion that it uses x87 is probably wrong. It seems OpenBSD has found a third way to do trigonometric range reduction outside of what x87 or Linux libm on x86-64 do. But I'd like to see how far it differs from x87, so I have in the meantime committed a change to the x87 test so that it outputs more details.

May I ask you to pull a new SBCL (you need at least 1.1.5-2), build it, modify the tests like before so that the one for x87 is activated, run "sh run-tests.sh float.impure.lisp" and paste the output here?

Thanks in advance!

Revision history for this message
zmyrgel (timo-myyra) wrote :

Here's the output:

$ sh run-tests.sh float.impure.lisp
/running tests on '/home/zmyrgel/git/sbcl/tests/../src/runtime/sbcl --core /home/zmyrgel/git/sbcl/tests/../output/sbcl.core --noinform --no-sysinit --no-userinit --noprint --disable-debugger'
// Running pure tests (#<FUNCTION RUN-TESTS::LOAD-TEST>)
// Running pure tests (#<FUNCTION RUN-TESTS::CLOAD-TEST>)
// Running impure tests (#<FUNCTION RUN-TESTS::LOAD-TEST>)
// Running /home/zmyrgel/git/sbcl/tests/float.impure.lisp
::: Running (:RANGE-REDUCTION :X87)
::: UNEXPECTED-FAILURE (:RANGE-REDUCTION :X87)
    due to #<SIMPLE-ERROR "Inaccurate result for ~a: expected ~a, got ~a"
             {1003925F83}>:
        "Inaccurate result for (SIN
                                3.708937962535487d21): expected 0.0d0, got -0.8792229689034846d0"
::: SKIPPED-DISABLED (:RANGE-REDUCTION :PRECISE-PI)
    Test disabled for this combination of platform and features
// Running impure tests (#<FUNCTION RUN-TESTS::CLOAD-TEST>)
// Running impure tests (#<FUNCTION RUN-TESTS::SH-TEST>)

Finished running tests.
Status:
 Failure: float.impure.lisp / (RANGE-REDUCTION X87)
 (1 tests skipped for this combination of platform and features)
test failed, expected 104 return code, got 1
$

Revision history for this message
Lutz Euler (lutz-euler) wrote :

OK, this result is completely different from the x87 one.

We have for (SIN 3.708937962535487d21):

x87 (x86 Linux): 0.0d0
x86-64 Linux: 0.999508127153045d0
x86-64 OpenBSD: -0.8792229689034846d0

So, definitely OpenBSD uses a range reduction method differing from the two we have tests for so far.

I personally think it is not terribly important to be able to run this test on OpenBSD x86-64; the original test was written because there was a bug in the x87 range reduction, and I later added the version for GNU libm as that is widely used on platforms SBCL runs on. So my plan would be to skip the :precise-pi test under OpenBSD.

Or would that be too broad? After all the test was added more than half a year ago. Did nobody run it so far under OpenBSD? Or did a recent OpenBSD upgrade bring a different math library with it? What about the other BSDs?

Revision history for this message
zmyrgel (timo-myyra) wrote :

The SBCL port on OpenBSD was updated today to 1.1.5 and the previous version was 1.0.58 so it might have gone unnoticed.
Just build the 1.1.5 version from the ports tree and the failure happens in there too.
The math library hasn't changed recently.

Douglas Katzman (dougk)
Changed in sbcl:
status: Triaged → Incomplete
Stas Boukarev (stassats)
Changed in sbcl:
status: Incomplete → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.