]> git.ipfire.org Git - thirdparty/libvirt.git/commit
Prevent crash from dlclose() of libvirt.so
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 1 Sep 2011 16:57:06 +0000 (17:57 +0100)
committerEric Blake <eblake@redhat.com>
Fri, 16 Sep 2011 21:51:31 +0000 (15:51 -0600)
commit8e44e5593eb9b89fbc0b54fde15f130707a0d81e
treee5bf9808f5eaeb095f6a54746a3c4f2396daadd0
parent14c22b3b6435e51049e4ebd3439bde9d96b17be3
Prevent crash from dlclose() of libvirt.so

When libvirt calls virInitialize it creates a thread local
for the virErrorPtr storage, and registers a callback to
cleanup memory when a thread exits. When libvirt is dlclose()d
or otherwise made non-resident, the callback function is
removed from memory, but the thread local may still exist
and if a thread later exists, it will invoke the callback
and SEGV. There may also be other thread locals with callbacks
pointing to libvirt code, so it is in general never safe to
unload libvirt.so from memory once initialized.

To allow dlclose() to succeed, but keep libvirt.so resident
in memory, link with '-z nodelete'. This issue was first
found with the libvirt CIM provider, but can potentially
hit many of the dynamic language bindings which all ultimately
involve dlopen() in some way, either on libvirt.so itself,
or on the glue code for the binding which in turns links
to libvirt

* configure.ac, src/Makefile.am: Ensure libvirt.so is linked
  with -z nodelete
* cfg.mk, .gitignore, tests/Makefile.am, tests/shunloadhelper.c,
  tests/shunloadtest.c: A test case to unload libvirt while
  a thread is still running.
.gitignore
cfg.mk
configure.ac
src/Makefile.am
tests/Makefile.am
tests/shunloadhelper.c [new file with mode: 0644]
tests/shunloadtest.c [new file with mode: 0644]