# FXRuby Segmentation fault

**URL:** <https://www.ruby-forum.com/t/fxruby-segmentation-fault/122538>\
**Category:** Ruby\
**Created:** [December 9, 2007, 1:56am UTC](https://www.ruby-forum.com/t/fxruby-segmentation-fault/122538 "2007-12-09T01:56:00Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ernsttanaka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/46a35a/32.png) [@ernsttanaka](https://www.ruby-forum.com/u/ernsttanaka)\
**Post date:** [December 9, 2007, 1:56am UTC](https://www.ruby-forum.com/t/fxruby-segmentation-fault/122538/1 "2007-12-09T01:56:00Z")

</div>

I am getting this error.  
I see on the forum more people had the error, but I can’t find a  
solution.

The error occurs in debug mode (via Netbeans) but also from the command  
line (debug or not)

[BUG] Segmentation fault  
ruby 1.8.6. \<2007-03-13\> [i386-mswin32]

The error points to this ruby line.

C:/ruby/lib/ruby/gems/1.8/gems/fxruby-1.6.13-mswin32/lib/fox16/kwargs.rb:1689:  
[BUG] Segmentation fault  
ruby 1.8.6 (2007-03-13) [i386-mswin32]

---

<div class="post-metadata">

**Author:** ![ernsttanaka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/46a35a/32.png) [@ernsttanaka](https://www.ruby-forum.com/u/ernsttanaka)\
**Post date:** [December 9, 2007, 3:57pm UTC](https://www.ruby-forum.com/t/fxruby-segmentation-fault/122538/2 "2007-12-09T15:57:10Z")

</div>

In addition to the above post;

I am on a windows/xp system.  
I downloaded all the lastest version of the gems.

The error message I get is;

[BUG] Segmentation fault  
ruby 1.8.6. \<2007-03-13\> [i386-mswin32]

It seems to be in calls to FXRuby.

I can do with some help;

- how can i debug errors like this?
- how can I get better error messages when using FXRuby

Searching for this error I found several posts, but none holds a  
solution.

Thanks for your help,

Ernst

---

<div class="post-metadata">

**Author:** ![ernsttanaka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/46a35a/32.png) [@ernsttanaka](https://www.ruby-forum.com/u/ernsttanaka)\
**Post date:** [December 9, 2007, 4:12pm UTC](https://www.ruby-forum.com/t/fxruby-segmentation-fault/122538/3 "2007-12-09T16:12:40Z")

</div>

-------- Original-Nachricht --------

> Datum: Sun, 9 Dec 2007 23:57:10 +0900  
> Von: Ernst T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> An: removed\_email\_address@domain.invalid  
> Betreff: Re: FXRuby Segmentation fault

> It seems to be in calls to FXRuby.  
> Thanks for your help,
> 
> Ernst
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

Dear Ernst,

I am not an FXRuby expert either, but most of my segmentation fault  
errors (and all those I could reproduce) were produced when I tried to  
use something from inside of  
something else where the “something else” wasn’t yet defined  
(as Ruby allows you to create things on the fly which Fox and thus  
C doesn’t without previous declaration).

So to test whether there is really something wrong with your  
installation,  
I’d try to run the test scripts that come with the FXRuby installation.

If you are not getting any errors there (save for non-installed  
dependencies), maybe you post (a simplified / shortened version of) your  
code to the FXRuby list. There is also a GUI builder for FXRuby from  
here:

[http://fox-tool.rubyforge.org](http://fox-tool.rubyforge.org) .

Best regards,

Axel

---

<div class="post-metadata">

**Author:** ![ernsttanaka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/46a35a/32.png) [@ernsttanaka](https://www.ruby-forum.com/u/ernsttanaka)\
**Post date:** [December 10, 2007, 3:04am UTC](https://www.ruby-forum.com/t/fxruby-segmentation-fault/122538/4 "2007-12-10T03:04:24Z")

</div>

Ernst T. wrote:

> I have proof that the error reproduces itself on a non-consistent  
> bases.
> 
> - One time program runs perfectly.
> - make non essential change; like I add a line x = " "
> - next time program does not run and gives the above mentioned errors.
> - remove of line --\> still errors

Symptoms like this sometimes mean there is a memory management problem  
(possibly somewhere in fxruby). It might mean that an object is being  
freed even though there is a reference to it. Try doing this somewhere  
early in your program:

GC.disable

If you do that, the program will consume increasing amounts of memory,  
so it is not a solution to the problem. But if the crash does not  
happen, then that probably indicates a memory management bug of some  
kind.

The source of the problem may be hard to find. You can insert GC.start  
after creating objects (remove the GC.disable first). This may help  
determine which allocation is the culprit. (Someone suggested a ruby  
option to tell GC to collect frequently, which would help, but AFAIK  
this doesn’t exist yet.)

Also, you can try to cut your program down to the smallest example in  
which the bug still happens.

---

<div class="post-metadata">

**Author:** ![ernsttanaka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/46a35a/32.png) [@ernsttanaka](https://www.ruby-forum.com/u/ernsttanaka)\
**Post date:** [December 10, 2007, 2:34am UTC](https://www.ruby-forum.com/t/fxruby-segmentation-fault/122538/5 "2007-12-10T02:34:17Z")

</div>

Thanks Axel for your reply.

Still working on the errors.

I am also getting;

This application has requested the Runtime to terminate it in an unusual  
way.  
Please contact the application’s support team for more information.

> Exit code: -1073741819

I have proof that the error reproduces itself on a non-consistent  
bases.

- One time program runs perfectly.
- make non essential change; like I add a line x = " "
- next time program does not run and gives the above mentioned errors.
- remove of line --\> still errors

---

<div class="post-metadata">

**Author:** ![ernsttanaka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/46a35a/32.png) [@ernsttanaka](https://www.ruby-forum.com/u/ernsttanaka)\
**Post date:** [December 10, 2007, 2:47pm UTC](https://www.ruby-forum.com/t/fxruby-segmentation-fault/122538/6 "2007-12-10T14:47:08Z")

</div>

Joel VanderWerf wrote:

> GC.disable

Thanks Joel (dankjewel)

I tried GC.disable and GC.enable and GC.start  
No difference; sometimes the program runs, sometimes not.

Debuging and minimizing the program by placing comments is giving  
non-consistent results. It seems not to be a specific line in my code  
which causes the error.

I am working with the lasted Gems, tried to execute the program from the  
command line and from Netbeans and Scite. no difference. all the same  
none-consistent results.

This is a tough one.

Ernst

---

<div class="post-metadata">

**Author:** ![ernsttanaka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/46a35a/32.png) [@ernsttanaka](https://www.ruby-forum.com/u/ernsttanaka)\
**Post date:** [December 10, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/fxruby-segmentation-fault/122538/7 "2007-12-10T16:31:44Z")

</div>

Found another little clue

@bs\_tab = [“Buy”, “Sell”]  
@bs = -1  
unless @horizontalframe41  
FX::HorizontalFrame.new(@horizontalframe4){|w|  
@horizontalframe41=w  
w.wdg\_name=‘horizontalframe41’  
w.backColor=Fox::FXRGBA(0,0,0,255)}  
FX::ComboBox.new(@horizontalframe41){|w|  
@w\_bs=w  
w.wdg\_name=‘w\_bs’  
w.fillItems(@bs\_tab)  
w.backColor=Fox::FXRGBA(0,0,0,255)  
w.textColor=Fox::FXRGBA(0,255,0,255)}  
@horizontalframe41.create  
end  
@w\_bs.currentItem = 0 if @bs == 1  
@w\_bs.currentItem = 1 if @bs == -1

It seems that the "w.fillItems(@bs\_tab) is the cause of many of my  
errors.

"This application has requested the Runtime to terminate it in an  
unusual  
way.  
Please contact the application’s support team for more information.

> Exit code: -1073741819"

---

<div class="post-metadata">

**Author:** ![ernsttanaka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/46a35a/32.png) [@ernsttanaka](https://www.ruby-forum.com/u/ernsttanaka)\
**Post date:** [December 10, 2007, 5:15pm UTC](https://www.ruby-forum.com/t/fxruby-segmentation-fault/122538/8 "2007-12-10T17:15:00Z")

</div>

On Dec 10, 2007 9:32 AM, Ernst T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> @w_bs=w
> 
> ```
> 
> errors.  
> What is @bs\_tab? It should be an array of strings. See what happens if  
> you replace the line:

```
w.fillItems(@bs_tab)

```

with this:

```
@bs_tab.each { |s| w.appendItem(s) }

```

Hope this helps,

Lyle

---

<div class="post-metadata">

**Author:** ![ernsttanaka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/46a35a/32.png) [@ernsttanaka](https://www.ruby-forum.com/u/ernsttanaka)\
**Post date:** [December 10, 2007, 7:34pm UTC](https://www.ruby-forum.com/t/fxruby-segmentation-fault/122538/9 "2007-12-10T19:34:47Z")

</div>

Lyle J. wrote:

> What is @bs\_tab? It should be an array of strings. See what happens if  
> you replace the line:
> 
> ```
> w.fillItems(@bs_tab)
> 
> ```

@bs\_tab is an array filled with two elements. [“Buy”, “Sell”]

Your suggestion make a world of difference.  
It seems that the fillItems is not as robust as it could be.

appendItem is doing the trick.

Thanks,  
Ernst

P.s. I am need for your book, spending to much time puzzling.
