Bug 208703 - lib/msun/fmaxmin_test:main started failing recently with "rounding mode 0" failures; clang 3.8.0 related
Summary: lib/msun/fmaxmin_test:main started failing recently with "rounding mode 0" fa...
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Dimitry Andric
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-11 16:54 UTC by Enji Cooper
Modified: 2017-02-21 03:53 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Enji Cooper freebsd_committer 2016-04-11 16:54:14 UTC
Somewhere in the past month, lib/msun/fmaxmin_test:main started failing in testcase
6, 7, 11, and 12.

I've seen this issue on my workstation at work, on Jenkins [1], and my amd64 VM (output attached below).

It seems that "rounding mode 0" is the problem symptom.

1. https://jenkins.freebsd.org/job/FreeBSD_HEAD/183/testReport/lib.msun/fmaxmin_test/main/

$ uname -a
FreeBSD fbsd11 11.0-CURRENT FreeBSD 11.0-CURRENT #1 r296025+f1d280e(isilon-atf): Wed Apr  6 17:28:12 PDT 2016     ngie@fbsd11:/usr/obj/usr/src/git/sys/GENERIC-NODEBUG  amd64
$ kyua debug -k /usr/tests/lib/msun/Kyuafile fmaxmin_test:main
fmaxf(1, nan) raised 0x1
fmaxf(nan, 1) raised 0x1
fmax(1, nan) raised 0x1
fmax(nan, 1) raised 0x1
fminf(1, nan) raised 0x1
fminf(nan, 1) raised 0x1
fmin(1, nan) raised 0x1
fmin(nan, 1) raised 0x1
FAILURE in rounding mode 0
fmaxf(inf, nan) raised 0x1
fmaxf(nan, inf) raised 0x1
fmax(inf, nan) raised 0x1
fmax(nan, inf) raised 0x1
fminf(inf, nan) raised 0x1
fminf(nan, inf) raised 0x1
fmin(inf, nan) raised 0x1
fmin(nan, inf) raised 0x1
FAILURE in rounding mode 0
fmaxf(nan, nan) raised 0x1
fmaxf(nan, nan) raised 0x1
fmax(nan, nan) raised 0x1
fmax(nan, nan) raised 0x1
fminf(nan, nan) raised 0x1
fminf(nan, nan) raised 0x1
fmin(nan, nan) raised 0x1
fmin(nan, nan) raised 0x1
FAILURE in rounding mode 0
fmaxf(-0, 0) = -0, expected 0
fmax(-0, 0) = -0, expected 0
fminf(0, -0) = 0, expected -0
fmin(0, -0) = 0, expected -0
FAILURE in rounding mode 0
1..12
ok 1 - big = 1, small = 0
ok 2 - big = 42, small = 41.999996185302734375
ok 3 - big = 42.000003814697265625, small = 42
ok 4 - big = -5, small = -5
ok 5 - big = -3, small = -4
not ok 6 - big = 1, small = nan
not ok 7 - big = inf, small = nan
ok 8 - big = inf, small = 1
ok 9 - big = -3, small = -inf
ok 10 - big = 3, small = -inf
not ok 11 - big = nan, small = nan
not ok 12 - big = 0, small = -0
fmaxmin_test:main  ->  failed: 4 tests of 12 failed
Comment 1 Enji Cooper freebsd_committer 2016-04-11 17:05:05 UTC
clang 3.8 seems to be the problem. The test passes using either clang37 from ports or gcc 4.2.1 from base.

Reassigning to dim@.
Comment 2 Dimitry Andric freebsd_committer 2016-04-11 19:05:05 UTC
How does one run these particular tests?  I've tried "make tests", but those all appear to succeed, both on i386 and amd64.
Comment 3 Dimitry Andric freebsd_committer 2016-04-11 19:11:30 UTC
Note also that similar to the discussion started by Steve Kargl on freebsd-toolchain, "#pragma STDC FENV_ACCESS ON" is not supported by gcc or clang, and therefore testing and setting of floating point exception registers through fesetexcept(), fegetexcept() and so on have undefined behavior.

See also the discussion on LLVM PR 26931 [1] which I submitted after Steve's mails.  Eventually it boiled down to:

> You can't use these fe* functions outside of a region marked with #pragma STDC FENV_ACCESS ON.
> 
> See C11 7.6.1/2: "If part of a program tests floating-point status flags,
> sets floating-point control modes, or runs under non-default mode settings,
> but was translated with the state for the FENV_ACCESS pragma ‘‘off’’, the
> behavior is undefined."

That said, the tests work for me, probably because they're all compiled with -O0.  Maybe that in combination with a few strategic volatile qualifiers will fix the test cases.  Alternatively, we can just disable them for COMPILER_VERSION >= 38.

[1] https://llvm.org/bugs/show_bug.cgi?id=26931
Comment 4 commit-hook freebsd_committer 2016-04-14 04:41:03 UTC
A commit references this bug:

Author: ngie
Date: Thu Apr 14 04:40:31 UTC 2016
New revision: 297952
URL: https://svnweb.freebsd.org/changeset/base/297952

Log:
  Disable fmaxmin_test when compiling it with clang 3.8.0

  The testcase always fails today due to how C11 7.6.1/2 is interpreted
  with clang 3.8.0 when combined with "#pragma STDC FENV_ACCESS ON".

  This testcase passes with clang <3.8.0 and gcc, so continue testing it
  with those compiler combinations

  More intelligent discussion on the issue is in the PR

  MFC after: never
  PR: 208703
  Sponsored by: EMC / Isilon Storage Division

Changes:
  head/lib/msun/tests/Makefile
Comment 5 Enji Cooper freebsd_committer 2016-04-14 04:42:29 UTC
(In reply to Dimitry Andric from comment #3)

I disabled the testcase to give us proper time to implement a fix.

FWIW, on stable/10, running tests is done like:

> make test

On head, it's:

> make check

Be sure to run `make install` first.
Comment 6 commit-hook freebsd_committer 2016-04-21 20:00:01 UTC
A commit references this bug:

Author: ngie
Date: Thu Apr 21 19:59:55 UTC 2016
New revision: 298434
URL: https://svnweb.freebsd.org/changeset/base/298434

Log:
  Completely disable fmaxmin_test (follow up to r297952)

  COMPILER_TYPE/COMPILER_VERSION doesn't get passed down properly at
  buildworld/installworld with older build hosts

  MFC after: never
  PR: 208703, 208963
  Reported by: Jenkins
  Sponsored by: EMC / Isilon Storage Division

Changes:
  head/lib/msun/tests/Makefile
Comment 7 commit-hook freebsd_committer 2016-08-08 18:00:23 UTC
A commit references this bug:

Author: bdrewery
Date: Mon Aug  8 17:59:59 UTC 2016
New revision: 303841
URL: https://svnweb.freebsd.org/changeset/base/303841

Log:
  Revert r298434 which should be fixed by r301287, r301394, and r301403.

  PR:	208703, 208963

Changes:
  head/lib/msun/tests/Makefile
Comment 8 commit-hook freebsd_committer 2017-01-13 04:22:05 UTC
A commit references this bug:

Author: ngie
Date: Fri Jan 13 04:21:09 UTC 2017
New revision: 312012
URL: https://svnweb.freebsd.org/changeset/base/312012

Log:
  fmaxmin_test still fails with clang 3.9.x.. bypass the test

  MFC after:	3 days
  PR:		208703
  Sponsored by:	Dell EMC Isilon

Changes:
  head/lib/msun/tests/Makefile
Comment 9 commit-hook freebsd_committer 2017-01-15 09:06:02 UTC
A commit references this bug:

Author: ngie
Date: Sun Jan 15 09:05:27 UTC 2017
New revision: 312213
URL: https://svnweb.freebsd.org/changeset/base/312213

Log:
  Turn COMPILER_VERSION/COMPILER_TYPE make check into a compile-time check
  of the clang version

  This works around breakage on ^/stable/10 when running installworld from
  a ^/stable/10 host where the test wouldn't be compiled on the first
  go-around and would be missing when make installworld is run.

  MFC after:	1 week
  PR:		208703
  Reported by:	emaste
  Sponsored by:	Dell EMC Isilon

Changes:
  head/lib/msun/tests/Makefile
  head/lib/msun/tests/fmaxmin_test.c
Comment 10 commit-hook freebsd_committer 2017-02-04 17:07:50 UTC
A commit references this bug:

Author: ngie
Date: Sat Feb  4 17:06:52 UTC 2017
New revision: 313237
URL: https://svnweb.freebsd.org/changeset/base/313237

Log:
  MFC r303841,r312012,r312213:

  r303841 (by bdrewery):

  Revert r298434 which should be fixed by r301287, r301394, and r301403.

  PR:	208703, 208963

  r312012:

  fmaxmin_test still fails with clang 3.9.x.. bypass the test

  PR:		208703

  r312213:

  Turn COMPILER_VERSION/COMPILER_TYPE make check into a compile-time check
  of the clang version

  This works around breakage on ^/stable/10 when running installworld from
  a ^/stable/10 host where the test wouldn't be compiled on the first
  go-around and would be missing when make installworld is run.

  PR:		208703

Changes:
_U  stable/11/
  stable/11/lib/msun/tests/Makefile
  stable/11/lib/msun/tests/fmaxmin_test.c
Comment 11 commit-hook freebsd_committer 2017-02-04 17:07:52 UTC
A commit references this bug:

Author: ngie
Date: Sat Feb  4 17:06:52 UTC 2017
New revision: 313237
URL: https://svnweb.freebsd.org/changeset/base/313237

Log:
  MFC r303841,r312012,r312213:

  r303841 (by bdrewery):

  Revert r298434 which should be fixed by r301287, r301394, and r301403.

  PR:	208703, 208963

  r312012:

  fmaxmin_test still fails with clang 3.9.x.. bypass the test

  PR:		208703

  r312213:

  Turn COMPILER_VERSION/COMPILER_TYPE make check into a compile-time check
  of the clang version

  This works around breakage on ^/stable/10 when running installworld from
  a ^/stable/10 host where the test wouldn't be compiled on the first
  go-around and would be missing when make installworld is run.

  PR:		208703

Changes:
_U  stable/11/
  stable/11/lib/msun/tests/Makefile
  stable/11/lib/msun/tests/fmaxmin_test.c
Comment 12 commit-hook freebsd_committer 2017-02-04 17:07:55 UTC
A commit references this bug:

Author: ngie
Date: Sat Feb  4 17:06:52 UTC 2017
New revision: 313237
URL: https://svnweb.freebsd.org/changeset/base/313237

Log:
  MFC r303841,r312012,r312213:

  r303841 (by bdrewery):

  Revert r298434 which should be fixed by r301287, r301394, and r301403.

  PR:	208703, 208963

  r312012:

  fmaxmin_test still fails with clang 3.9.x.. bypass the test

  PR:		208703

  r312213:

  Turn COMPILER_VERSION/COMPILER_TYPE make check into a compile-time check
  of the clang version

  This works around breakage on ^/stable/10 when running installworld from
  a ^/stable/10 host where the test wouldn't be compiled on the first
  go-around and would be missing when make installworld is run.

  PR:		208703

Changes:
_U  stable/11/
  stable/11/lib/msun/tests/Makefile
  stable/11/lib/msun/tests/fmaxmin_test.c
Comment 13 commit-hook freebsd_committer 2017-02-14 00:55:31 UTC
A commit references this bug:

Author: ngie
Date: Tue Feb 14 00:54:48 UTC 2017
New revision: 313713
URL: https://svnweb.freebsd.org/changeset/base/313713

Log:
  Handle clang 4.x+ with the compile-time exception added in r312213

  It also fails the assertions noted in bug 208703

  PR:	208703
  PR:	217084
  Submitted by:	jbeich
  MFC after:	1 week
  Sponsored by:	Dell EMC Isilon

Changes:
  head/lib/msun/tests/fmaxmin_test.c
Comment 14 commit-hook freebsd_committer 2017-02-21 03:49:58 UTC
A commit references this bug:

Author: ngie
Date: Tue Feb 21 03:49:53 UTC 2017
New revision: 314022
URL: https://svnweb.freebsd.org/changeset/base/314022

Log:
  MFC r313713:

  Handle clang 4.x+ with the compile-time exception added in r312213

  It also fails the assertions noted in bug 208703

  PR:	208703
  PR:	217084

Changes:
_U  stable/11/
  stable/11/lib/msun/tests/fmaxmin_test.c
Comment 15 commit-hook freebsd_committer 2017-02-21 03:52:04 UTC
A commit references this bug:

Author: ngie
Date: Tue Feb 21 03:50:57 UTC 2017
New revision: 314023
URL: https://svnweb.freebsd.org/changeset/base/314023

Log:
  MFC r312213,r313713:

  r312213:

  Turn COMPILER_VERSION/COMPILER_TYPE make check into a compile-time check
  of the clang version

  This works around breakage on ^/stable/10 when running installworld from
  a ^/stable/10 host where the test wouldn't be compiled on the first
  go-around and would be missing when make installworld is run.

  PR:		208703

  r313713:

  Handle clang 4.x+ with the compile-time exception added in r312213

  It also fails the assertions noted in bug 208703

  PR:	208703
  PR:	217084

Changes:
_U  stable/10/
  stable/10/lib/msun/tests/fmaxmin_test.c
Comment 16 commit-hook freebsd_committer 2017-02-21 03:52:06 UTC
A commit references this bug:

Author: ngie
Date: Tue Feb 21 03:50:57 UTC 2017
New revision: 314023
URL: https://svnweb.freebsd.org/changeset/base/314023

Log:
  MFC r312213,r313713:

  r312213:

  Turn COMPILER_VERSION/COMPILER_TYPE make check into a compile-time check
  of the clang version

  This works around breakage on ^/stable/10 when running installworld from
  a ^/stable/10 host where the test wouldn't be compiled on the first
  go-around and would be missing when make installworld is run.

  PR:		208703

  r313713:

  Handle clang 4.x+ with the compile-time exception added in r312213

  It also fails the assertions noted in bug 208703

  PR:	208703
  PR:	217084

Changes:
_U  stable/10/
  stable/10/lib/msun/tests/fmaxmin_test.c