RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2183081 - glibc: Incorrect x86 inline feraiseexcept
Summary: glibc: Incorrect x86 inline feraiseexcept
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: glibc
Version: 8.5
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Florian Weimer
QA Contact: Martin Coufal
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-03-30 11:15 UTC by Jakub Jelinek
Modified: 2023-11-14 18:04 UTC (History)
7 users (show)

Fixed In Version: glibc-2.28-226.el8
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-11-14 15:49:05 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
GNU Compiler Collection 109344 0 P3 RESOLVED feraiseexcept produces incorrect code when optimizations are enabled 2023-04-03 07:48:02 UTC
Red Hat Issue Tracker RHELPLAN-153552 0 None None None 2023-03-30 11:16:13 UTC
Red Hat Product Errata RHBA-2023:7107 0 None None None 2023-11-14 15:49:34 UTC
Sourceware 30305 0 P2 NEW Incorrect asm constraint in feraiseexcept on x86-64 2023-04-03 07:48:02 UTC

Description Jakub Jelinek 2023-03-30 11:15:49 UTC
As mentioned in https://gcc.gnu.org/PR109344, the RHEL 8 (likely older RHEL too, RHEL 9 seems to be fine) glibc /usr/include/bits/fenv.h header contains an incorrect
inline version of feraiseexcept:
      /* One example of an invalid operation is 0.0 / 0.0.  */
      float __f = 0.0;

# ifdef __SSE_MATH__
      __asm__ __volatile__ ("divss %0, %0 " : : "x" (__f));
# else
      __asm__ __volatile__ ("fdiv %%st, %%st(0); fwait"
                            : "=t" (__f) : "0" (__f));
# endif
and
      float __f = 1.0;
      float __g = 0.0;

# ifdef __SSE_MATH__
      __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
# else
      __asm__ __volatile__ ("fdivp %%st, %%st(1); fwait"
                            : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
# endif
is incorrect for defined(__SSE_MATH__), because it modifies whatever register holds __f without telling the compiler about it.
It should be
      __asm__ __volatile__ ("divss %0, %0 " : "+x" (__f));
and
      __asm__ __volatile__ ("divss %1, %0" : "+x" (__f) : "x" (__g));
Without that, GCC can assume after pxor %xmm0, %xmm0 that %xmm0 contains 0.0
even after divss %xmm0, %xmm0, which is not the case, it is then qNaN, and so doesn't raise division by zero exception when trying to divide 1.0 by that.

Comment 1 Florian Weimer 2023-04-21 13:17:55 UTC
The out-of-line copy was fixed upstream via:

commit 5d1ccdda7b0c625751661d50977f3dfbc73f8eae
Author: Florian Weimer <fweimer>
Date:   Mon Apr 3 17:23:11 2023 +0200

    x86_64: Fix asm constraints in feraiseexcept (bug 30305)
    
    The divss instruction clobbers its first argument, and the constraints
    need to reflect that.  Fortunately, with GCC 12, generated code does
    not actually change, so there is no externally visible bug.
    
    Suggested-by: Jakub Jelinek <jakub>
    Reviewed-by: Noah Goldstein <goldstein.w.n>

A similar fix needs to be applied to the installed headers, as Jakub kindly explained.

Comment 2 Florian Weimer 2023-04-21 13:19:08 UTC
There's no intermediate fix for the installed headers because the inline functions were removed with the bug still present. (Upstream relies on GCC doing these optimizations.)

Comment 8 errata-xmlrpc 2023-11-14 15:49:05 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (glibc bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:7107


Note You need to log in before you can comment on or make changes to this bug.