This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Glibc 2.5 - dlsym issue in threaded app.


On Fri, Oct 31, 2008 at 11:45 AM, Vitaliy Ivanov
<vivanov@softservecom.com> wrote:
> So, what I understand is that dlsym when linked with pthreads is calling changed calloc and we enter infinite loop.
> When we are not linking with pthreads is seems like dlsym doesn't call calloc at all.
>
> Are you aware of this? What is the practice to avoid this endless loop?

You will always have this problem whenever you have a possibly
circular reference e.g. calloc which depends on calloc.

You must break the dependency by providing your own static buffer, and
returning calloc references to that static buffer, for all of the
calloc calls that can possibly be made by the dynamic loader calls
during the resolution of the next calloc symbol. Once you run out of
static calloc space, you can fall back to calling the next calloc
symbol, hopefully by this point all the internal library calloc's will
be handled.

I can see only one calloc reference in libc/dlfcn/dlerror.c
(_dlerror_run), and it allocates ~20 bytes of data. Once that data is
allocated, it won't be allocated again.

Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]