Re: [PATCH] Fix SEGV on exit after domainEventDeregister()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ping.

Am Dienstag 13 Juli 2010 10:54:26 schrieb Philipp Hahn:
> When the last callback is removed using domainEventDeregister(), the
> events dispatcher is deregistered from the C-library, but
> domainEventsCallbacks is still an empty list.
> On shutdown __del__() deregisters the dispatacher again, which SEGVs
>
> 	# You need the event-loop implementation from the Python examples;
> 	# give the file a name which is importable by Python.
> 	ln examples/domain-events/events-python/event-test.py eloop.py
> 	python -c 'from eloop import *
> 	import sys
>
> 	def dump(*args): print " ".join(map(str, args))
>
> 	virEventLoopPureStart()
> 	c = libvirt.open("xen:///")
> 	c.domainEventRegister(dump, None)
> 	c.domainEventDeregister(dump)
> 	sys.exit(0)'
>
> domainEventDeregister() needs to delete domainEventCallbacks so subsequent
> calls to __del__() and domainEventRegister() choose the right code paths.
> Setting it to None is not enough, since calling domainEventRegiser() again
> would trigger an TypeError.
>
> Signed-off-by: Philipp Hahn <hahn@xxxxxxxxxxxxx>
> ---
>  python/libvirt-override-virConnect.py |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)


-- 
Philipp Hahn           Open Source Software Engineer      hahn@xxxxxxxxxxxxx   
Univention GmbH        Linux for Your Business        fon: +49 421 22 232- 0
Mary-Somerville-Str.1  28359 Bremen                   fax: +49 421 22 232-99
                                                    http://www.univention.de
From 5cffa31ebdb1b2f82d1d66fb56d2fc36334bb7f3 Mon Sep 17 00:00:00 2001
From: Philipp Hahn <hahn@xxxxxxxxxxxxx>
Date: Tue, 13 Jul 2010 10:37:24 +0200
Subject: [PATCH] Fix SEGV on exit after domainEventDeregister()

When the last callback is removed using domainEventDeregister(), the
events dispatcher is deregistered from the C-library, but
domainEventsCallbacks is still an empty list.
On shutdown __del__() deregisters the dispatacher again, which SEGVs

	# You need the event-loop implementation from the Python examples;
	# give the file a name which is importable by Python.
	ln examples/domain-events/events-python/event-test.py eloop.py
	python -c 'from eloop import *
	import sys

	def dump(*args): print " ".join(map(str, args))

	virEventLoopPureStart()
	c = libvirt.open("xen:///")
	c.domainEventRegister(dump, None)
	c.domainEventDeregister(dump)
	sys.exit(0)'

domainEventDeregister() needs to delete domainEventCallbacks so subsequent
calls to __del__() and domainEventRegister() choose the right code paths.
Setting it to None is not enough, since calling domainEventRegiser() again
would trigger an TypeError.
---
 python/libvirt-override-virConnect.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/python/libvirt-override-virConnect.py b/python/libvirt-override-virConnect.py
index 52914dc..e344303 100644
--- a/python/libvirt-override-virConnect.py
+++ b/python/libvirt-override-virConnect.py
@@ -2,7 +2,7 @@
         try:
            for cb,opaque in self.domainEventCallbacks.items():
                del self.domainEventCallbacks[cb]
-           self.domainEventCallbacks = None
+           del self.domainEventCallbacks
            libvirtmod.virConnectDomainEventDeregister(self._o, self)
         except AttributeError:
            pass
@@ -17,6 +17,7 @@
         try:
             del self.domainEventCallbacks[cb]
             if len(self.domainEventCallbacks) == 0:
+                del self.domainEventCallbacks
                 ret = libvirtmod.virConnectDomainEventDeregister(self._o, self)
                 if ret == -1: raise libvirtError ('virConnectDomainEventDeregister() failed', conn=self)
         except AttributeError:
-- 
1.5.6.3

Attachment: signature.asc
Description: This is a digitally signed message part.

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]