[DRE-maint] [Bug 514899] Re: Multithreaded Gtk applications using Ruby bindings freeze

Jean-Baptiste Lallement jean-baptiste.lallement at ubuntu.com
Fri Aug 13 13:10:25 UTC 2010


** Description changed:

  Binary package hint: libgtk2-ruby
  
  In Ubuntu 9.10 with the version of libgtk2-ruby from the repositories
  (0.19.0), new threads cause the Gtk main loop to freeze. As an example,
  the following code will never produce any output:
  
+ 
+ ===== Impact =====
+ I don't know which program available directly within Ubuntu is written in Ruby-GTK+, but those which do and which are using the Ruby Thread class are broken, and of course developing such a program is broken too.
+ 
+ The fix is available in ruby-gnome2 since version 0.19.2 and was
+ introduced through SVN revisions 3692[1] and 3694[2]. Both are within
+ the attachment "ruby-gnome2-gtk-thread-patch.debdiff" in comment #1.
+ 
+ [1] http://ruby-gnome2.svn.sourceforge.net/viewvc/ruby-gnome2?view=rev&revision=3692
+ [2] http://ruby-gnome2.svn.sourceforge.net/viewvc/ruby-gnome2?view=rev&revision=3694
+ 
+ 
+ TEST CASE:
   require 'gtk2'
  
   Thread.new do
     sleep 1 # Look busy
     exit    # Finished, exit
   end
  
   # Main loop
   loop do
     # Process all currently pending events
     Gtk.main_iteration while Gtk.events_pending?
     print '.'
   end
  
  However, when the latest version of the bindings is installed (0.19.3)
  the program works as expected, filling the screen with dots.
  
+ TEST CASE 2:
+ Here is another example for reproducing this bug:
+ 
+ require "gtk2"
+ include Gtk, GLib
+ # Create widgets
+ window = Window.new
+ vbox = VBox.new(false, 2)
+ button = Button.new("Run Thread")
+ progress = ProgressBar.new
+ # Pack widgets
+ window.add(vbox)
+ vbox.add(button)
+ vbox.add(progress)
+ # Set default window size
+ window.default_width = 120
+ window.default_height = 50
+ window.show_all
+ # Connect signals
+ button.signal_connect("clicked") do
+         Thread.new do
+                 puts "Thread started!"
+                 progress.pulse
+         end
+ end
+ window.signal_connect("destroy") { main_quit }
+ # Show all and run
+ main # start the GTK+ main loop
+ 
+ The test program shows a window with a button and a progress bar.
+ Clicking the button will execute a Ruby Thread object, and the GUI
+ visual elements/the GTK+ main loop will remain freezed.
+ 
+ REGRESSION:
+ The only package that depends on ruby-gnome2 in karmic is alien-arena-browser, which is far from being a critical application. The impact of a potential regression would be very limited.
+ 
+ The example in the bug description is supposed to print dots, and
+ instead it doesn't.
+ 
  This problem is also reported at:
  http://sourceforge.net/mailarchive/forum.php?thread_name=dc3bf8581001120746kb5da118udd0a74439cc4dcd9%40mail.gmail.com&forum_name=ruby-gnome2-devel-en

-- 
Multithreaded Gtk applications using Ruby bindings freeze
https://bugs.launchpad.net/bugs/514899
You received this bug notification because you are subscribed to Ubuntu.

Status in “ruby-gnome2” package in Ubuntu: Fix Released
Status in “ruby-gnome2” source package in Karmic: Fix Committed

Bug description:
Binary package hint: libgtk2-ruby

In Ubuntu 9.10 with the version of libgtk2-ruby from the repositories (0.19.0), new threads cause the Gtk main loop to freeze. As an example, the following code will never produce any output:


===== Impact =====
I don't know which program available directly within Ubuntu is written in Ruby-GTK+, but those which do and which are using the Ruby Thread class are broken, and of course developing such a program is broken too.

The fix is available in ruby-gnome2 since version 0.19.2 and was introduced through SVN revisions 3692[1] and 3694[2]. Both are within the attachment "ruby-gnome2-gtk-thread-patch.debdiff" in comment #1.

[1] http://ruby-gnome2.svn.sourceforge.net/viewvc/ruby-gnome2?view=rev&revision=3692
[2] http://ruby-gnome2.svn.sourceforge.net/viewvc/ruby-gnome2?view=rev&revision=3694


TEST CASE:
 require 'gtk2'

 Thread.new do
   sleep 1 # Look busy
   exit    # Finished, exit
 end

 # Main loop
 loop do
   # Process all currently pending events
   Gtk.main_iteration while Gtk.events_pending?
   print '.'
 end

However, when the latest version of the bindings is installed (0.19.3) the program works as expected, filling the screen with dots.

TEST CASE 2:
Here is another example for reproducing this bug:

require "gtk2"
include Gtk, GLib
# Create widgets
window = Window.new
vbox = VBox.new(false, 2)
button = Button.new("Run Thread")
progress = ProgressBar.new
# Pack widgets
window.add(vbox)
vbox.add(button)
vbox.add(progress)
# Set default window size
window.default_width = 120
window.default_height = 50
window.show_all
# Connect signals
button.signal_connect("clicked") do
        Thread.new do
                puts "Thread started!"
                progress.pulse
        end
end
window.signal_connect("destroy") { main_quit }
# Show all and run
main # start the GTK+ main loop

The test program shows a window with a button and a progress bar. Clicking the button will execute a Ruby Thread object, and the GUI visual elements/the GTK+ main loop will remain freezed.

REGRESSION:
The only package that depends on ruby-gnome2 in karmic is alien-arena-browser, which is far from being a critical application. The impact of a potential regression would be very limited.

The example in the bug description is supposed to print dots, and instead it doesn't.

This problem is also reported at:
http://sourceforge.net/mailarchive/forum.php?thread_name=dc3bf8581001120746kb5da118udd0a74439cc4dcd9%40mail.gmail.com&forum_name=ruby-gnome2-devel-en










More information about the Pkg-ruby-extras-maintainers mailing list