This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug string/24024] strerror() might set errno to ENOMEM due to -fno-math-error


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

--- Comment #6 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, release/2.28/master has been updated
       via  198bfee8085fcc63d6401fec0c542b62aea711a5 (commit)
      from  1e5c5303a522764d7e9d2302a60e4a32cdb902f1 (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=198bfee8085fcc63d6401fec0c542b62aea711a5

commit 198bfee8085fcc63d6401fec0c542b62aea711a5
Author: Aurelien Jarno <aurelien@aurel32.net>
Date:   Thu Jan 3 15:51:37 2019 +0100

    Only build libm with -fno-math-errno (bug 24024)

    Commit 1294b1892e ("Add support for sqrt asm redirects") added the
    -fno-math-errno flag to build most of the glibc in order to enable GCC
    to inline math functions. Due to GCC bug #88576, saving and restoring
    errno around calls to malloc are optimized-out. In turn this causes
    strerror to set errno to ENOMEM if it get passed an invalid error number
    and if malloc sets errno to ENOMEM (which might happen even if it
    succeeds). This is not allowed by POSIX.

    This patch changes the build flags, building only libm with
    -fno-math-errno and all the remaining code with -fno-math-errno. This
    should be safe as libm doesn't contain any code saving and restoring
    errno around malloc. This patch can probably be reverted once the GCC
    bug is fixed and available in stable releases.

    Tested on x86-64, no regression in the testsuite.

    Changelog:
        [BZ #24024]
        * Makeconfig: Build libm with -fno-math-errno but build the remaining
        code with -fmath-errno.
        * string/Makefile [$(build-shared)] (tests): Add test-strerror-errno.
        [$(build-shared)] (LDLIBS-test-strerror-errno): New variable.
        * string/test-strerror-errno.c: New file.

    (cherry picked from commit 2ef427168818ce04b03cecb7b739f9db0156e3e4)

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

Summary of changes:
 ChangeLog                    |    9 ++++++
 Makeconfig                   |    6 +++-
 NEWS                         |    1 +
 string/Makefile              |    6 ++++
 string/test-strerror-errno.c |   61 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 81 insertions(+), 2 deletions(-)
 create mode 100644 string/test-strerror-errno.c

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]