Bug 22377 - iseqsig, float128 and C++
Summary: iseqsig, float128 and C++
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: math (show other bugs)
Version: 2.26
: P2 normal
Target Milestone: 2.27
Assignee: Gabriel F. T. Gomes
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-31 16:12 UTC by Joseph Myers
Modified: 2018-06-20 14:22 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Myers 2017-10-31 16:12:59 UTC
Similar to other such bugs:

iseqsig is defined to use __MATH_TG.  Thus, when float128 is supported as ABI-distinct from long double, iseqsig will not work in C++ code.

Fixing this might be trickier than for other such macros, because comparison macros are meant to work based on the evaluation format rather than the semantic type; that is, the function to call should be determined by __MATH_EVAL_FMT2 (x, y).  The macro __MATH_EVAL_FMT2 *is* OK to call from C++ code (but the result of the call should only be used to determine the particular __iseqsig* function to call; it would be incorrect actually to evaluate the expression __MATH_EVAL_FMT2 expands to, only its type is relevant).
Comment 1 Gabriel F. T. Gomes 2017-11-03 13:18:07 UTC
I posted an initial patch for review on:

https://sourceware.org/ml/libc-alpha/2017-11/msg00076.html

It still lacks a test case, though.
Comment 2 Joseph Myers 2017-12-19 17:47:34 UTC
Is there a reason the patch approved in https://sourceware.org/ml/libc-alpha/2017-12/msg00190.html hasn't been committed?
Comment 3 Gabriel F. T. Gomes 2017-12-19 19:01:27 UTC
(In reply to Joseph Myers from comment #2)
> Is there a reason the patch approved in
> https://sourceware.org/ml/libc-alpha/2017-12/msg00190.html hasn't been
> committed?

No.  I'll commit it, now (then close this bug).  Sorry for taking longer than usual, and thanks for pointing this out.
Comment 4 cvs-commit@gcc.gnu.org 2017-12-20 01:46:04 UTC
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  c85e54ac6cef0faed7b7ffc722f52523dec59bf5 (commit)
      from  10e93d968716ab82931d593bada121c17c0a4b93 (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=c85e54ac6cef0faed7b7ffc722f52523dec59bf5

commit c85e54ac6cef0faed7b7ffc722f52523dec59bf5
Author: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
Date:   Fri Nov 3 10:44:36 2017 -0200

    Provide a C++ version of iseqsig (bug 22377)
    
    In C++ mode, __MATH_TG cannot be used for defining iseqsig, because
    __MATH_TG relies on __builtin_types_compatible_p, which is a C-only
    builtin.  This is true when float128 is provided as an ABI-distinct type
    from long double.
    
    Moreover, the comparison macros from ISO C take two floating-point
    arguments, which need not have the same type.  Choosing what underlying
    function to call requires evaluating the formats of the arguments, then
    selecting which is wider.  The macro __MATH_EVAL_FMT2 provides this
    information, however, only the type of the macro expansion is relevant
    (actually evaluating the expression would be incorrect).
    
    This patch provides a C++ version of iseqsig, in which only the type of
    __MATH_EVAL_FMT2 (__typeof or decltype) is used as a template parameter
    for __iseqsig_type.  This function calls the appropriate underlying
    function.
    
    Tested for powerpc64le and x86_64.
    
    	[BZ #22377]
    	* math/Makefile [C++] (tests): Add test for iseqsig.
    	* math/math.h [C++] (iseqsig): New implementation, which does
    	not rely on __MATH_TG/__builtin_types_compatible_p.
    	* math/test-math-iseqsig.cc: New file.
    	* sysdeps/powerpc/powerpc64le/Makefile
    	(CFLAGS-test-math-iseqsig.cc): New variable.

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

Summary of changes:
 ChangeLog                                          |   10 ++
 math/Makefile                                      |    2 +-
 math/math.h                                        |   72 +++++++++++++++-
 ...st-math-issignaling.cc => test-math-iseqsig.cc} |   92 ++++++++++----------
 sysdeps/powerpc/powerpc64le/Makefile               |    8 ++-
 5 files changed, 132 insertions(+), 52 deletions(-)
 copy math/{test-math-issignaling.cc => test-math-iseqsig.cc} (52%)
Comment 5 Gabriel F. T. Gomes 2017-12-20 01:47:26 UTC
Fixed for 2.27.
Comment 6 cvs-commit@gcc.gnu.org 2018-01-30 19:02:11 UTC
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, release/2.26/master has been updated
       via  bbabb868cd248763373d0db763bacd84ce27ede8 (commit)
       via  38e08dc3e00fc27d127701175018cac4ddaf998e (commit)
      from  a5db85df69dce7fcf793fefc60c764c684e0c272 (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=bbabb868cd248763373d0db763bacd84ce27ede8

commit bbabb868cd248763373d0db763bacd84ce27ede8
Author: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
Date:   Fri Jan 12 18:50:33 2018 -0200

    powerpc: Fix syscalls during early process initialization [BZ #22685]
    
    The tunables framework needs to execute syscall early in process
    initialization, before the TCB is available for consumption.  This
    behavior conflicts with powerpc{|64|64le}'s lock elision code, that
    checks the TCB before trying to abort transactions immediately before
    executing a syscall.
    
    This patch adds a powerpc-specific implementation of __access_noerrno
    that does not abort transactions before the executing syscall.
    
    Tested on powerpc{|64|64le}.
    
    	[BZ #22685]
    	* sysdeps/powerpc/powerpc32/sysdep.h (ABORT_TRANSACTION_IMPL): Renamed
    	from ABORT_TRANSACTION.
    	(ABORT_TRANSACTION): Redirect to ABORT_TRANSACTION_IMPL.
    	* sysdeps/powerpc/powerpc64/sysdep.h (ABORT_TRANSACTION,
    	ABORT_TRANSACTION_IMPL): Likewise.
    	* sysdeps/unix/sysv/linux/powerpc/not-errno.h: New file.  Reuse
    	Linux code, but remove the code that aborts transactions.
    
    Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
    Tested-by: Aurelien Jarno <aurelien@aurel32.net>
    (cherry picked from commit 4612268a0ad8e3409d8ce2314dd2dd8ee0af5269)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=38e08dc3e00fc27d127701175018cac4ddaf998e

commit 38e08dc3e00fc27d127701175018cac4ddaf998e
Author: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
Date:   Fri Nov 3 10:44:36 2017 -0200

    Provide a C++ version of iseqsig (bug 22377)
    
    In C++ mode, __MATH_TG cannot be used for defining iseqsig, because
    __MATH_TG relies on __builtin_types_compatible_p, which is a C-only
    builtin.  This is true when float128 is provided as an ABI-distinct type
    from long double.
    
    Moreover, the comparison macros from ISO C take two floating-point
    arguments, which need not have the same type.  Choosing what underlying
    function to call requires evaluating the formats of the arguments, then
    selecting which is wider.  The macro __MATH_EVAL_FMT2 provides this
    information, however, only the type of the macro expansion is relevant
    (actually evaluating the expression would be incorrect).
    
    This patch provides a C++ version of iseqsig, in which only the type of
    __MATH_EVAL_FMT2 (__typeof or decltype) is used as a template parameter
    for __iseqsig_type.  This function calls the appropriate underlying
    function.
    
    Tested for powerpc64le and x86_64.
    
    	[BZ #22377]
    	* math/Makefile [C++] (tests): Add test for iseqsig.
    	* math/math.h [C++] (iseqsig): New implementation, which does
    	not rely on __MATH_TG/__builtin_types_compatible_p.
    	* math/test-math-iseqsig.cc: New file.
    	* sysdeps/powerpc/powerpc64le/Makefile
    	(CFLAGS-test-math-iseqsig.cc): New variable.
    
    (cherry picked from commit c85e54ac6cef0faed7b7ffc722f52523dec59bf5)

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

Summary of changes:
 ChangeLog                                          |   21 +++++
 NEWS                                               |    2 +
 math/Makefile                                      |    2 +-
 math/math.h                                        |   72 +++++++++++++++-
 ...st-math-issignaling.cc => test-math-iseqsig.cc} |   92 ++++++++++----------
 sysdeps/powerpc/powerpc32/sysdep.h                 |    5 +-
 sysdeps/powerpc/powerpc64/sysdep.h                 |    5 +-
 sysdeps/powerpc/powerpc64le/Makefile               |    7 ++-
 .../unix/sysv/linux/powerpc/not-errno.h            |   23 +++--
 9 files changed, 164 insertions(+), 65 deletions(-)
 copy math/{test-math-issignaling.cc => test-math-iseqsig.cc} (52%)
 copy support/xsigaction.c => sysdeps/unix/sysv/linux/powerpc/not-errno.h (60%)
Comment 7 cvs-commit@gcc.gnu.org 2018-05-24 18:47:45 UTC
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  fb0e10b8eb1ebb68c57d4551f7a95118f3c54837 (commit)
      from  43d4f3d5ad94e1fa5e56d7a7200d0e9f3d8e2f02 (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=fb0e10b8eb1ebb68c57d4551f7a95118f3c54837

commit fb0e10b8eb1ebb68c57d4551f7a95118f3c54837
Author: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
Date:   Mon May 14 09:04:28 2018 -0300

    Fix parameter type in C++ version of iseqsig (bug 23171)
    
    The commit
    
      commit c85e54ac6cef0faed7b7ffc722f52523dec59bf5
      Author: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
      Date:   Fri Nov 3 10:44:36 2017 -0200
    
          Provide a C++ version of iseqsig (bug 22377)
    
    mistakenly used double parameters in the long double version of iseqsig,
    thus causing spurious conversions to double, as reported on bug 23171.
    
    Tested for powerpc64le and x86_64.

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

Summary of changes:
 ChangeLog   |    6 ++++++
 math/math.h |    2 +-
 2 files changed, 7 insertions(+), 1 deletions(-)
Comment 8 cvs-commit@gcc.gnu.org 2018-06-20 14:19:45 UTC
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, release/2.26/master has been updated
       via  81b994bd8391e5994913d67b0966ce10cc0977a6 (commit)
      from  7b52c8ae05340c795654d23a0e7a2590a3e23bd2 (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=81b994bd8391e5994913d67b0966ce10cc0977a6

commit 81b994bd8391e5994913d67b0966ce10cc0977a6
Author: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
Date:   Mon May 14 09:04:28 2018 -0300

    Fix parameter type in C++ version of iseqsig (bug 23171)
    
    The commit
    
      commit c85e54ac6cef0faed7b7ffc722f52523dec59bf5
      Author: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
      Date:   Fri Nov 3 10:44:36 2017 -0200
    
          Provide a C++ version of iseqsig (bug 22377)
    
    mistakenly used double parameters in the long double version of iseqsig,
    thus causing spurious conversions to double, as reported on bug 23171.
    
    Tested for powerpc64le and x86_64.
    
    (cherry picked from commit fb0e10b8eb1ebb68c57d4551f7a95118f3c54837)

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

Summary of changes:
 ChangeLog   |    6 ++++++
 NEWS        |    1 +
 math/math.h |    2 +-
 3 files changed, 8 insertions(+), 1 deletions(-)
Comment 9 cvs-commit@gcc.gnu.org 2018-06-20 14:22:49 UTC
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, release/2.27/master has been updated
       via  ffc56239787cdb5b0306baa8368923753f5891e6 (commit)
      from  80c83e91140d429c73f79092fdb75eed0fb71da0 (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=ffc56239787cdb5b0306baa8368923753f5891e6

commit ffc56239787cdb5b0306baa8368923753f5891e6
Author: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
Date:   Mon May 14 09:04:28 2018 -0300

    Fix parameter type in C++ version of iseqsig (bug 23171)
    
    The commit
    
      commit c85e54ac6cef0faed7b7ffc722f52523dec59bf5
      Author: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
      Date:   Fri Nov 3 10:44:36 2017 -0200
    
          Provide a C++ version of iseqsig (bug 22377)
    
    mistakenly used double parameters in the long double version of iseqsig,
    thus causing spurious conversions to double, as reported on bug 23171.
    
    Tested for powerpc64le and x86_64.
    
    (cherry picked from commit fb0e10b8eb1ebb68c57d4551f7a95118f3c54837)

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

Summary of changes:
 ChangeLog   |    6 ++++++
 NEWS        |    1 +
 math/math.h |    2 +-
 3 files changed, 8 insertions(+), 1 deletions(-)