Bug 676788

Summary: libguestfs trace segfaults when list-filesystems returns error
Product: Red Hat Enterprise Linux 6 Reporter: Lei Wang <leiwang>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1CC: jzheng, mshao, yuzhang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: libguestfs-1.7.17-15.el6 Doc Type: Bug Fix
Doc Text:
The guestfish set-trace command was not prepared to handle all possible error conditions. This resulted in a segmentation fault when attempting to handle several conditions. The command now handles trace errors separately, so the segmentation fault no longer occurs. Note that this bug was reported and corrected during development. It was not seen in production systems in the field.
Story Points: ---
Clone Of:
: 682756 (view as bug list) Environment:
Last Closed: 2011-05-19 11:44:48 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:
Bug Depends On:    
Bug Blocks: 682756    

Description Lei Wang 2011-02-11 09:08:22 UTC
Description of problem:
Run "guestfish --remote" commands "set-trace 1" and "list-filesystems" before "run" or "add" command will lead to error "guestfish: remote: looks like the server is not running".

Version-Release number of selected component (if applicable):
libguestfs-1.7.17-12.el6

How reproducible:
100%

Steps to Reproduce:
1. # eval `guestfish --listen`
2. # guestfish --remote -- -add /data/images/RHEL-Server-5.5-32-hvm.raw
3. # guestfish --remote -- -set-trace 1
4. # guestfish --remote -- -list-filesystems
libguestfs: trace: list_filesystems
libguestfs: trace: list_devices
libguestfs: error: list_devices: call launch before using this function
(in guestfish, don't forget to use the 'run' command)
libguestfs: trace: list_devices = NULL (error)
libguestfs: trace: list_filesystems = ["guestfish: protocol error: could not decode reply from server
5. # guestfish --remote -- -run
guestfish: remote: looks like the server is not running

Actual results:
guestfish remote server down after reporting error, "guestfish --listen" process lost.
In guestfish interactive shell there's no similar problem, shell still work after reporting error.

Expected results:
guestfish remote server should still be alive after reporting error.

Additional info:
1. if no "set-trace" command executed before "list-filesystems", guestfish server doesn't down.
2. if execute "run" command before "list-filesystems", guestfish server doesn't down.

Comment 2 Richard W.M. Jones 2011-03-07 13:51:20 UTC
Since this bug exists upstream too, I have cloned it as
bug 682756.

Comment 3 Richard W.M. Jones 2011-03-07 14:00:17 UTC
This is nothing to do with remote, and all to
do with the trace patch.  Simple reproducer:

$ guestfish -a /dev/null -x list-filesystems
libguestfs: trace: add_drive_opts "/dev/null"
libguestfs: trace: add_drive_opts = 0
libguestfs: trace: list_filesystems
libguestfs: trace: list_devices
libguestfs: error: list_devices: call launch before using this function
(in guestfish, don't forget to use the 'run' command)
libguestfs: trace: list_devices = NULL (error)
libguestfs: trace: list_filesystems = ["Segmentation fault (core dumped)

Comment 4 Richard W.M. Jones 2011-03-07 17:42:44 UTC
http://brewweb.devel.redhat.com/brew/taskinfo?taskID=3159967
(still building)

Comment 5 Richard W.M. Jones 2011-03-07 21:34:23 UTC
I can't work out how to make any changes to the
erratum (https://errata.devel.redhat.com/errata/info/10513)
but this issue is surely serious enough that it should
stop us from going ahead and releasing the current
(1.7.17-14) package.

Comment 6 Yewei Shao 2011-03-08 01:28:02 UTC
rjones, I have changed the errata status to NEW_FILES, you can add this bug and new libguestfs version now.

Thanks,
Maggie.

Comment 7 Jinxin Zheng 2011-03-08 06:10:18 UTC

Test result for libguestfs-1.7.17-14.el6:

$ guestfish -a /dev/null -x list-filesystems
libguestfs: trace: add_drive_opts "/dev/null"
libguestfs: trace: add_drive_opts = 0
libguestfs: trace: list_filesystems
libguestfs: trace: list_devices
libguestfs: error: list_devices: call launch before using this function
(in guestfish, don't forget to use the 'run' command)
libguestfs: trace: list_devices = NULL (error)
libguestfs: trace: list_filesystems = ["Segmentation fault (core dumped)

result for libguestfs-1.7.17-15.el6:

$ guestfish -a /dev/null -x list-filesystems
libguestfs: trace: add_drive_opts "/dev/null"
libguestfs: trace: add_drive_opts = 0
libguestfs: trace: list_filesystems
libguestfs: trace: list_devices
libguestfs: error: list_devices: call launch before using this function
(in guestfish, don't forget to use the 'run' command)
libguestfs: trace: list_devices = NULL (error)
libguestfs: trace: list_filesystems = NULL (error)

see there no seg fault after upgrading.

I also tested the reproducer in Lei's description, results are similar to this test. I'm putting this VERIFIED.

Comment 11 Laura Bailey 2011-04-20 05:33:24 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
The guestfish set-trace command was not prepared to handle all possible error conditions. This resulted in a segmentation fault when attempting to handle several conditions. The command now handles trace errors separately, so the segmentation fault no longer occurs.

Note that this bug was reported and corrected during development. It was not seen in production systems in the field.

Comment 12 Richard W.M. Jones 2011-04-20 07:53:15 UTC
This is fine.

Comment 13 errata-xmlrpc 2011-05-19 11:44:48 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2011-0586.html

Comment 14 errata-xmlrpc 2011-05-19 13:10:57 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2011-0586.html