Bug 1072062

Summary: Ruby bindings for libguestfs throws an error periodically
Product: Red Hat Enterprise Linux 6 Reporter: Timothy Williams <tiwillia>
Component: libguestfsAssignee: Pino Toscano <ptoscano>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.5CC: huzhan, leiwang, lkong, mbooth, ptoscano, rjones, wshi, yuliu
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libguestfs-1.20.11-3.el6 Doc Type: Bug Fix
Doc Text:
Cause: The Guestfs.new constructor in the Ruby binding was not implemented properly. Consequence: Creating a new Guestfs instance in Ruby would often result in an error. Fix: Rework the implementation of Guestfs.new Result: Guestfs.new works correctly.
Story Points: ---
Clone Of:
: 1072079 (view as bug list) Environment:
Last Closed: 2014-10-14 06:35:09 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: 1046509    
Bug Blocks:    
Attachments:
Description Flags
0001-ruby-Fix-.new-method-RHBZ-1046509.patch
none
0002-run-Use-timeout-foreground-option.patch
none
0003-run-Actually-use-timeout-foreground-option-RHBZ-1025.patch none

Description Timothy Williams 2014-03-03 19:58:29 UTC
Description of problem:
About 50% of the time, Creating a new Guestfs object with the ruby libguestfs bindings will fail with an Argument error:

[root@stendarr ~]# irb -rguestfs
irb(main):062:0> Guestfs::Guestfs.new
ArgumentError: expecting 0 or 1 arguments
	from (irb):62:in `new'
	from (irb):62
	from :0
irb(main):063:0> exit

[root@stendarr ~]# irb -rguestfs
irb(main):001:0> Guestfs::Guestfs.new
=> #<Guestfs::Guestfs:0x7f32e73b02b0>

Version-Release number of selected component (if applicable):
# rpm -qa | grep libguestfs
libguestfs-1.20.11-2.el6.x86_64
libguestfs-tools-1.20.11-2.el6.x86_64
ruby-libguestfs-1.20.11-2.el6.x86_64
libguestfs-tools-c-1.20.11-2.el6.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Create a new guestfs object with Guestfs::Guestfs.new()

Actual results:
irb(main):062:0> Guestfs::Guestfs.new
ArgumentError: expecting 0 or 1 arguments
	from (irb):62:in `new'
	from (irb):62
	from :0

Expected results:
irb(main):001:0> Guestfs::Guestfs.new
=> #<Guestfs::Guestfs:0x7f32e73b02b0>

Additional info:
Using the pry gem to show-method, we see the same thing being called each time:

[1] pry(main)> Guestfs::Guestfs.new
ArgumentError: expecting 0 or 1 arguments
from (pry):1:in `new'
[2] pry(main)> show-method Guestfs::Guestfs.new

From: object.c (C Method):
Owner: Class
Visibility: public
Number of lines: 3

VALUE
rb_class_new_instance(argc, argv, klass)
int argc;

[root@stendarr ~]# pry -rguestfs
[1] pry(main)> Guestfs::Guestfs.new
=> #<Guestfs::Guestfs:0x7f1fe442f058>
[2] pry(main)> show-method Guestfs::Guestfs.new

From: object.c (C Method):
Owner: Class
Visibility: public
Number of lines: 3

VALUE
rb_class_new_instance(argc, argv, klass)
int argc;

Comment 2 Richard W.M. Jones 2014-03-03 20:43:37 UTC
Reproducer:

while ! echo 'Guestfs::Guestfs.new' | irb -rguestfs | grep -sq ArgumentError; do echo -n .; done

(That command is all on a single line)

If you see a line of dots being printed, then everything is working OK.

If you see a few dots and then it stops, then you have hit the bug.

On RHEL 6 it exits after a few dots.  Upstream (Fedora 20) it keeps
printing dots.

Comment 3 Richard W.M. Jones 2014-03-03 21:10:58 UTC
I thought I'd seen this before, and it is in fact fixed
upstream by this commit which fixes bug 1046509.

https://github.com/libguestfs/libguestfs/commit/ee4ce2a0298d012bd8c500c35dc50e1f53e88c8b

Actually 3 commits are required to make the tests work
properly.  I will attach them, rebased on RHEL 6.5.

Comment 4 Richard W.M. Jones 2014-03-03 21:11:52 UTC
Created attachment 870129 [details]
0001-ruby-Fix-.new-method-RHBZ-1046509.patch

Comment 5 Richard W.M. Jones 2014-03-03 21:12:45 UTC
Created attachment 870130 [details]
0002-run-Use-timeout-foreground-option.patch

Comment 6 Richard W.M. Jones 2014-03-03 21:13:04 UTC
Created attachment 870131 [details]
0003-run-Actually-use-timeout-foreground-option-RHBZ-1025.patch

Comment 7 bfan 2014-03-04 06:13:36 UTC
Reproduced with libguestfs-1.20.11-2.el6.x86_64

It can print a few dots and then stops, sometimes there's no output 

[root]# while ! echo 'Guestfs::Guestfs.new' | irb -rguestfs | grep -sq ArgumentError; do echo -n .; done
[root]# while ! echo 'Guestfs::Guestfs.new' | irb -rguestfs | grep -sq ArgumentError; do echo -n .; done
.[root]#while ! echo 'Guestfs::Guestfs.new' | irb -rguestfs | grep -sq ArgumentError; do echo -n .; done
[root]# while ! echo 'Guestfs::Guestfs.new' | irb -rguestfs | grep -sq ArgumentError; do echo -n .; done
.[root]# while ! echo 'Guestfs::Guestfs.new' | irb -rguestfs | grep -sq ArgumentError; do echo n .; done
......[root@amd-1216-8-3 home]

Comment 9 bfan 2014-05-14 02:51:36 UTC
Verified with libguestfs-1.20.11-3.el6.x86_64

# while ! echo 'Guestfs::Guestfs.new' | irb -rguestfs | grep -sq ArgumentError; do echo -n .; done
..................................................................................................................................................................................................................................

Can see a line of dots be printed, match the expect result

Comment 10 errata-xmlrpc 2014-10-14 06:35:09 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, and where to find the updated
files, follow the link below.

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

http://rhn.redhat.com/errata/RHBA-2014-1458.html