Bug 1926691

Summary: virt-viewer will core dump with -r and -d options together via ssh when destroying the vnc vm
Product: Red Hat Enterprise Linux 8 Reporter: zhoujunqin <juzhou>
Component: virt-viewerAssignee: Default Assignee for SPICE Bugs <rh-spice-bugs>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 8.4CC: berrange, mdean, mxie, tyan, tzheng, uril, virt-maint, xiaodwan
Target Milestone: rcKeywords: Triaged
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: virt-viewer-9.0-10.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-11-09 17:48:12 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1948357    

Description zhoujunqin 2021-02-09 09:40:57 UTC
Description of problem:
virt-viewer will core dump with -r and -d options together via ssh when destroying the vm, only for the vm with vnc graphics.

Version-Release number of selected component (if applicable):
virt-viewer-9.0-9.el8.x86_64
virt-viewer-debuginfo-9.0-9.el8.x86_64
gtk-vnc2-0.9.0-2.el8.x86_64
libgovirt-0.3.7-4.el8.x86_64
kernel-4.18.0-283.el8.x86_64
libvirt-6.0.0-34.module+el8.4.0+9758+5c420eed.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Prepare a running vnc vm on host A, which listens to all public network interfaces.
...

# virsh dumpxml vnc
    <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0' sharePolicy='ignore'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
...

2. On host B, use virt-viewer to connect to the vm on host A with -r and -d options together.
# virt-viewer -c qemu+ssh://$host_A_ip/system vnc -r -d

Result: After inputting the password for one time, connecting to vm with vnc graphics on host A successfully.

3. Destroy the guest on host A
# virsh destroy vnc
Domain vnc destroyed

# virt-viewer -c qemu+ssh://$host_A_ip/system vnc -r -d

(virt-viewer:132323): GLib-GIO-CRITICAL **: 03:02:29.185: g_dbus_proxy_new_sync: assertion 'G_IS_DBUS_CONNECTION (connection)' failed
root@$host_A's password:

...
Segmentation fault (core dumped)

Result: Virt-viewer core dumped.

# ll /var/lib/systemd/coredump/core.virt-viewer.0.21b774aa4dd74c648f512f7405508319.135615.1612863470000000.lz4 
-rw-r-----. 1 root root 3326851 Feb  9 04:37 /var/lib/systemd/coredump/core.virt-viewer.0.21b774aa4dd74c648f512f7405508319.135615.1612863470000000.lz4

# coredumpctl dump 
           PID: 135615 (virt-viewer)
           UID: 0 (root)
           GID: 0 (root)
        Signal: 11 (SEGV)
     Timestamp: Tue 2021-02-09 04:37:50 EST (1min 18s ago)
  Command Line: virt-viewer -c qemu+ssh://$host_A_ip/system vnc -r -d
    Executable: /usr/bin/virt-viewer
 Control Group: /user.slice/user-0.slice/session-5.scope
          Unit: session-5.scope
         Slice: user-0.slice
       Session: 5
     Owner UID: 0 (root)
       Boot ID: 21b774aa4dd74c648f512f7405508319
    Machine ID: 30bd6ea3b23645d5859a4277ecf75fe9
      Hostname: $host_B
       Storage: /var/lib/systemd/coredump/core.virt-viewer.0.21b774aa4dd74c648f512f7405508319.135615.1612863470000000.lz4
       Message: Process 135615 (virt-viewer) of user 0 dumped core.
                
                Stack trace of thread 135615:
                #0  0x00007f57ea865c84 vnc_display_set_keyboard_grab (libgtk-vnc-2.0.so.0)
                #1  0x000056086a738aa3 virt_viewer_display_vnc_new (virt-viewer)
                #2  0x000056086a737711 virt_viewer_session_vnc_disconnected (virt-viewer)
                #3  0x00007f57e79ae3fd g_closure_invoke (libgobject-2.0.so.0)
                #4  0x00007f57e79c1985 signal_emit_unlocked_R (libgobject-2.0.so.0)
                #5  0x00007f57e79caa46 g_signal_emit_valist (libgobject-2.0.so.0)
                #6  0x00007f57e79cb083 g_signal_emit (libgobject-2.0.so.0)
                #7  0x00007f57ea862f74 on_disconnected (libgtk-vnc-2.0.so.0)
                #8  0x00007f57e79ae3fd g_closure_invoke (libgobject-2.0.so.0)
                #9  0x00007f57e79c1985 signal_emit_unlocked_R (libgobject-2.0.so.0)
                #10 0x00007f57e79caa46 g_signal_emit_valist (libgobject-2.0.so.0)
                #11 0x00007f57e79cb083 g_signal_emit (libgobject-2.0.so.0)
                #12 0x00007f57ea645db8 do_vnc_connection_emit_main_context (libgvnc-1.0.so.0)
                #13 0x00007f57e76cf0bb g_idle_dispatch (libglib-2.0.so.0)
                #14 0x00007f57e76d277d g_main_context_dispatch (libglib-2.0.so.0)
                #15 0x00007f57e76d2b48 g_main_context_iterate.isra.21 (libglib-2.0.so.0)
                #16 0x00007f57e76d2be0 g_main_context_iteration (libglib-2.0.so.0)
                #17 0x00007f57e7c9b12d g_application_run (libgio-2.0.so.0)
                #18 0x000056086a725850 main (virt-viewer)
                #19 0x00007f57e6d5b493 __libc_start_main (libc.so.6)
                #20 0x000056086a7258ae _start (virt-viewer)
                
                Stack trace of thread 135616:
                #0  0x00007f57e6e29a31 __poll (libc.so.6)
                #1  0x00007f57e76d2ab6 g_main_context_iterate.isra.21 (libglib-2.0.so.0)
                #2  0x00007f57e76d2be0 g_main_context_iteration (libglib-2.0.so.0)
                #3  0x00007f57e76d2c31 glib_worker_main (libglib-2.0.so.0)
                #4  0x00007f57e76fae1a g_thread_proxy (libglib-2.0.so.0)
                #5  0x00007f57e710514a start_thread (libpthread.so.0)
                #6  0x00007f57e6e34db3 __clone (libc.so.6)
Refusing to dump core to tty (use shell redirection or specify --output).


Actual results:
As described.

Expected results:
virt-viewer will not crash and shows 'Waiting for guest domain to  re-start' in the vm console.

Additional info:
1. I can't reproduce it with spice graphics, thanks.

Comment 1 Jakub Janků 2021-02-16 15:21:11 UTC
Hi, I believe that the root cause is the same as for bz#1911224, so I'm assigning this one to myself too.
It's reproducible without ssh. Connection via vnc on localhost just with the --reconnect option also segfaults.

(fix waiting for review: https://gitlab.com/virt-viewer/virt-viewer/-/merge_requests/61)

Comment 2 Jakub Janků 2021-02-19 09:58:58 UTC
Should be fixed by:
https://gitlab.com/virt-viewer/virt-viewer/-/merge_requests/61

Comment 3 zhoujunqin 2021-03-15 10:44:59 UTC
I can reproduce this bug with the package:

virt-viewer-9.0-9.el8.x86_64

Then try to verify this bug with a new build:
virt-viewer-9.0-10.el8.x86_64

Steps:
1. Prepare a running vnc vm on host A, which listens to all public network interfaces.
...

# virsh dumpxml win10
    <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>

...

2. On host B, use virt-viewer to connect to the vm on host A with -r and -d options together.
# virt-viewer -c qemu+ssh://$host_A_ip/system win10 -r -d
root@$host_A's password:

Result: After inputting the password for one time, connecting to vm with vnc graphics on host A successfully.

3. Destroy the guest on host A
# virsh destroy vnc
Domain vnc destroyed

Test result:
virt-viewer keeps connection with vm and displays "Waiting for the guest domain to re-start".
And after start vm again, virt-viewer shows the console of vm without error.

So I think the bug issue has been fixed, thanks.

Comment 12 zhoujunqin 2021-04-13 12:00:18 UTC
Verify this bug with packages:
virt-viewer-9.0-10.el8.x86_64
libvirt-6.0.0-35.module+el8.4.0+10230+7a9b21e4.x86_64
qemu-kvm-4.2.0-48.module+el8.4.0+10368+630e803b.x86_64


Steps:
1. Prepare a running vnc vm on host A, which listens to all public network interfaces.
...

# virsh dumpxml vnc
    <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>

...

2. On host B, use virt-viewer to connect to the vm on host A with -r and -d options together.
# virt-viewer -c qemu+ssh://$host_A_ip/system win10 -r -d
root@$host_A's password:

Result: After inputting the password for one time, connecting to vm with vnc graphics on host A successfully.

3. Destroy the guest on host A
# virsh destroy vnc
Domain vnc destroyed

Test result:
virt-viewer keeps connection with vm and displays "Waiting for the guest domain to re-start".
And after start vm again, virt-viewer shows the console of vm without error.

So I move this bug from ON_QA to VERIFIED status, thanks.

Comment 16 errata-xmlrpc 2021-11-09 17:48:12 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (virt-viewer bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:4165