Bug 250379

Summary: virsh segfaults after attempting to connecting to a non-existant hypervisor
Product: Red Hat Enterprise Linux 5 Reporter: David Robinson <drobinso>
Component: libvirtAssignee: Daniel Veillard <veillard>
Status: CLOSED NEXTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 5.0CC: xen-maint
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-08-01 09:35:34 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description David Robinson 2007-08-01 08:32:08 UTC
Description of problem:
virsh crashes after attempting to connect to an invalid hypervisor.

Version-Release number of selected component (if applicable):
$ rpm -q libvirt glibc xen kernel-xen
libvirt-0.1.8-15.el5.x86_64
glibc-2.5-12.i686
glibc-2.5-12.x86_64
xen-3.0.3-25.0.3.el5.x86_64
kernel-xen-2.6.18-8.1.8.el5.x86_64

How reproducible:
100%

Steps to Reproduce:
$ virsh 
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
       'quit' to quit

virsh # connect blah
libvir: error : no support for hypervisor
error: Failed to connect to the hypervisor

virsh # connect
Segmentation fault (core dumped)

Additional info:
(gdb) bt
#0  malloc_consolidate (av=0x3474b49960) at malloc.c:4700
#1  0x000000347486eea2 in _int_malloc (av=0x3474b49960, bytes=640) at malloc.c:4081
#2  0x00000034748706dd in *__GI___libc_malloc (bytes=640) at malloc.c:3468
#3  0x0000003475c05d9c in virHashCreate (size=511992576) at hash.c:92
#4  0x0000003475c05e3e in virGetConnect () at hash.c:537
#5  0x0000003475c05718 in virConnectOpen (name=0x3475c16882 "Xen") at libvirt.c:241
#6  0x0000000000404ea4 in cmdConnect (ctl=0x7fff14294b80, cmd=0x1e846280) at
virsh.c:298
#7  0x0000000000405d97 in vshCommandRun (ctl=0x7fff14294b80, cmd=0x1e846280) at
virsh.c:1975
#8  0x000000000040655c in main (argc=0, argv=0x7fff14294cd8) at virsh.c:2724
#9  0x000000347481d8a4 in __libc_start_main (main=0x405e69 <main>, argc=1,
ubp_av=0x7fff14294cd8, init=<value optimized out>, fini=<value optimized out>, 
    rtld_fini=<value optimized out>, stack_end=0x7fff14294cc8) at libc-start.c:231
#10 0x0000000000401f79 in _start ()

# tail -1 /var/log/messages
Aug  1 17:59:12 friday kernel: virsh[7617]: segfault at 000000349338fcc8 rip
000000347486ca27 rsp 00007fff14294810 error 4

The problem occurs on i386 also, below is the message the occurs from a
*different system* (the message didn't appear on my system):

*** glibc detected *** virsh: malloc(): memory corruption (fast):
0x09e54968 ***
======= Backtrace: =========
/lib/i686/nosegneg/libc.so.6[0xc1ec8e]
/lib/i686/nosegneg/libc.so.6(__libc_malloc+0x85)[0xc1fb95]
/lib/i686/nosegneg/libc.so.6(strndup+0x39)[0xc23f29]
/usr/lib/libvirt.so.0[0x6cb802]
/usr/lib/libvirt.so.0[0x6cb6e5]
/usr/lib/libvirt.so.0[0x6cb899]
/usr/lib/libvirt.so.0[0x6c6eac]
/usr/lib/libvirt.so.0[0x6c6f9c]
/usr/lib/libvirt.so.0[0x6caa81]
/usr/lib/libvirt.so.0(virConnectOpen+0xe0)[0x6bd682]
virsh[0x804c4f4]
virsh[0x804d43e]
virsh[0x804dc96]
/lib/i686/nosegneg/libc.so.6(__libc_start_main+0xdc)[0xbccdec]
virsh[0x8049641]
======= Memory map: ========
00101000-00113000 r-xp 00000000 fd:00 48553436 /usr/lib/libz.so.1.2.3
00113000-00114000 rwxp 00011000 fd:00 48553436 /usr/lib/libz.so.1.2.3
001ac000-001ae000 r-xp 00000000 fd:00 51841222 /lib/libdl-2.5.so
001ae000-001af000 r-xp 00001000 fd:00 51841222 /lib/libdl-2.5.so
001af000-001b0000 rwxp 00002000 fd:00 51841222 /lib/libdl-2.5.so
001d0000-001e9000 r-xp 00000000 fd:00 51841342 /lib/ld-2.5.so
001e9000-001ea000 r-xp 00018000 fd:00 51841342 /lib/ld-2.5.so
001ea000-001eb000 rwxp 00019000 fd:00 51841342 /lib/ld-2.5.so
004a5000-004a9000 r-xp 00000000 fd:00 48537106 /usr/lib/libxenstore.so.3.0.0
004a9000-004aa000 rwxp 00003000 fd:00 48537106 /usr/lib/libxenstore.so.3.0.0
004aa000-004ad000 rwxp 004aa000 00:00 0
00577000-00578000 r-xp 00577000 00:00 0 [vdso]
006b9000-006d3000 r-xp 00000000 fd:00 48540039 /usr/lib/libvirt.so.0.1.8
006d3000-006d4000 rwxp 0001a000 fd:00 48540039 /usr/lib/libvirt.so.0.1.8
00860000-008a0000 r-xp 00000000 fd:00 48535864 /usr/lib/libncurses.so.5.5
008a0000-008a8000 rwxp 00040000 fd:00 48535864 /usr/lib/libncurses.so.5.5
008a8000-008a9000 rwxp 008a8000 00:00 0
00bb7000-00cf1000 r-xp 00000000 fd:00 51839005
/lib/i686/nosegneg/libc-2.5.so
00cf1000-00cf3000 r-xp 0013a000 fd:00 51839005
/lib/i686/nosegneg/libc-2.5.so
00cf3000-00cf4000 rwxp 0013c000 fd:00 51839005
/lib/i686/nosegneg/libc-2.5.so
00cf4000-00cf7000 rwxp 00cf4000 00:00 0
00cf9000-00d1e000 r-xp 00000000 fd:00 51839049
/lib/i686/nosegneg/libm-2.5.so
00d1e000-00d1f000 r-xp 00024000 fd:00 51839049
/lib/i686/nosegneg/libm-2.5.so
00d1f000-00d20000 rwxp 00025000 fd:00 51839049
/lib/i686/nosegneg/libm-2.5.so
00d28000-00d3b000 r-xp 00000000 fd:00 51839029
/lib/i686/nosegneg/libpthread-2.5.so
00d3b000-00d3c000 r-xp 00012000 fd:00 51839029
/lib/i686/nosegneg/libpthread-2.5.so
00d3c000-00d3d000 rwxp 00013000 fd:00 51839029
/lib/i686/nosegneg/libpthread-2.5.so
00d3d000-00d3f000 rwxp 00d3d000 00:00 0
0518d000-05198000 r-xp 00000000 fd:00 51841338
/lib/libgcc_s-4.1.1-20070105.so.1
05198000-05199000 rwxp 0000a000 fd:00 51841338
/lib/libgcc_s-4.1.1-20070105.so.1
05288000-053b4000 r-xp 00000000 fd:00 48555642 /usr/lib/libxml2.so.2.6.26
053b4000-053b9000 rwxp 0012b000 fd:00 48555642 /usr/lib/libxml2.so.2.6.26
053b9000-053ba000 rwxp 053b9000 00:00 0
05abc000-05aeb000 r-xp 00000000 fd:00 63537215 /usr/lib/libreadline.so.5.1
05aeb000-05aef000 rwxp 0002f000 fd:00 63537215 /usr/lib/libreadline.so.5.1
05aef000-05af0000 rwxp 05aef000 00:00 0
08048000-08050000 r-xp 00000000 fd:00 63406296 /usr/bin/virsh
08050000-08051000 rw-p 00008000 fd:00 63406296 /usr/bin/virsh
09e54000-09e75000 rw-p 09e54000 00:00 0
b7c00000-b7c21000 rw-p b7c00000 00:00 0
b7c21000-b7d00000 ---p b7c21000 00:00 0
b7ddd000-b7fdd000 r--p 00000000 fd:00 48535866
/usr/lib/locale/locale-archive
b7fdd000-b7fe0000 rw-p b7fdd000 00:00 0
b7ff5000-b7ffc000 r--s 00000000 fd:00 48627972
/usr/lib/gconv/gconv-modules.cache
b7ffc000-b7ffe000 rw-p b7ffc000 00:00 0
bfcb8000-bfccd000 rw-p bfcb8000 00:00 0 [stack]
Aborted

Comment 1 Daniel Veillard 2007-08-01 09:35:34 UTC
Yes there were bugs like this cleaned up since 0.1.8 . It is now fixed in
current releases and will be fixed as part of RHEL5U1 rebase:

[root@paphio ~]# virsh 
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
       'quit' to quit

virsh # connect blah
libvir: error : could not connect to blah
error: Failed to connect to the hypervisor

virsh # connect

virsh # list
 Id Name                 State
----------------------------------
  0 Domain-0             running
 16 WinXP                blocked

virsh # quit

[root@paphio ~]# rpm -q libvirt xen kernel-xen
libvirt-0.3.1-2
xen-3.0.3-29.el5
kernel-xen-2.6.18-34.el5
[root@paphio ~]# uname -a
Linux paphio.veillard.com 2.6.18-34.el5xen #1 SMP Thu Jul 12 16:51:20 EDT 2007
x86_64 x86_64 x86_64 GNU/Linux
[root@paphio ~]# 

  thanks for the report but this was already fixed upstream :-)

Daniel