From: Rich Felker <dalias@libc.org>
To: Natanael Copa <ncopa@alpinelinux.org>
Cc: "Gary E. Miller" <gem@rellim.com>, musl@lists.openwall.com
Subject: Re: [musl] *strerror_r() bug in musl
Date: Wed, 13 Apr 2022 10:05:33 -0400 [thread overview]
Message-ID: <20220413140532.GT7074@brightrain.aerifal.cx> (raw)
In-Reply-To: <20220413142432.311e20f5@ncopa-desktop.lan>
On Wed, Apr 13, 2022 at 02:24:32PM +0200, Natanael Copa wrote:
> On Tue, 12 Apr 2022 13:43:55 -0700
> "Gary E. Miller" <gem@rellim.com> wrote:
>
> > Yo All!
>
> Hi!
>
> >
> > I'm new to the list. I;ve been trying to report a musl bug on #musl since
> > last Friday, but no one seems to live there.
> >
> > musl (all versions) has a bug in strerror_r().
> >
> > The musl reference manual says of _GNUSOURCE:
> >
> > _GNU_SOURCE (or _ALL_SOURCE)
> >
> > Adds everything above, plus interfaces modeled after GNU libc
> > extensions and interfaces for making use of Linux-specific features.
> >
> > I take that to mean that when _GNU_SOURCE is used to compile code with musl
> > that the results will behave as GNU libc (glinc).
>
> Well, as other has mentioned. GNU libc has a non-compliant version of
> strerror_r.
>
> ....
>
> > When _GNU_SOURCE is defined with glibc, then strerror_r() returns a char *.
>
> I have met this in multiple places the last decade. The usual way to
> fix it is to also check for GNU libc in addition to _GNU_SOURCE.
>
> #if defined (__GLIBC__) && defined (_GNU_SOURCE)
> /* non-standard GLIBC exception */
> #else
> /* standard behavior for everything else */
> #endif
That, or probe for the signature with a configure-style check and use
the result of that, as in
#ifdef HAVE_GNU_STRERROR_R
// handle the GNU version
#else
// code written to the standard
#endif
or, even better, wrapping strerror_r in a translation unit that begins
with
#undef _GNU_SOURCE
#define _POSIX_C_SOURCE 200809L
or similar so that you always get the standard one, and calling your
wrapper instead.
Rich
next prev parent reply other threads:[~2022-04-13 14:05 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-12 20:43 [musl] ✘strerror_r() " Gary E. Miller
2022-04-12 20:48 ` alice
2022-04-12 21:04 ` Gary E. Miller
2022-04-12 20:56 ` Alex Xu (Hello71)
2022-04-12 21:07 ` Gary E. Miller
2022-04-12 23:16 ` Wolf
2022-04-13 0:15 ` Gary E. Miller
2022-04-12 21:13 ` Gary E. Miller
2022-04-13 3:44 ` Rich Felker
2022-04-13 12:24 ` [musl] *strerror_r() " Natanael Copa
2022-04-13 14:05 ` Rich Felker [this message]
2022-04-13 17:36 ` Gary E. Miller
2022-04-13 20:38 ` Rich Felker
2022-04-13 21:16 ` Gary E. Miller
2022-04-13 22:27 ` Rich Felker
2022-04-13 22:43 ` Gary E. Miller
2022-04-13 22:58 ` Rich Felker
2022-04-13 23:07 ` Gary E. Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220413140532.GT7074@brightrain.aerifal.cx \
--to=dalias@libc.org \
--cc=gem@rellim.com \
--cc=musl@lists.openwall.com \
--cc=ncopa@alpinelinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).