Segmentation fault using ruby gtk cairo on windows

Hello All,
I’m writing an ruby Gtk app which uses the new cairo features.

It runs well on linux but crashes after a few redraws when executed on
Windows (segmentation fault).
I noticed that the same happens with the cairo-pong.rb sample
distributed with ruby gtk (you need to wait some minutes of “ponging” to
get the crash.).

I’m not able to tell if this is a problem with GTK or the ruby bindings,
so don’t know where to post it.

Is this a known problem ?

Vincenzo P.


This SF.Net email is sponsored by xPML, a groundbreaking scripting
language
that extends applications into web and mobile media. Attend the live
webcast
and join the prime developer group breaking into this new coding
territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

Hi,

2006/4/7, Vincenzo P. [email protected]:

It runs well on linux but crashes after a few redraws when executed on
Windows (segmentation fault).
I noticed that the same happens with the cairo-pong.rb sample
distributed with ruby gtk (you need to wait some minutes of “ponging” to
get the crash.).

Could you write a small program which reproduces the problem?

Regards,

kou

As I said, cairo-pong.rb (in the ruby gtk samples) is a good way to
reproduce the bug: just let it run for a while.

You can also use the following program, grab the box and move it around,
it takes a while to get the crash (1 minute on my machine).

---- cairobug.rb — BEGIN ----
require ‘gtk2’
require ‘cairo’

class Canvas < Gtk::EventBox
    def initialize
         @bounds = [10, 10,100,100]

        super
        signal_connect('expose-event') { |widget, event|
        cr = widget.window.create_cairo_context
        cr.set_source_rgba(1.0, 1.0, 1.0)
        cr.paint

         cr.rectangle(*@bounds)
        cr.set_source_rgb(0.5,0.0,0.0)
        cr.fill_preserve
        cr.set_source_rgb(0.7,0.7,0.7)
        cr.set_line_join(Cairo::LINE_JOIN_MITER)
        cr.set_line_width(2)
        cr.stroke
        }

  signal_connect("button_press_event") do |widget, event|
    @dragging=pt_in_rect([event.x, event.y], @bounds)
  end


  signal_connect("button_release_event") do |widget, event|
    @dragging=false
  end


    signal_connect("motion_notify_event") do |widget, event|
  if @dragging
         queue_draw_area(@bounds[0] -2, @bounds[1] -2, @bounds[2]+4,

@bounds[3]+4)
@bounds[0] = event.x
@bounds[1] = event.y
queue_draw_area(@bounds[0] -2, @bounds[1] -2, @bounds[2]+4,
@bounds[3]+4)
end
end

end

    def pt_in_rect(pt, rect)
        (0..rect[2]).include?(pt[0]-rect[0]) &&
            (0..rect[3]).include?(pt[1]-rect[1])
    end


end

class MainWindow < Gtk::Window
def initialize
super
set_size_request(600, 400)
@canvas = Canvas.new
add(@canvas)
signal_connect(“destroy”) {
Gtk.main_quit
}
show_all
end
end

def main
Gtk.init
@main_window = MainWindow.new
Gtk.main
end

main
---- cairobug.rb — END -----

Enzo

Kouhei S. ha scritto:


This SF.Net email is sponsored by xPML, a groundbreaking scripting
language
that extends applications into web and mobile media. Attend the live
webcast
and join the prime developer group breaking into this new coding
territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

Hi,

In [email protected]
“Re: [ruby-gnome2-devel-en] segmentation fault using ruby gtk cairo on
windows” on Mon, 10 Apr 2006 18:30:32 +0200,
Vincenzo P. [email protected] wrote:

As I said, cairo-pong.rb (in the ruby gtk samples) is a good way to
reproduce the bug: just let it run for a while.

OK. Can you get back trace? I don’t have Windows environment.

Thanks,

kou


This SF.Net email is sponsored by xPML, a groundbreaking scripting
language
that extends applications into web and mobile media. Attend the live
webcast
and join the prime developer group breaking into this new coding
territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

Hi,

In [email protected]
“Re: [ruby-gnome2-devel-en] segmentation fault using ruby gtk cairo on
windows” on Tue, 11 Apr 2006 22:16:04 +0200,
Vincenzo P. [email protected] wrote:

Here follows the stack trace obtained with windbg.
I found that the crash only happens with ruby184-16_rc1, it works fine
with 184-15.

This problem may be caused by different DLL: MSVCR71.dll
(used by Ruby/GTK2 and GTK+ binary for Windows) and
MSVCRT.dll (used by One-Click Ruby Installer 1.8.4). Could
you check your msvcrt-ruby18.dll?

% objdump -p msvcrt-ruby18.dll | grep MSV

Thanks,

kou


This SF.Net email is sponsored by xPML, a groundbreaking scripting
language
that extends applications into web and mobile media. Attend the live
webcast
and join the prime developer group breaking into this new coding
territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

Here follows the stack trace obtained with windbg.
I found that the crash only happens with ruby184-16_rc1, it works fine
with 184-15.

HEAP[ruby.exe]: Invalid Address specified to RtlFreeHeap( 2ff0000,
36ae488 )
(6bc.6a4): Break instruction exception - code 80000003 (first chance)
eax=036ae480 ebx=036ae480 ecx=0240a018 edx=02409db4 esi=02ff0000
edi=036ae480
eip=7848144b esp=02409f98 ebp=02409f9c iopl=0 nv up ei pl nz na
pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000
efl=00200202
ntdll!DbgBreakPoint:
7848144b cc int 3
0:000> k
ChildEBP RetAddr
WARNING: Stack unwind information not available. Following frames may be
wrong.
02409f9c 78496bcc ntdll!DbgBreakPoint
02409fb0 78495e42 ntdll!RtlpNtEnumerateSubKey+0x4cdf
0240a028 784881a8 ntdll!RtlpNtEnumerateSubKey+0x3f55
0240a0c8 784abd1c ntdll!RtlDestroyHandleTable+0x6c1
*** ERROR: Symbol file could not be found. Defaulted to export symbols
for C:\WINNT\system32\MSVCR71.dll -
0240a16c 7c34218a ntdll!RtlSizeHeap+0x416
*** WARNING: Unable to verify checksum for
c:\ruby\lib\ruby\site_ruby\1.8\i386-msvcrt\glib2.so
*** ERROR: Symbol file could not be found. Defaulted to export symbols
for c:\ruby\lib\ruby\site_ruby\1.8\i386-msvcrt\glib2.so -
0240a1b4 02ee8af6 MSVCR71!free+0x39
*** WARNING: Unable to verify checksum for c:\ruby\bin\msvcrt-ruby18.dll
*** ERROR: Symbol file could not be found. Defaulted to export symbols
for c:\ruby\bin\msvcrt-ruby18.dll -
0240a1c4 100478d8 glib2!rbgobj_boxed_create+0x126
0240a1ec 100473ba msvcrt_ruby18!rb_gc_mark_frame+0xb58
0240a244 10046f65 msvcrt_ruby18!rb_gc_mark_frame+0x63a
0240a2a4 10045f23 msvcrt_ruby18!rb_gc_mark_frame+0x1e5
0240a2b4 100411a9 msvcrt_ruby18!rb_newobj+0x13
0240a2c0 10042f1c msvcrt_ruby18!rb_float_new+0x9
0240a2e0 1000d721 msvcrt_ruby18!Init_Numeric+0x165c
0240a4d8 1000c8e3 msvcrt_ruby18!rb_with_disable_interrupt+0x11a1
0240a518 1000646f msvcrt_ruby18!rb_with_disable_interrupt+0x363
0240ab4c 1000e1fa msvcrt_ruby18!rb_Array+0x22bf
0240ad44 1000c8e3 msvcrt_ruby18!rb_with_disable_interrupt+0x1c7a
0240ad84 100068b0 msvcrt_ruby18!rb_with_disable_interrupt+0x363
0240b3b4 1000620c msvcrt_ruby18!rb_Array+0x2700
0240b9d8 100059b0 msvcrt_ruby18!rb_Array+0x205c

Thanks

Enzo

Kouhei S. ha scritto:

OK. Can you get back trace? I don’t have Windows environment.

Thanks,

kou


This SF.Net email is sponsored by xPML, a groundbreaking scripting
language
that extends applications into web and mobile media. Attend the live
webcast
and join the prime developer group breaking into this new coding
territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642