From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 23882 invoked from network); 13 Apr 2022 03:44:28 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 13 Apr 2022 03:44:28 -0000 Received: (qmail 28581 invoked by uid 550); 13 Apr 2022 03:44:25 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 28549 invoked from network); 13 Apr 2022 03:44:25 -0000 Date: Tue, 12 Apr 2022 23:44:11 -0400 From: Rich Felker To: "Gary E. Miller" Cc: musl@lists.openwall.com Message-ID: <20220413034411.GS7074@brightrain.aerifal.cx> References: <20220412134355.59bd920e@spidey.rellim.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220412134355.59bd920e@spidey.rellim.com> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] =?utf-8?B?4pyYc3RyZXJyb3Jfcig=?= =?utf-8?Q?=29?= bug in musl On Tue, Apr 12, 2022 at 01:43:55PM -0700, Gary E. Miller wrote: > Yo All! > > 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). This is really a deficiency of the documentation. The text that's there isn't factually wrong but it's in some sense wrong by omission -- it omits clearly stating that _GNU_SOURCE does not change anything to behave in ways that conflict with the standards-specified behaviors (or change the behavior of standards-specified interfaces whatsoever). It *only* exposes extension interfaces. In addition to correcting this, the "criteria for exclusion/inclusion" of extension functionality should really be written up well and placed in a conspicuous place. At present it's just scattered across mailing list discussions of various proposed extensions. And likewise, the specific example of `strerror_r` (note: `basename` is like this and is already covered) should be mentioned on the wiki "differences from glibc" page. > Is if musl intends its strerror_r() to work like glibc's strerror_r() then > there is a bug. > > Particularly nasty to have functions that only run when an error condition > occurs, to themselves cause crashes. The code should not even compile if it's using the wrong signature. The GNU version of the function does not guarantee that the string is stored in the provided buf, so you have to examine the return value, and assignment/passing of an int where a pointer type is expected is a constraint violation. By default gcc only treats this as a warning (-Wint-conversion) but you can and should make it an error via -Werror=int-conversion since code doing this is unconditionally wrong. Rich