dlopen() and dlclose() are not MT-safe?
Kazuaki Oda
kaakun at highway.ne.jp
Wed Mar 22 21:04:18 UTC 2006
Kostik Belousov wrote:
> Oops. Completely reversed condition in the if. :(. Also, I don't think it
> shall returns the error in this situation. New take:
>
> Index: libexec/rtld-elf/rtld.c
> ===================================================================
> RCS file: /usr/local/arch/ncvs/src/libexec/rtld-elf/rtld.c,v
> retrieving revision 1.112
> diff -u -r1.112 rtld.c
> --- libexec/rtld-elf/rtld.c 24 Dec 2005 15:37:30 -0000 1.112
> +++ libexec/rtld-elf/rtld.c 22 Mar 2006 19:03:12 -0000
> @@ -1688,6 +1688,11 @@
> wlock_release(rtld_bind_lock, lockstate);
> objlist_call_fini(&list_fini);
> lockstate = wlock_acquire(rtld_bind_lock);
> + if (root->refcount != 0) {
> + wlock_release(rtld_bind_lock, lockstate);
> + return 0;
> + }
> +
> objlist_remove_unref(&list_fini);
>
> /* Finish cleaning up the newly-unreferenced objects. */
Thanks. I applied your patch and ran the test program once more.
When linked with libpthread:
% ./dltest
Segmentation fault (core dumped)
When linked with libthr:
% ./dltest
ld-elf.so.1: assert failed: /usr/src/libexec/rtld-elf/rtld.c:1728
In libpthread case, the result was changed. I got no "assert failed"
message, and it took longer time to crash than before. In libthr
case, I could not find any difference.
BTW do you know the reason why lock is released before calling
objlist_call_fini()? If we don't release the lock, what problem will
occur? deadlock?
--
Kazuaki Oda
More information about the freebsd-hackers
mailing list