From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12609 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: How to test if dlclose is a no-op? Date: Thu, 15 Mar 2018 11:32:36 -0400 Message-ID: <20180315153236.GF1436@brightrain.aerifal.cx> References: <20180315144015.GD1436@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1521127849 29032 195.159.176.226 (15 Mar 2018 15:30:49 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 15 Mar 2018 15:30:49 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-12623-gllmg-musl=m.gmane.org@lists.openwall.com Thu Mar 15 16:30:45 2018 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1ewUq4-0007QV-AN for gllmg-musl@m.gmane.org; Thu, 15 Mar 2018 16:30:44 +0100 Original-Received: (qmail 30619 invoked by uid 550); 15 Mar 2018 15:32:48 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 30599 invoked from network); 15 Mar 2018 15:32:48 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:12609 Archived-At: On Thu, Mar 15, 2018 at 10:24:05AM -0500, Thadeus Fleming wrote: > I'm working on improving a system that makes some bad assumptions > about dynamic unloading. While I'm not fond of dynamic unloading, I > think it might be valuable to be able to distinguish between "this C > library doesn't support unloading at all" and "if the planets are all > aligned, unloading might work." Testing if dlclose is a no-op would > allow me to make that distinction. Well obviously you can do something like dlopen/dlclose/dlopen of the same library (a specially crafted probe library) with a ctor and observe whether ctor ran once or twice. But it seems like if you fix whatever bad assumptions the code has to the point that it runs correctly on musl, it will run correctly everywhere without caring what the behavior is. Rich > On Thu, Mar 15, 2018 at 9:40 AM, Rich Felker wrote: > > On Thu, Mar 15, 2018 at 08:32:34AM -0500, Thadeus Fleming wrote: > >> In the spirit of not “assum[ing] a certain implementation has > >> particular properties rather than testing,” how can one test if > >> dlclose is a no-op, as it is in musl, without breaking things if it > >> isn’t? > > > > This sounds like an XY problem¹. Do you care about whether you can > > recover virtual memory space, whether the underlying fs objects remain > > referenced, whether there's a cycle of dtors and ctors running, or > > something else? > > > > FYI there is no clear answer to the question even on other > > implementations. glibc only sometimes unloads; there are corner cases > > and race-type conditions where unloading is impossible for them. You > > really should not be designing around an assumption/requirement that > > anything get unloaded. > > > > Rich > > > > > > > > ¹ http://xyproblem.info/