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: dlopen with RTLD_PRIVATE?


On Wed, May 27, 2015 at 12:07:05PM +0200, Tom van Dijk wrote:
> Hello,
> 
> Judging from a cursory search on the internet, quite a few people
> would love to have dlopen with an RTLD_PRIVATE flag, which would allow
> opening a .so file that has some internal state multiple times.
> 
> for example:
> 
> http://stackoverflow.com/questions/24365989/loading-two-instances-of-a-shared-library-without-rtld-private-or-multiple-copie
> 
> http://stackoverflow.com/questions/3433522/loading-two-instances-of-a-shared-library
> 
> This appears to be implemented eg in UnixWare:
> http://uw714doc.sco.com/en/man/html.3C/dlopen.3C.html
> 
> Our my case, I'd like to load a .so that is not thread-safe for every
> thread. Using only one instance protected with a mutex is not an
> option, as I'm interested in a highly parallel application.
> 
> Is this something that is difficult to implement in glibc for some
> reason? Or is there already some solid alternative for this problem? A
> search did not find satisfactory solutions, although there is a
> workaround by copying the library to uniquely named files in /tmp on
> runtime and loading each copied file separately, but I'd say you'd
> agree that this is a pretty dirty solution.
>
Here you could try to fix library by fixing it to use tls by adding
__thread to shared data. Performance would suffer and tls for shared
libraries is suboptimal.

Second suggestion would be use separate process instead thread with mmap
shared memory.


Then there is question if its good idea or you should fix library.

A functionality is possible but you would need to write patch yourself
as we aren't convinced to add this functionality. Wrapping hack of using
different filename but mmap to same library would work so its question
of effectivity. 


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