GNOME Bugzilla – Bug 754601
Make g_strerror work with non-glibc POSIX systems
Last modified: 2015-09-07 19:21:58 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.
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.
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.
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)
We could just split the file,I guess
(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