]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
If dlclose() is called recursively from a _fini() function, the inner
authorjh <jh@FreeBSD.org>
Thu, 16 Dec 2010 16:56:44 +0000 (16:56 +0000)
committerjh <jh@FreeBSD.org>
Thu, 16 Dec 2010 16:56:44 +0000 (16:56 +0000)
commitc65c4f33f57d89072950dae0a54f2bac154c1cfa
tree1e3dfbaf6242438f06fdee35fa73176b29a362e4
parentb643d680108901e283c59d9a5a35eb4b2ebdfe2a
If dlclose() is called recursively from a _fini() function, the inner
dlclose() call may unload the object of the outer call prematurely
because objects are unreferenced before _fini() calls.

Fix this by unreferencing objects after calling objlist_call_fini() in
dlclose(). Therefore objlist_call_fini() now calls the fini function if
the reference count of an object is 1. In addition we must restart the
list_fini traversal after every _fini() call because another dlclose()
call might have modified the reference counts.

Add an XXX comment to objlist_call_fini() about possible race with
dlopen().

PR: 133246, 149464
Reviewed by: kan, kib
libexec/rtld-elf/rtld.c