Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190207213723.GU23599@brightrain.aerifal.cx>
Date: Thu, 7 Feb 2019 16:37:23 -0500
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: dlsym(handle) may search in unrelated libraries

On Thu, Feb 07, 2019 at 04:33:18PM -0500, Rich Felker wrote:
> On Thu, Feb 07, 2019 at 09:31:38PM +0100, Markus Wichmann wrote:
> > > Yes, but you can also avoid recursion just by looping to the deepest
> > > dependency with !inited, then going back to the root. For a one-time
> > > operation at dlopen-time or program-start time, the quadratic search
> > > for each !inited seems unlikely to be a problem:
> > > 
> > 
> > Wait, I have an idea. If the only ordering is that the dependencies need
> > to be initialized before their dependents, then couldn't we just
> > initialize the libs in reverse BFS order? The elements further down the
> > tree are all necessarily further down the list, aren't they?
> 
> No. Suppose X depends on Y and Z, and Z also depends on Y. If you do
> reverse-BFS order, you'll construct Z before Y, despite Z depending on
> Y (and Z's ctors depending on Y's ctors already having run).

Hmm, maybe if you add redundant entries like your code was doing, this
works -- the list gets "YZY" for my example -- but then you waste a
good bit of space and need a way to cut off circular dependencies
(which can't respect ctor dependency order) while not breaking the
order for non-circular ones.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.