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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 6522 invoked from network); 5 Jun 2023 19:36:19 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 5 Jun 2023 19:36:19 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1685993779; b=OgkLXzkKfp58uzBBzHrqlM8jmKAarJ3KU9eoEoGusgTI5PVYVJkUVqzpHJTftXN72QCS9nobca Zji9Y0pcxLU2FDq4mmwnS6k/W0BhXGqAxpS7gGcb9Ktz7Y0vWJbkBDAV6dOU/YKDGPRvjGxfVw Aot6829zmYnBqUrFmrr2XM6u5nsurttCDhywguCMsxqDTuUrY6iD/PTzgL2Yfh5bwJX6DwGO/0 B4j59+UHRlepcgxl6QXPU+hyjIwdDe48YOBYz9XlzP0AwTvS5EIkAedJYbi3nVgXddPx80x9lL 1g7DaUeJ50q6sNJAj0uM7fVXAd8Gpz0sBRg+vsJrmVwxmA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (baseband.digital) smtp.remote-ip=162.55.218.138; dmarc=none header.from=hostalia.de; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1685993779; bh=T2ZQebmt2NeBuxL6EebWlkyqkY9mdFYZj0lCt20iQng=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:To:Subject:MIME-Version:Date:Message-ID:DKIM-Signature; b=DhYDHmi4OXNrfhyDaO1ewn75Dib8q8gQ959jHxQ1zfxmt3IONsCt1sB8jHPxltb99IKHaJFIuD VnXQ82mA+FPQdwwTJCD9WnIqwLfdLk4KZq5Bv/JDLpAU9wxUKWFGyRoNhAv0YjXwG5OyUECgAI 6kD6pgeBImx8Ayiykw3Yn4uiyO+eTb3kgYC1bLQROi4xIEMS3yEb90y+goz0iAMYUmOUI0ky7c 1bbr0ughb8hXGFjX848djTrGIrH048FfqMfDw93a9EfiJREeOJpsh4GdRxWV8uB1TkVjUMRyo2 U05IixDkkRj0gvwzDXxMkuYYxyc8yaZuDO9rQN7x/Bj2Ew==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=bUV+yJcd8emal2Gk1YrYSePs7+sUBt4cgm0azVr4HIU=; b=BUNn+M/WxdoCS971ncIk16mP25 Fvyxbas28ldA8NYSaH4Ow0Hu/sHHxvCrjjlkeOiSMcx/QQZK0fgJXTJPn7VXR8/pjTGHCarrjIjje bg6acAaF2DMUIoyYirBOrHLCN/d6EjUcq7Xwwi5JZZBjnjHY5VrdDOkZuJroUtzrkUnXYw3VqT4gs /EB8S/Zt8xkOF7AY2nrszBZUE14NYCzM8GXbEYVjibe8odKuqEE/dGJ2pYUmHbkt9koAc6M613eoJ MzLfXU9hYlQbcJiGfOr1dSG1UoERD5N1xVPM7760LX4Q8T67OoEHwTF637yXm5N/INmyjrX9oPDyo GmPMz2DA==; Received: by zero.zsh.org with local id 1q6G01-000992-TC; Mon, 05 Jun 2023 19:36:17 +0000 Authentication-Results: zsh.org; iprev=pass (baseband.digital) smtp.remote-ip=162.55.218.138; dmarc=none header.from=hostalia.de; arc=none Received: from baseband.digital ([162.55.218.138]:41946) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1q6FzU-0008qI-08; Mon, 05 Jun 2023 19:35:45 +0000 Received: from [IPV6:2a00:1398:9:fb03:ff83:1873:1461:432e] (unknown [IPv6:2a00:1398:9:fb03:ff83:1873:1461:432e]) by baseband.digital (Postfix) with ESMTPSA id 4716E5DCF7; Mon, 5 Jun 2023 21:35:43 +0200 (CEST) Message-ID: <227fe72b-7441-935c-55a7-421945da54b3@hostalia.de> Date: Mon, 5 Jun 2023 21:35:42 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [Bug] modules zsh/tcp, zsh/zftp unloadable, probably affecting most modern Linuxes To: Philippe Troin , =?UTF-8?Q?Marcus_M=c3=bcller?= , zsh-workers@zsh.org References: <027f2a491b638e2ffaf7766fe4adf29537c11fdf.camel@fifi.org> Content-Language: en-US From: =?UTF-8?Q?Marcus_M=c3=bcller?= In-Reply-To: <027f2a491b638e2ffaf7766fe4adf29537c11fdf.camel@fifi.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Seq: 51828 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: Hi Phil, thanks for the follow-up: On 6/4/23 23:17, Philippe Troin wrote: > Interestingly: > % zsh -f > % echo $ZSH_VERSION > 5.9 > % rpm -q zsh > zsh-5.9-5.fc38.x86_64 > % zmodload zsh/zftp > zsh: failed to load module `zsh/zftp': /usr/lib64/zsh/5.9/zsh/zftp.so: undefined symbol: freehostent > % autoload zfinit > % zfinit > % zmodload zsh/zftp ah, ok, that's how it's supposed to work? Shouldn't the module then not trigger some warning or specific error on load, before the dynamic loader runs and fails? > freehostent is defined in zsh/net/tcp: > > % nm --dynamic /usr/lib64/zsh/5.9/zsh/net/tcp.so| grep freehostent > 00000000000027c0 T freehostent Hui. Looking into tcp.c:197, that function is --- /**/ mod_export void freehostent(UNUSED(struct hostent *ptr)) { } --- Why is that not calling `free`? Oh, very simple, because above, the comment near the getipnodebyname implementation says: --- /* note: this is not a complete implementation.  If ignores the flags,    and does not provide the memory allocation of the standard interface.    Each returned structure will overwrite the previous one. */ --- Ah, so we're exporting and thus overwriting a symbol that overwrites a pointer by the name of an existing libc function with a "overrides potentially unowned memory" one? That sounds a tad undesirable in the grander scheme of things :) Since the only use of this function pair (zsh_getipnodebyname, freehostent) is to be used internally in zfinit'ed modules, and the number of internal consumers is zftp.c, could I propose we just rename `freehostent` to `zsh_freehostent`? That would sound less invasive, and would at least send the next person not down the tracks looking for libc anachronisms (not blaming anyone but me for going down that road) ;-) > Since I think you're supposed to initialize zftp through zfinit, I do > not think this qualifies as a bug. Hm, yeah, surprising to me, but probably documented somewhere well enough. > But the freehostent symbol in zsh/net/tcp.so feels a little funky. I'd agree, see above Cheers, Marcus