Monitor Reference Counting Fix: The monitor was being unreferenced
inside virCHEventHandlerLoop, that has led to a segmentation fault.
The monitor was unreferenced after successful child thread creation
while it was still being used in the child thread. To maintain
correct reference counting, the monitor unreference has been moved
to virCHStartEventHandler (the child thread). Other monitor
unreference in virCHStartEventHandler are retained for cases where
new thread creation fails, as the reference in not used afterward.
VM Reference Counting Fix: The VM object was being unreferenced
in virCHEventHandlerLoop while it was still being used by the debug
print. To resolve this, the VM unreference has been moved to after
the debug print.
Signed-off-by: Kirill Shchetiniuk <kshcheti(a)redhat.com>
---
src/ch/ch_events.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/ch/ch_events.c b/src/ch/ch_events.c
index 1cce30836a..2dd3e7ecc2 100644
--- a/src/ch/ch_events.c
+++ b/src/ch/ch_events.c
@@ -287,8 +287,9 @@ virCHEventHandlerLoop(void *data)
}
g_clear_pointer(&mon->event_buffer.buffer, g_free);
- virObjectUnref(vm);
VIR_DEBUG("%s: Event handler loop thread exiting", vm->def->name);
+ virObjectUnref(vm);
+ virObjectUnref(mon);
return;
}
@@ -308,7 +309,6 @@ virCHStartEventHandler(virCHMonitor *mon)
virObjectUnref(mon);
return -1;
}
- virObjectUnref(mon);
g_atomic_int_set(&mon->event_handler_stop, 0);
return 0;
--
2.48.1