From 8e44e5593eb9b89fbc0b54fde15f130707a0d81e Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Thu, 1 Sep 2011 17:57:06 +0100 Subject: 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 | 3 +++ 1 file changed, 3 insertions(+) (limited to '.gitignore') diff --git a/.gitignore b/.gitignore index 06c3d0b6d..41fa50f5d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ *.gcda *.gcno *.gcov +*.la +*.lo *.o *.orig *.rej @@ -72,6 +74,7 @@ /tests/networkxml2argvtest /tests/nwfilterxml2xmltest /tests/openvzutilstest +/tests/shunloadtest /update.log Makefile Makefile.in -- cgit v1.2.3-65-gdbad