Forum: Ruby-Gnome 2 Garbage Collection causes segfaults

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Conan (Guest)
on 2007-06-13 19:46
Hi.  I'm having a problem with a Ruby-Gnome2 application I've been
building.  For some reason my program randomly segfaults.  I fixed this
by disabling garbage collection(Maybe GC was cleaning up gnome objects
that were still in use?) but of course now my application runs out of
memory relatively quickly (not so much from the gtk objects, but from my
non-gnome objects that are memory hogs that need garbage collection).

I was wondering if there is any known reasons that the garbage
collection might cause problems with ruby-gnome2, and if there are any
workarounds I might employ to avoid them besides disabling my garbage
collection?

Any ideas would be appreciated

Conan
Markus Koller (Guest)
on 2007-06-13 20:06
(Received via mailing list)
On Wed, Jun 13, 2007 at 07:46:55PM +0200, Conan wrote:
> I was wondering if there is any known reasons that the garbage
> collection might cause problems with ruby-gnome2, and if there are any
> workarounds I might employ to avoid them besides disabling my garbage
> collection?

I guess you're still using Ruby-Gnome2 version 0.15, which had lots of
errors
related to memory management. You should upgrade to 0.16.

FYI, you can also manually run garbage collection with GC.start.


Cheers,
Markus

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
Conan (Guest)
on 2007-06-13 20:29
Markus Koller wrote:
> I guess you're still using Ruby-Gnome2 version 0.15, which had lots of
> errors
> related to memory management. You should upgrade to 0.16.
>
> FYI, you can also manually run garbage collection with GC.start.
>

I'm using the ruby-gnome2-0.16.0-1-i386-mswin32.exe installer, so that
should be ok?.

GC.start won't run while GC is disabled(and when it is enabled, it'll
occasionally cause an segfault which seems to be my problem)
5de8eb50c51eb654ae4a4e7d569f6f80?d=identicon&s=25 Conan R. (conan)
on 2007-06-14 00:05
Ok, hopefully this code comes out unmangled...

To trigger a segfault, just run this code and click furiously on the
listbox.  After a while(10 seconds of furious mouse clicking) it'll
segfault on my computer.  I'm running ruby 1.8.2 on a windows 32 bit
machine with ruby-gnome2-0.16.0-1(Windows installer)


#Contrived example to get a segfault bug
require 'gtk2'

#Fill  up the list box
def fill_box(model)
  ['Stuff','More Stuff','Cool Stuff','Lame stuff'].each do |l|
    iter = model.append
    iter[0] = l
  end
end

window = Gtk::Window.new
label_model = Gtk::ListStore.new(String)
label_box = Gtk::TreeView.new(label_model)

t_render = Gtk::CellRendererText.new
label_box.append_column(Gtk::TreeViewColumn.new("Sample Set", t_render,
:text => 0))
window.add(label_box)
fill_box(label_model)

label_box.signal_connect("cursor-changed") do |treeview|
  0.upto(100) do |iii| #More chances to generate a bug
    current_label = treeview.selection.selected
    current_label = current_label[0] if(current_label != nil)
    label_model.clear

    fill_box(label_model)
  end
end

window.show_all
Gtk.main
29055d42380dd36c3eaa2e06ef3904c8?d=identicon&s=25 Daniel L. (lucraft)
on 2007-06-14 08:53
(Received via mailing list)
After about a minute of clicking as fast as I possibly could, I started
to consider the possibility that you were having a little fun with me.
:)

Sorry, no segfaulting. Have you tried running with Ruby 1.8.6? I have
used another C extension that segfaulted until I upgraded.

best,
Dan

Conan Rubymanjaro wrote:
>
> label_box = Gtk::TreeView.new(label_model)
>     current_label = current_label[0] if(current_label != nil)
>     label_model.clear
>
>     fill_box(label_model)
>   end
> end
>
> window.show_all
> Gtk.main
>

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
5de8eb50c51eb654ae4a4e7d569f6f80?d=identicon&s=25 Conan R. (conan)
on 2007-06-14 16:48
Hmm, maybe thats the case then.  I'll give it a shot and see what
happens. (Also, try changing the 100 to 1000 or 10000, that reduces the
number of furious clicks needed)


Daniel Lucraft wrote:
> After about a minute of clicking as fast as I possibly could, I started
> to consider the possibility that you were having a little fun with me.
> :)
>
> Sorry, no segfaulting. Have you tried running with Ruby 1.8.6? I have
> used another C extension that segfaulted until I upgraded.
>
> best,
> Dan
>
> Conan Rubymanjaro wrote:
>>
>> label_box = Gtk::TreeView.new(label_model)
>>     current_label = current_label[0] if(current_label != nil)
>>     label_model.clear
>>
>>     fill_box(label_model)
>>   end
>> end
>>
>> window.show_all
>> Gtk.main
>>
5de8eb50c51eb654ae4a4e7d569f6f80?d=identicon&s=25 Conan R. (conan)
on 2007-06-14 18:40
Yeah, your right.  Upgrading to Ruby 1.8.6 seems to have solved the
problems.  Great, thanks for your help!

Conan Rubymanjaro wrote:
> Hmm, maybe thats the case then.  I'll give it a shot and see what
> happens. (Also, try changing the 100 to 1000 or 10000, that reduces the
> number of furious clicks needed)
>
Masao Mutoh (Guest)
on 2007-06-15 18:00
(Received via mailing list)
Hi,

If you'll have segfaults problem again, require the code below
before executing your apps.

gctest.rb
----------
Thread.new do
  loop do
    sleep 0.01
    GC.start
    p "GCed"
  end
end
----------

Then,

$ ruby -rgctest yourapp.rb

You are able to get the segfaults faster.

On Thu, 14 Jun 2007 18:40:46 +0200
Conan Rubymanjaro <ruby-forum-incoming@andreas-s.net> wrote:

> Posted via http://www.ruby-forum.com/.
>
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
This topic is locked and can not be replied to.