From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id D1C802B2F5 for ; Sat, 9 Mar 2024 20:25:30 +0100 (CET) Received: (qmail 24125 invoked by uid 550); 9 Mar 2024 19:21:24 -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 24050 invoked from network); 9 Mar 2024 19:21:24 -0000 Date: Sat, 9 Mar 2024 14:25:34 -0500 From: Rich Felker To: Alejandro Colomar Cc: Andreas Schwab , musl@lists.openwall.com, Guillem Jover , libc-alpha@sourceware.org, libbsd@lists.freedesktop.org, "Serge E. Hallyn" , "Skyler Ferrante (RIT Student)" , Iker Pedrosa , Christian Brauner Message-ID: <20240309192533.GT4163@brightrain.aerifal.cx> References: <20240309150258.GS4163@brightrain.aerifal.cx> <87o7bnjlsg.fsf@igel.home> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] Re: Tweaking the program name for functions On Sat, Mar 09, 2024 at 07:46:38PM +0100, Alejandro Colomar wrote: > Hi Andreas, > > On Sat, Mar 09, 2024 at 07:35:27PM +0100, Andreas Schwab wrote: > > On Mär 09 2024, Alejandro Colomar wrote: > > > > > There's not a portable way to configure them, AFAIK. You could say it's > > > glibc and musl's fault, for importing the err.h functions without > > > importing setprogname(3). > > > > When glibc imported err, setprogname didn't exist yet. > > Thanks. Then BSD extended the contract. That's still a problem of musl > and glibc. The API is deficient without setprogname(3), and should be > fixed. I think libc should either drop err.h and let another library > take ownership of the API, or add a way to configure it, hopefully being > compatible with the BSDs. No? libc can't drop anything at the binary level because that's breaking existing dynamic linked programs. It could remove the header, but that has its own problems. The err.h interfaces are called "legacy" in musl (appearing in src/legacy) because they are not part of any standard and are just something a bunch of ancient crufty code used and assumed was there. They were added to musl early on (back in 2011) because they were very-low-cost to add, no interaction with anything else (they didn't even support progname at the time), and made it easier for people who were getting musl-based systems up for the first time. They don't do anything significant you can't do yourself with fprintf/perror, the err forms exit without giving you any opportunity for clean exit (except installing atexit handlers, which are their own mess of global state), and as implmented aren't really multithread-friendly (they don't lock around the multiple stdio calls to make the error output atomic). Basically, they just go with a really, really antiquated programming model, and do not seem like the sort of thing anyone should be investing development time into improving *or* intentionally breaking. I agree there are sometimes hazards to copy-and-paste, but in the case of these, a copy-and-paste version (or just a rewrite) where you can wire up your own better behaviors more suited to your application is really *better* than using them as-is. If you have your own header and definition for these functions, the ones in libc will not even get used. There is no "ownership" conflict. Rich