aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2011-09-01 17:57:06 +0100
committerEric Blake <eblake@redhat.com>2011-09-16 15:51:31 -0600
commit8e44e5593eb9b89fbc0b54fde15f130707a0d81e (patch)
treee5bf9808f5eaeb095f6a54746a3c4f2396daadd0 /tests/Makefile.am
parentqemu: add return value check (diff)
downloadlibvirt-8e44e5593eb9b89fbc0b54fde15f130707a0d81e.tar.gz
libvirt-8e44e5593eb9b89fbc0b54fde15f130707a0d81e.tar.bz2
libvirt-8e44e5593eb9b89fbc0b54fde15f130707a0d81e.zip
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.
Diffstat (limited to 'tests/Makefile.am')
-rw-r--r--tests/Makefile.am14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f4afcb915..cbbbc6f6c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -89,7 +89,9 @@ check_PROGRAMS = virshtest conftest sockettest \
nodeinfotest qparamtest virbuftest \
commandtest commandhelper seclabeltest \
hashtest virnetmessagetest virnetsockettest ssh \
- utiltest virnettlscontexttest
+ utiltest virnettlscontexttest shunloadtest
+
+check_LTLIBRARIES = libshunload.la
# This is a fake SSH we use from virnetsockettest
ssh_SOURCES = ssh.c
@@ -207,6 +209,7 @@ TESTS = virshtest \
virnetmessagetest \
virnetsockettest \
virnettlscontexttest \
+ shunloadtest \
utiltest \
$(test_scripts)
@@ -503,6 +506,15 @@ eventtest_SOURCES = \
eventtest_LDADD = -lrt $(LDADDS)
endif
+libshunload_la_SOURCES = shunloadhelper.c
+libshunload_la_LIBADD = ../src/libvirt.la
+libshunload_la_LDFLAGS = -module -avoid-version -rpath /evil/libtool/hack/to/force/shared/lib/creation
+
+shunloadtest_SOURCES = \
+ shunloadtest.c
+shunloadtest_LDADD = -lpthread
+shunloadtest_DEPENDENCIES = libshunload.la
+
if WITH_CIL
CILOPTFLAGS =
CILOPTINCS =