# Segmentation fault using ruby gtk cairo on windows

**URL:** <https://www.ruby-forum.com/t/segmentation-fault-using-ruby-gtk-cairo-on-windows/57039>\
**Category:** Ruby-Gnome 2\
**Created:** [April 6, 2006, 7:28pm UTC](https://www.ruby-forum.com/t/segmentation-fault-using-ruby-gtk-cairo-on-windows/57039 "2006-04-06T19:28:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vincenzo\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e274bd/32.png) [@Vincenzo\_P](https://www.ruby-forum.com/u/Vincenzo_P)\
**Post date:** [April 6, 2006, 7:28pm UTC](https://www.ruby-forum.com/t/segmentation-fault-using-ruby-gtk-cairo-on-windows/57039/1 "2006-04-06T19:28:03Z")

</div>

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](http://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](http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642)

---

<div class="post-metadata">

**Author:** ![Vincenzo\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e274bd/32.png) [@Vincenzo\_P](https://www.ruby-forum.com/u/Vincenzo_P)\
**Post date:** [April 7, 2006, 4:19am UTC](https://www.ruby-forum.com/t/segmentation-fault-using-ruby-gtk-cairo-on-windows/57039/2 "2006-04-07T04:19:00Z")

</div>

Hi,

2006/4/7, Vincenzo P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> 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

---

<div class="post-metadata">

**Author:** ![Vincenzo\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e274bd/32.png) [@Vincenzo\_P](https://www.ruby-forum.com/u/Vincenzo_P)\
**Post date:** [April 10, 2006, 6:34pm UTC](https://www.ruby-forum.com/t/segmentation-fault-using-ruby-gtk-cairo-on-windows/57039/3 "2006-04-10T18:34:03Z")

</div>

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](http://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](http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642)

---

<div class="post-metadata">

**Author:** ![Vincenzo\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e274bd/32.png) [@Vincenzo\_P](https://www.ruby-forum.com/u/Vincenzo_P)\
**Post date:** [April 11, 2006, 2:01am UTC](https://www.ruby-forum.com/t/segmentation-fault-using-ruby-gtk-cairo-on-windows/57039/4 "2006-04-11T02:01:31Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] segmentation fault using ruby gtk cairo on  
windows” on Mon, 10 Apr 2006 18:30:32 +0200,  
Vincenzo P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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](http://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](http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642)

---

<div class="post-metadata">

**Author:** ![Vincenzo\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e274bd/32.png) [@Vincenzo\_P](https://www.ruby-forum.com/u/Vincenzo_P)\
**Post date:** [April 12, 2006, 3:49pm UTC](https://www.ruby-forum.com/t/segmentation-fault-using-ruby-gtk-cairo-on-windows/57039/5 "2006-04-12T15:49:02Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] segmentation fault using ruby gtk cairo on  
windows” on Tue, 11 Apr 2006 22:16:04 +0200,  
Vincenzo P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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](http://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](http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642)

---

<div class="post-metadata">

**Author:** ![Vincenzo\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e274bd/32.png) [@Vincenzo\_P](https://www.ruby-forum.com/u/Vincenzo_P)\
**Post date:** [April 11, 2006, 10:20pm UTC](https://www.ruby-forum.com/t/segmentation-fault-using-ruby-gtk-cairo-on-windows/57039/6 "2006-04-11T22:20:04Z")

</div>

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](http://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](http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642)
