List Info

Thread: Re: A bug in wxRuby. Segmentation fault in random situations.




Re: A bug in wxRuby. Segmentation fault in random situations.
user name
2008-02-28 12:07:56
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
jacekwiktorgmail.com
_______________________________________________
wxruby-users mailing list
wxruby-usersrubyforge.org
ht
tp://rubyforge.org/mailman/listinfo/wxruby-users

Re: A bug in wxRuby. Segmentation fault in random situations.
country flaguser name
United Kingdom
2008-02-29 20:09:51
Hi Jacek

Thanks for posting more details. I've just fixed a bug in
SVN which fits 
with the code and symptom you supplied. I tested your code
on OS X and 
it now doesn't crash after the MDI child is closed with
HEAD, though I 
can reproduce the crash with the 1.9.4 rubygem.

So I am hopeful that this will be resolved by the next
release which 
should be soon, but if you are able please test with the
latest source 
from SVN.

Jacek Nowak wrote:
> I have a lot of trouble trying to find out what exactly
causes the bug.
>
>   
So did I ... this bug has been vexing me for more than a
month and was a 
git to track down.
> 1. First I removed all calls of method
"destroy" in dialogs.
Definitely stick with this.
> But still it crashes from time to time.
>   
The trigger was the destruction of a Frame or Dialog
containing a Sizer; 
after this it would crash on the next GC run. So it would
seem sporadic, 
in the pattern you gave.

cheers
alex


_______________________________________________
wxruby-users mailing list
wxruby-usersrubyforge.org
ht
tp://rubyforge.org/mailman/listinfo/wxruby-users

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )