[wxruby-users] A bug in wxRuby. Segmentation fault in random situations.
Jacek Nowak
jacekwiktor at gmail.com
Thu Feb 28 13:07:56 EST 2008
Hi,
I have a lot of trouble trying to find out what exactly causes the bug.
Generally it seems that the more code I remove from my application,
the more rarely the crash happens.
What I did:
1. First I removed all calls of method "destroy" in dialogs.
Normally my code for displaying dialogs was everywhere like that:
d = SomeDialog.new(self,-1,"title",some_arguments)
d.show_modal
d.destroy
I removed all calls to "destroy" and it _seems_ that now my
application crashes less often (at least it doesn't crash in the place
where it always crashed before). But still it crashes from time to
time.
2. I managed to create a small chunk of code which always crashes just
after closing of MDIChildFrame but it crashes only when gc_stress is
set to 1ms or something near that.
If I set it to 1s or more I'm not able to trigger the crash so I don't
know if this is the issue of GC called too often or the problem with
the code.
I am sending you the code below:
# ============== BEGIN OF CODE:
#!/usr/bin/env ruby
require 'rubygems'
require 'wx'
include Wx
class KatalogTowarowFrame < Wx::MDIChildFrame
def initialize(parent,id,title)
super(parent,id,title)
button1 = Button.new(self,-1,"aaaa")
button2 = Button.new(self,-1,"bbbb")
sizer1 = BoxSizer.new(HORIZONTAL)
sizer1.add(button1,1,GROW,2)
sizer1.add(button2,1,GROW,2)
set_sizer(sizer1)
end
end
class MainFrame < Wx::MDIParentFrame
def initialize
super(nil, -1, "Application that crashes", DEFAULT_POSITION,
Wx::Size.new(800,600),
DEFAULT_FRAME_STYLE | VSCROLL | HSCROLL | FRAME_NO_WINDOW_MENU)
menu1 = Menu.new
menu1.append(5000, "test test","test test")
menubar = MenuBar.new()
menubar.append(menu1,"fdlgfdgfdgddffgd")
set_menu_bar(menubar)
create_status_bar
evt_menu(5000) {|event| on_a(event)}
end
def on_a(event)
win = KatalogTowarowFrame.new(self,-1,"Kartoteka towarow")
win.show
win.set_focus
end
end
class Aplikacja < Wx::App
def on_init
gc_stress
mainframe = MainFrame.new
mainframe.set_title("abc")
mainframe.show()
end
end
Aplikacja.new.main_loop
# ============== END OF CODE
--
Jacek Nowak
jacekwiktor at gmail.com
More information about the wxruby-users
mailing list