Date: Thu, 23 Mar 2006 05:57:24 +0900 From: Kazuaki Oda <kaakun@highway.ne.jp> To: Kostik Belousov <kostikbel@gmail.com> Cc: kan@freebsd.org, hackers@freebsd.org Subject: Re: dlopen() and dlclose() are not MT-safe? Message-ID: <4421BA34.8040908@highway.ne.jp> In-Reply-To: <20060322190725.GC27116@deviant.kiev.zoral.com.ua> References: <44215FE9.2070602@highway.ne.jp> <20060322174312.GB27116@deviant.kiev.zoral.com.ua> <20060322190725.GC27116@deviant.kiev.zoral.com.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4421BA34.8040908>