[PATCH] ldso: fix dlsym hang when reloading DSOs

Timo Teras timo.teras at iki.fi
Thu Jun 27 18:52:35 UTC 2013


On Thu, 27 Jun 2013 21:36:14 +0300
Timo Teras <timo.teras at iki.fi> wrote:

> On Thu, 27 Jun 2013 14:16:26 -0400
> Rich Felker <dalias at aerifal.cx> wrote:
> 
> > On Thu, Jun 27, 2013 at 09:34:32AM +0300, Timo Teräs wrote:
> > > It can happen under certain cases that the DSO had refcount 0,
> > > but was already loaded. (NODELETE flag is set, or it is pulled
> > > in via both NEEDED dependency and explicit dlopen()).
> > 
> > Wouldn't it be more logical to prevent this from happening by not
> > using a refcount of zero? For example, NODELETE could just perform
> > an extra increment on the refcnt so that it never reaches 0. In
> > essence, the NODELETE flag is a permanent reference to the DSO.
> 
> It seems this is not the only case. As mentioned, NEEDED dependencies
> together with dlopen()/dlclose() can result in this too in some cases.
> Apparently usage_count refers to active handles from dlopen() - and
> can be zero if the lib is pulled in via NEEDED dependency only.
> 
> Thus, this is the least intrusive fix. While restructuring dlopen()
> and dlclose() could fix this better, I did not have the time or
> interest to rewrite most of the libdl code.

Hum. Actually it might be that this happens with NODELETE flag only.
Seems my test case had that instead of the weird combo.

I'll test with NODELETE flag just adding usage_count by extra
reference. Will post new patch if it works (or report back if it
didn't).

- Timo


More information about the uClibc mailing list