public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug math/15491] New: x86 nearbyint implementations wrongly clear all exceptions
@ 2013-05-19 18:38 jsm28 at gcc dot gnu.org
  2014-02-06 18:33 ` [Bug math/15491] [i386/x86_64] " jsm28 at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2013-05-19 18:38 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=15491

             Bug #: 15491
           Summary: x86 nearbyint implementations wrongly clear all
                    exceptions
           Product: glibc
           Version: 2.17
            Status: NEW
          Severity: normal
          Priority: P2
         Component: math
        AssignedTo: unassigned@sourceware.org
        ReportedBy: jsm28@gcc.gnu.org
    Classification: Unclassified


The implementations of nearbyint functions using x87 floating point (x86 all
versions, x86_64 long double only) use the fclex instruction, which clears any
exceptions that were raised before the function was called.  These functions
must not clear exceptions that were raised before they were called.

I think fixing this will require saving and restoring the whole floating-point
environment as the way of avoiding raising "inexact" (which is what fesetenv
does, so use of frndint should still be faster than the C versions) - except
that if frndint raises an "invalid" exception for a sNaN operand, that *should*
be added into the restored environment.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug math/15491] [i386/x86_64] x86 nearbyint implementations wrongly clear all exceptions
  2013-05-19 18:38 [Bug math/15491] New: x86 nearbyint implementations wrongly clear all exceptions jsm28 at gcc dot gnu.org
@ 2014-02-06 18:33 ` jsm28 at gcc dot gnu.org
  2014-06-13 17:43 ` fweimer at redhat dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2014-02-06 18:33 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=15491

Joseph Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
               Host|                            |i?86-*-* x86_64-*-*
            Summary|x86 nearbyint               |[i386/x86_64] x86 nearbyint
                   |implementations wrongly     |implementations wrongly
                   |clear all exceptions        |clear all exceptions

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug math/15491] [i386/x86_64] x86 nearbyint implementations wrongly clear all exceptions
  2013-05-19 18:38 [Bug math/15491] New: x86 nearbyint implementations wrongly clear all exceptions jsm28 at gcc dot gnu.org
  2014-02-06 18:33 ` [Bug math/15491] [i386/x86_64] " jsm28 at gcc dot gnu.org
@ 2014-06-13 17:43 ` fweimer at redhat dot com
  2015-10-22 23:16 ` cvs-commit at gcc dot gnu.org
  2015-10-22 23:17 ` jsm28 at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: fweimer at redhat dot com @ 2014-06-13 17:43 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=15491

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug math/15491] [i386/x86_64] x86 nearbyint implementations wrongly clear all exceptions
  2013-05-19 18:38 [Bug math/15491] New: x86 nearbyint implementations wrongly clear all exceptions jsm28 at gcc dot gnu.org
  2014-02-06 18:33 ` [Bug math/15491] [i386/x86_64] " jsm28 at gcc dot gnu.org
  2014-06-13 17:43 ` fweimer at redhat dot com
@ 2015-10-22 23:16 ` cvs-commit at gcc dot gnu.org
  2015-10-22 23:17 ` jsm28 at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2015-10-22 23:16 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=15491

--- Comment #1 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  846d9a4a3acdb4939ca7bf6aed48f9f6f26911be (commit)
      from  45ccb8346bba9b0f7a72a92d7f8b1c796dd496ba (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=846d9a4a3acdb4939ca7bf6aed48f9f6f26911be

commit 846d9a4a3acdb4939ca7bf6aed48f9f6f26911be
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Thu Oct 22 23:14:55 2015 +0000

    Fix i386 / x86_64 nearbyint exception clearing (bug 15491).

    The implementations of nearbyint functions using x87 floating point
    (i386 all versions, x86_64 long double only) use the fclex
    instruction, which clears any exceptions that were raised before the
    function was called.  These functions must not clear exceptions that
    were raised before they were called.

    This patch fixes these functions to save and restore the whole
    floating-point environment (fnstenv / fldenv) as the way of avoiding
    raising "inexact" (recall that there isn't an x87 instruction for
    loading just the status word, so the whole environment has to be saved
    and loaded instead - the code already saved and loaded the control
    word, which is now obtained from the saved environment after this
    patch, to disable traps on "inexact").  In the case of the long double
    functions, any "invalid" exception from frndint (applied to a
    signaling NaN) needs merging into the saved state; this issue doesn't
    apply to the float and double functions because that exception would
    have been raised when the argument is loaded, before the environment
    is saved.

        [BZ #15491]
        * sysdeps/i386/fpu/s_nearbyint.S (__nearbyint): Save and restore
        floating-point environment instead of clearing all exceptions.
        * sysdeps/i386/fpu/s_nearbyintf.S (__nearbyintf): Likewise.
        * sysdeps/i386/fpu/s_nearbyintl.S (__nearbyintl): Likewise,
        merging in "invalid" exceptions from frndint.
        * sysdeps/x86_64/fpu/s_nearbyintl.S (__nearbyintl): Likewise.
        * math/test-nearbyint-except.c: New file.
        * math/Makefile (tests): Add test-nearbyint-except.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                         |   12 +++++
 NEWS                              |   24 +++++-----
 math/Makefile                     |    2 +-
 math/test-nearbyint-except.c      |   82 +++++++++++++++++++++++++++++++++++++
 sysdeps/i386/fpu/s_nearbyint.S    |   23 ++++------
 sysdeps/i386/fpu/s_nearbyintf.S   |   23 ++++------
 sysdeps/i386/fpu/s_nearbyintl.S   |   26 +++++------
 sysdeps/x86_64/fpu/s_nearbyintl.S |   14 ++++---
 8 files changed, 145 insertions(+), 61 deletions(-)
 create mode 100644 math/test-nearbyint-except.c

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug math/15491] [i386/x86_64] x86 nearbyint implementations wrongly clear all exceptions
  2013-05-19 18:38 [Bug math/15491] New: x86 nearbyint implementations wrongly clear all exceptions jsm28 at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2015-10-22 23:16 ` cvs-commit at gcc dot gnu.org
@ 2015-10-22 23:17 ` jsm28 at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2015-10-22 23:17 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=15491

Joseph Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |2.23

--- Comment #2 from Joseph Myers <jsm28 at gcc dot gnu.org> ---
Fixed for 2.23.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-10-22 23:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-19 18:38 [Bug math/15491] New: x86 nearbyint implementations wrongly clear all exceptions jsm28 at gcc dot gnu.org
2014-02-06 18:33 ` [Bug math/15491] [i386/x86_64] " jsm28 at gcc dot gnu.org
2014-06-13 17:43 ` fweimer at redhat dot com
2015-10-22 23:16 ` cvs-commit at gcc dot gnu.org
2015-10-22 23:17 ` jsm28 at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).