From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id 0B1463858D20 for ; Wed, 13 Dec 2023 22:33:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0B1463858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0B1463858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=45.83.234.184 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702506803; cv=none; b=NrU2JrgpzIbzWa3hwZxsDI1ovyrFjkodn1ODQF2HVcc8IC55Bs1FLhJYyl2tfLvgusDGepZHVfPmp6ofczjukzAuLv9EaBhWVs9ujZlk4zpQEC5lvmp8K6Fx6X3CqGcBSLm48sWXtw5czJ/nG0LGe1DQ8eFcXFEwxYIrY1GiHhE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702506803; c=relaxed/simple; bh=8KLZxG8gOGUien0pbJ0Pc8ng+94Fsi/H8N0riLV6BFM=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=JXBudno9eDDJ8s+nBM7nFO/oq3EPmAQ9xu745/YxqpqqMqyg2TKJ77lxrG5FdPgnDtdrDJTWsJ54xsW3a1HXj13ssEnQrMNPrSdmUTalrNspww3HBzk3f5WRyJOBHlKv3TVbd4KpIgpRvsgUgZC8RAYHYG0URp0/0aeJ22zHkZA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by gnu.wildebeest.org (Postfix, from userid 1000) id 0677D30291AB; Wed, 13 Dec 2023 23:33:20 +0100 (CET) Date: Wed, 13 Dec 2023 23:33:19 +0100 From: Mark Wielaard To: Khem Raj Cc: elfutils-devel@sourceware.org Subject: Re: [PATCH] Add helper function for basename Message-ID: <20231213223319.GA19134@gnu.wildebeest.org> References: <20231210202033.151578-1-raj.khem@gmail.com> <94bd77b96d261ebac6bfe62e8de64d3539742133.camel@klomp.org> 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) X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, Dec 13, 2023 at 08:29:01AM -0800, Khem Raj wrote: > On Wed, Dec 13, 2023 at 7:10 AM Mark Wielaard wrote: > > > > Hi Khem, > > > > On Tue, 2023-12-12 at 09:16 -0800, Khem Raj wrote: > > > On Tue, Dec 12, 2023 at 5:18 AM Mark Wielaard wrote: > > > > On Sun, 2023-12-10 at 12:20 -0800, Khem Raj wrote: > > > > > musl does not provide GNU version of basename and lately have removed > > > > > the definiton from string.h [1] which exposes this problem. It can be > > > > > made to work by providing a local implementation of basename which > > > > > implements the GNU basename behavior, this makes it work across C > > > > > libraries which have POSIX implementation only. > > > > > > > > Thanks, this should work, but wouldn't it be easier to add a configure > > > > test for having basename defined in string.h and then only define > > > > basename in libeu.h (and build basename.c) if it isn't. So that all the > > > > code can just keep using basename (we just have to make sure libeu.h is > > > > included)? > > > > > > we could do that but it will not work as expected with older musl releases > > > where the prototype in string.h will exist. > > > > But that is good isn't it? Or did musl define basename in string.h with > > different semantics (where the given input string is modified)? > > basename was declared like this till lately > https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7 Urgh, that is pretty bad. So it declared it with the wrong signature and then it called an implementation that modified its argument... > > In the second case various elfutils libraries and tools probably just > > segfaulted when build/run against musl. And your patch would indeed fix > > both old and new musl versions. Do people using musl already use some > > variant of your patch? > > This is not yet tried widely in distros as the musl patch above is > till new and not part of > a release yet. I understand that. But I don't understand how an elfutils build/ran against current musl even worked given that it would be using the wrong basename implementation. It seems it cannot without your patch. Did we just get lucky because most paths don't end with one or more slashes? Cheers, Mark