Go to file
Christophe Fergeau 30b7e299b0 Fix virt-viewer --reconnect crash with SPICE VMs
When using virt-viewer --reconnect, virt-viewer currently crashes when
a SPICE VM is destroyed with "virsh destroy"

What happens is that when the guest is destroyed, virt-viewer receives a
SPICE_CHANNEL_ERROR_IO notification in
virt_viewer_session_spice_main_channel_event().  This triggers the
emission of the "session-disconnected" signal, which will end up calling
spice_session_disconnect() (indirectly through
virt_viewer_app_disconnected/virt_viewer_app_deactivate).

Since spice-gtk commit ff25f3e, the actual session disconnection is
done from an idle.  When the "session-disconnected" emission stops, the
VirtViewerSession instance is destroyed. However, the associated
VirtViewerDisplaySpice are still alive as the various SpiceChannels
instances hold a reference through the "virt-viewer-displays" GObject
data.
These channels are destroyed when the idle queued by spice_session_disconnect()
run. The associated VirtViewerDisplay are in turn destroyed too, but
this causes attempts to use the VirtViewerSession associated with the
displays, which has already been destroyed. This causes a crash.

This commit adds a virt_viewer_session_spice_clear_displays() which is
similar to virt_viewer_session_clear_displays(), but makes sure the
"virt-viewer-displays" references are dropped too. This ensures the
VirtViewerDisplay instances don't outlive the VirtViewerSession
they are associated with.

Backtrace for the crash:

 #0  0x0000000000413f0f in display_show_hint (display=0x85ab50 [VirtViewerDisplaySpice], pspec=0x939bd0 [GParamFlags], user_data=0x0) at virt-viewer-app.c:949
 #4  0x00000031ff22a29f in <emit signal notify:show-hint on instance 0x85ab50 [VirtViewerDisplaySpice]> (instance=instance@entry=0x85ab50, signal_id=<optimized out>, detail=<optimized out>) at gsignal.c:3361
     #1  0x00000031ff20fc45 in g_closure_invoke (closure=0xa98f50, return_value=return_value@entry=0x0, n_param_values=2, param_values=param_values@entry=0x7fffffffc700, invocation_hint=invocation_hint@entry=0x7fffffffc680) at gclosure.c:768
     #2  0x00000031ff2214c9 in signal_emit_unlocked_R (node=node@entry=0x674f80, detail=detail@entry=1678, instance=instance@entry=0x85ab50, emission_return=emission_return@entry=0x0, instance_and_params=instance_and_params@entry=0x7fffffffc700) at gsignal.c:3549
     #3  0x00000031ff229ed0 in g_signal_emit_valist (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>, var_args=var_args@entry=0x7fffffffc8d0) at gsignal.c:3305
 #5  0x00000031ff214175 in g_object_dispatch_properties_changed (object=0x85ab50 [VirtViewerDisplaySpice], n_pspecs=<optimized out>, pspecs=<optimized out>) at gobject.c:1056
 #6  0x00000031ff216661 in g_object_notify (pspec=0x939bd0 [GParamFlags], object=0x85ab50 [VirtViewerDisplaySpice]) at gobject.c:1149
 #7  0x00000031ff216661 in g_object_notify (object=0x85ab50 [VirtViewerDisplaySpice], property_name=<optimized out>) at gobject.c:1197
 #8  0x000000000041e5ab in virt_viewer_display_set_show_hint (self=0x85ab50 [VirtViewerDisplaySpice], mask=1, enable=0) at virt-viewer-display.c:691
 #9  0x000000000042b62d in update_display_ready (self=0x85ab50 [VirtViewerDisplaySpice])
     at virt-viewer-display-spice.c:145
 #13 0x00000031ff22a29f in <emit signal notify:ready on instance 0x898590 [SpiceDisplay]> (instance=instance@entry=0x898590, signal_id=<optimized out>, detail=<optimized out>) at gsignal.c:3361
     #10 0x00000031ff20fc45 in g_closure_invoke (closure=0x99b280, return_value=return_value@entry=0x0, n_param_values=2, param_values=param_values@entry=0x7fffffffcc50, invocation_hint=invocation_hint@entry=0x7fffffffcbd0) at gclosure.c:768
     #11 0x00000031ff2214c9 in signal_emit_unlocked_R (node=node@entry=0x674f80, detail=detail@entry=1696, instance=instance@entry=0x898590, emission_return=emission_return@entry=0x0, instance_and_params=instance_and_params@entry=0x7fffffffcc50) at gsignal.c:3549
     #12 0x00000031ff229ed0 in g_signal_emit_valist (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>, var_args=var_args@entry=0x7fffffffce20) at gsignal.c:3305
 #14 0x00000031ff214175 in g_object_dispatch_properties_changed (object=0x898590 [SpiceDisplay], n_pspecs=<optimized out>, pspecs=<optimized out>) at gobject.c:1056
 #15 0x00000031ff216661 in g_object_notify (pspec=0xa83370 [GParamBoolean], object=0x898590 [SpiceDisplay]) at gobject.c:1149
 #16 0x00000031ff216661 in g_object_notify (object=0x898590 [SpiceDisplay], property_name=<optimized out>) at gobject.c:1197
 #17 0x00007ffff7522525 in update_ready (display=0x898590 [SpiceDisplay]) at spice-widget.c:236
 #18 0x00007ffff752257e in set_monitor_ready (self=0x898590 [SpiceDisplay], ready=0)
     at spice-widget.c:244
 #19 0x00007ffff75274e6 in primary_destroy (channel=0x89f5c0 [SpiceDisplayChannel], data=0x898590)
     at spice-widget.c:2169
 #20 0x00007ffff7528918 in channel_destroy (s=0x909fa0 [SpiceSession], channel=0x89f5c0 [SpiceDisplayChannel], data=0x898590) at spice-widget.c:2484
 #24 0x00000031ff22a29f in <emit signal ??? on instance 0x909fa0 [SpiceSession]> (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>) at gsignal.c:3361
     #21 0x00000031ff20fc45 in g_closure_invoke (closure=0xa9bda0, return_value=return_value@entry=0x0, n_param_values=2, param_values=param_values@entry=0x7fffffffd280, invocation_hint=invocation_hint@entry=0x7fffffffd200) at gclosure.c:768
     #22 0x00000031ff2214c9 in signal_emit_unlocked_R (node=node@entry=0x9c17d0, detail=detail@entry=0, instance=instance@entry=0x909fa0, emission_return=emission_return@entry=0x0, instance_and_params=instance_and_params@entry=0x7fffffffd280) at gsignal.c:3549
     #23 0x00000031ff229ed0 in g_signal_emit_valist (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>, var_args=var_args@entry=0x7fffffffd450) at gsignal.c:3305
 #25 0x00007ffff71c3248 in spice_session_channel_destroy (session=0x909fa0 [SpiceSession], channel=0x89f5c0 [SpiceDisplayChannel]) at spice-session.c:2217
 #26 0x00007ffff71bd8b2 in session_disconnect (self=0x909fa0 [SpiceSession], keep_main=0)
     at spice-session.c:281
 #27 0x00007ffff71c1b27 in session_disconnect_idle (self=0x909fa0 [SpiceSession]) at spice-session.c:1853
 #28 0x00000031fee4a0ba in g_main_context_dispatch (context=0x6a4400) at gmain.c:3122
 #29 0x00000031fee4a0ba in g_main_context_dispatch (context=context@entry=0x6a4400) at gmain.c:3737
 #30 0x00000031fee4a450 in g_main_context_iterate (context=0x6a4400, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3808
 #31 0x00000031fee4a772 in g_main_loop_run (loop=0x9890f0) at gmain.c:4002
 #32 0x0000003babc05f75 in gtk_main () at gtkmain.c:1219
 #33 0x000000000043143b in main (argc=1, argv=0x7fffffffda48) at virt-viewer-main.c:12
2015-04-01 14:27:57 +02:00
build-aux Import GNULIB rules for syntax checking code 2012-02-06 12:42:23 +00:00
data wixl: use a versionized installation directory 2015-01-12 17:04:46 +00:00
icons Add virt-viewer-usb.png 2014-11-24 14:14:14 +01:00
m4 build-sys: use git.mk to generate gitignore 2012-03-30 14:48:13 +02:00
man Fix typo s/to to/to/ 2014-10-27 16:39:06 +00:00
po POTFILES: Add virt-viewer-preferences.xml 2015-03-12 18:09:28 +01:00
src Fix virt-viewer --reconnect crash with SPICE VMs 2015-04-01 14:27:57 +02:00
.mailmap update .mailmap 2012-03-01 16:20:25 +01:00
acinclude.m4 Turn off deprecation warnings 2013-02-13 15:20:11 +00:00
AUTHORS.in Auto-generate AUTHORS file from GIT logs 2013-02-13 15:17:57 +00:00
autobuild.sh Tweak autobuild.sh to facilitate release builds 2015-01-12 11:27:56 +00:00
autogen.sh Auto-generate AUTHORS file from GIT logs 2013-02-13 15:17:57 +00:00
cfg.mk Delete browser plugin entirely 2013-03-13 11:47:42 +00:00
ChangeLog Automatically generate changelog from GIT history during make dist 2011-11-07 12:42:15 +00:00
configure.ac Bump spice-gtk to 0.28 2015-03-04 16:39:14 +01:00
COPYING Added COPYING/INSTALL files 2007-08-15 20:22:40 -04:00
git.mk Fix some syntax violations in git.mk 2012-04-05 09:27:24 +01:00
GNUmakefile Import GNULIB rules for syntax checking code 2012-02-06 12:42:23 +00:00
intltool-extract.in Add support for i18n of the UI 2010-01-11 16:01:20 +00:00
intltool-merge.in Add support for i18n of the UI 2010-01-11 16:01:20 +00:00
intltool-update.in Add support for i18n of the UI 2010-01-11 16:01:20 +00:00
maint.mk Adapt 'po file' syntax check to look at more files 2013-02-13 15:18:19 +00:00
Makefile.am Disable mime database update during make distcheck 2013-12-19 10:06:13 +01:00
mingw-virt-viewer.spec.in spec: Add virt-viewer-preferences.xml 2015-03-12 18:09:28 +01:00
NEWS Update NEWS for 2.0 release 2015-01-12 17:39:20 +00:00
README Update spice-gtk requirement everywhere 2013-12-18 15:42:24 +01:00
virt-viewer.spec.in spec: Add virt-viewer-preferences.xml 2015-03-12 18:09:28 +01:00

  Virt Viewer
  ===========

Virt Viewer provides a graphical viewer for the guest OS
display. At this time is supports guest OS using the VNC
or SPICE protocols. Further protocols may be supported in
the future as user demand dicatates. The viewer can connect
directly to both local and remotely hosted guest OS, optionally
using SSL/TLS encryption.

Virt Viewer can be built with either GTK2 or GTK3, with the
default option currently being GTK2. The choice can be made
with:

   ./configure --with-gtk=3.0  (or =2.0)

Virt Viewer uses the GTK-VNC (>= 0.4.3) widget to provide a
display of the VNC protocol, which is available from

  http://gtk-vnc.sourceforge.net/

Virt Viewer uses the SPICE-GTK (>= 0.22) widget to provide a
display of the SPICE protocol, which is available from:

  http://spice-space.org/page/Spice-Gtk

Use of either SPICE-GTK or GTK-VNC can be disabled at time
of configure, with --without-gtk-vnc or --without-spice-gtk
respectively.

Virt Viewer uses libvirt to lookup information about the
guest OS display. This is available from

  http://libvirt.org/

Further information about the Virt Viewer application can be
found on the Virt Manager website:

  http://virt-manager.org/

Feedback should be directed to the mailing list at

  http://virt-manager.org/mailinglist.html

-- End