After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 754601 - Make g_strerror work with non-glibc POSIX systems
Make g_strerror work with non-glibc POSIX systems
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: build
2.45.x
Other FreeBSD
: High critical
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2015-09-05 15:47 UTC by Ting-Wei Lan
Modified: 2015-09-07 19:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Make g_strerror work with non-glibc POSIX systems (911 bytes, patch)
2015-09-05 15:49 UTC, Ting-Wei Lan
reviewed Details | Review

Description Ting-Wei Lan 2015-09-05 15:47:54 UTC
g_strerror assumes GNU-specific version of strerror_r should be used when !G_OS_WIN32, but this causes problem on non-glibc POSIX systems because strerror_r returns 0 when it succeeds, which crashes g-ir-compiler on FreeBSD because NULL pointer is used.
Comment 1 Ting-Wei Lan 2015-09-05 15:49:20 UTC
Created attachment 310703 [details] [review]
Make g_strerror work with non-glibc POSIX systems

We should only use GNU-specific strerror_r on glibc. On other systems,
we should use the XSI-compliant version.
Comment 2 Colin Walters 2015-09-06 15:17:42 UTC
Review of attachment 310703 [details] [review]:

Instead of testing for __GLIBC__, we should use what's in the man page:

       The XSI-compliant version of strerror_r() is provided if:
       (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE
       Otherwise, the GNU-specific version is provided.

I think at the moment we always get the GNU version due to AC_USE_SYSTEM_EXTENSIONS, but we might as well match the man page.

I also note we're missing error handling for each case.
Comment 3 Matthias Clasen 2015-09-07 01:09:47 UTC
The problem here is that glibc is only providing xsi strerror_r if you turn off gnu extensions. But we use those elsewhere in this file (stdtod_l,etc)
Comment 4 Matthias Clasen 2015-09-07 01:10:25 UTC
We could just split the file,I guess
Comment 5 Colin Walters 2015-09-07 19:21:58 UTC
(In reply to Matthias Clasen from comment #3)
> The problem here is that glibc is only providing xsi strerror_r if you turn
> off gnu extensions. But we use those elsewhere in this file (stdtod_l,etc)

I wasn't suggesting we try to use the XSI version on glibc, just an extended check that we're using the GNU version on glibc.

I pushed:
https://git.gnome.org/browse/glib/commit/?id=ebf961a58d540ea40611ad75bc983f5386d3635b