# Segmentation Fault : \[i386-mswin32\] in wxruby

**URL:** <https://www.ruby-forum.com/t/segmentation-fault-i386-mswin32-in-wxruby/157568>\
**Category:** wxRuby\
**Created:** [January 13, 2009, 8:39am UTC](https://www.ruby-forum.com/t/segmentation-fault-i386-mswin32-in-wxruby/157568 "2009-01-13T08:39:35Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![lcyeap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9fc348/32.png) [@lcyeap](https://www.ruby-forum.com/u/lcyeap)\
**Post date:** [January 13, 2009, 8:39am UTC](https://www.ruby-forum.com/t/segmentation-fault-i386-mswin32-in-wxruby/157568/1 "2009-01-13T08:39:35Z")

</div>

Greetings,

I have created a GUI to generate a output text file using wxruby. my  
program codes are about ~1400 lines.  
ruby : 1.8.6  
wxruby : 1.9.7  
rails : 2.1.0

FYI, I am using the TextCtrl & combobox in the main GUI to get the  
output file name and main settings. after clicking the button, it will  
pop up another frame which let user to select and modified settings with  
TextCtrl & combobox. By clicking the button on the new GUI, an output  
file will be generated.

But problem occurred if i want to generate multiple files. When i enter  
the new name in the TextCtrl for creating new file, the GUI will close  
immediately with this error pop up – \> “Bug:Segmentation Fault”

May i know is there any reference for me or suggestion to fix this  
problem?

Your help will be highly appreciated. =)

---

<div class="post-metadata">

**Author:** ![lcyeap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9fc348/32.png) [@lcyeap](https://www.ruby-forum.com/u/lcyeap)\
**Post date:** [January 13, 2009, 8:56am UTC](https://www.ruby-forum.com/t/segmentation-fault-i386-mswin32-in-wxruby/157568/2 "2009-01-13T08:56:10Z")

</div>

Well, there’s two things here.

First, your using 1.9.7 of Ruby, please upgrade to 1.9.9, and test  
again,  
before moving on to this second part, there have been many bug fixes  
between  
1.9.7 and 1.9.9.

Second, and do this only after you tried the first part, if the problem  
still occurs, please send us a Minimal example, that can reproduce the  
problem that your having, so that we can test it, and see what exactly  
is  
going on.

hth,  
Mario

---

<div class="post-metadata">

**Author:** ![lcyeap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9fc348/32.png) [@lcyeap](https://www.ruby-forum.com/u/lcyeap)\
**Post date:** [January 13, 2009, 9:23am UTC](https://www.ruby-forum.com/t/segmentation-fault-i386-mswin32-in-wxruby/157568/3 "2009-01-13T09:23:13Z")

</div>

By 1.9.7 of Ruby, I mean 1.9.7 of wxRuby, not Ruby itself.

---

<div class="post-metadata">

**Author:** ![lcyeap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9fc348/32.png) [@lcyeap](https://www.ruby-forum.com/u/lcyeap)\
**Post date:** [January 13, 2009, 10:15am UTC](https://www.ruby-forum.com/t/segmentation-fault-i386-mswin32-in-wxruby/157568/4 "2009-01-13T10:15:29Z")

</div>

Lc Yeap wrote:

> However, when I run my program again, the same error occurred. →   
> “config\_vector\_v6.rb:1418: [BUG] Segmentation fault  
> ruby 1.8.6 (2007-09-24) [i386-mswin32]”

You can check what version of wxRuby is being used by your program by  
looking at the value of Wx::WXRUBY\_VERSION. It’s printed out in the  
“About” box of the minimal sample.

> so I deleted the previous gem “wxruby-1.9.7-i386-mswin32.gem” from the  
> bin folder and reinstalled it again, but still the same error being  
> reported.

Use gem uninstall, don’t delete directly.

> I tried with command “gem update wxruby” but I get this–\>"ERROR: While  
> executing gem … (Gem::RemoteFetcher::FetchError)  
> No connection could be made because the target machine actively  
> refused it.
> 
> - connect(2)(Errno::ECONNREFUSED)"

Make sure that you have the latest versions of rubygems installed then  
try installing wxruby-1.9.9 again.

gem --update system

> Is that I am not using the correct version of wxruby? can you point me  
> how to upgrade my wxruby? If this still fail again after using wxruby  
> 1.9.9, I will attach a sample code of my program.

OK. It might be worth posting a runnable sample of your code anyway.  
There may be something in there obvious that’s not quite right -  
although wxRuby tries to raise an exception on incorrect use of the API,  
this isn’t always possible. Or if there is a bug, it may still exist in  
the latest development version, in which case sample code will help us  
find it quicker.

a

---

<div class="post-metadata">

**Author:** ![lcyeap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9fc348/32.png) [@lcyeap](https://www.ruby-forum.com/u/lcyeap)\
**Post date:** [January 13, 2009, 9:28am UTC](https://www.ruby-forum.com/t/segmentation-fault-i386-mswin32-in-wxruby/157568/5 "2009-01-13T09:28:46Z")

</div>

Mario S. wrote:

> Well, there’s two things here.
> 
> First, your using 1.9.7 of Ruby, please upgrade to 1.9.9, and test  
> again,  
> before moving on to this second part, there have been many bug fixes  
> between  
> 1.9.7 and 1.9.9.
> 
> Second, and do this only after you tried the first part, if the problem  
> still occurs, please send us a Minimal example, that can reproduce the  
> problem that your having, so that we can test it, and see what exactly  
> is  
> going on.
> 
> hth,  
> Mario

Hi Mario,

thanks for the prompt response.  
I downloaded the “wxruby-1.9.9-x86-mswin32-60.gem” from RubyForge.  
by typing command ‘gem install wxruby’, system reported that it has  
successfully installed wxruby with version 1.9.9.  
However, when I run my program again, the same error occurred. →   
“config\_vector\_v6.rb:1418: [BUG] Segmentation fault  
ruby 1.8.6 (2007-09-24) [i386-mswin32]”

so I deleted the previous gem “wxruby-1.9.7-i386-mswin32.gem” from the  
bin folder and reinstalled it again, but still the same error being  
reported.  
I tried with command “gem update wxruby” but I get this–\>"ERROR: While  
executing gem … (Gem::RemoteFetcher::FetchError)  
No connection could be made because the target machine actively  
refused it.

- connect(2)(Errno::ECONNREFUSED)"

Is that I am not using the correct version of wxruby? can you point me  
how to upgrade my wxruby? If this still fail again after using wxruby  
1.9.9, I will attach a sample code of my program.

Thanks again. =)

---

<div class="post-metadata">

**Author:** ![lcyeap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9fc348/32.png) [@lcyeap](https://www.ruby-forum.com/u/lcyeap)\
**Post date:** [January 13, 2009, 12:32pm UTC](https://www.ruby-forum.com/t/segmentation-fault-i386-mswin32-in-wxruby/157568/6 "2009-01-13T12:32:19Z")

</div>

Lc, you definitely need to simplify your example. Try to make it as  
small as  
possible. You need the MINIMUM example which reproduces the error. Sad  
to  
say that, but nobody will look through that amount of code you’ve given.

2009/1/13 Lc Yeap [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![lcyeap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9fc348/32.png) [@lcyeap](https://www.ruby-forum.com/u/lcyeap)\
**Post date:** [January 13, 2009, 12:09pm UTC](https://www.ruby-forum.com/t/segmentation-fault-i386-mswin32-in-wxruby/157568/7 "2009-01-13T12:09:49Z")

</div>

Alex F. wrote:

> Lc Yeap wrote:
> 
> > However, when I run my program again, the same error occurred. →   
> > “config\_vector\_v6.rb:1418: [BUG] Segmentation fault  
> > ruby 1.8.6 (2007-09-24) [i386-mswin32]”
> 
> You can check what version of wxRuby is being used by your program by  
> looking at the value of Wx::WXRUBY\_VERSION. It’s printed out in the  
> “About” box of the minimal sample.
> 
> > so I deleted the previous gem “wxruby-1.9.7-i386-mswin32.gem” from the  
> > bin folder and reinstalled it again, but still the same error being  
> > reported.
> 
> Use gem uninstall, don’t delete directly.
> 
> > I tried with command “gem update wxruby” but I get this–\>"ERROR: While  
> > executing gem … (Gem::RemoteFetcher::FetchError)  
> > No connection could be made because the target machine actively  
> > refused it.
> > 
> > - connect(2)(Errno::ECONNREFUSED)"
> 
> Make sure that you have the latest versions of rubygems installed then  
> try installing wxruby-1.9.9 again.
> 
> gem --update system
> 
> > Is that I am not using the correct version of wxruby? can you point me  
> > how to upgrade my wxruby? If this still fail again after using wxruby  
> > 1.9.9, I will attach a sample code of my program.
> 
> OK. It might be worth posting a runnable sample of your code anyway.  
> There may be something in there obvious that’s not quite right -  
> although wxRuby tries to raise an exception on incorrect use of the API,  
> this isn’t always possible. Or if there is a bug, it may still exist in  
> the latest development version, in which case sample code will help us  
> find it quicker.
> 
> a

Hi Alex,

thanks for your reply. after follow your instructions, I have been  
confirmed the version of wxruby that i used is correct, which is 1.9.9.  
But, still the same error observed.

Attached is my sample code. The error pop up when i try to generate the  
2nd file.

Hope will find out the cause of the error soon as i need this  
application to be up.

Thanks a lot. =)

---

<div class="post-metadata">

**Author:** ![lcyeap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9fc348/32.png) [@lcyeap](https://www.ruby-forum.com/u/lcyeap)\
**Post date:** [January 13, 2009, 1:00pm UTC](https://www.ruby-forum.com/t/segmentation-fault-i386-mswin32-in-wxruby/157568/8 "2009-01-13T13:00:22Z")

</div>

Lc Yeap wrote

> thanks for your reply. after follow your instructions, I have been  
> confirmed the version of wxruby that i used is correct, which is 1.9.9.  
> But, still the same error observed.
> 
> Attached is my sample code. The error pop up when i try to generate the  
> 2nd file.

I can reproduce the error with mswin32 1.9.9, but not with MingW on  
Windows (either 1.9.9 or the latest development version). If someone has  
a build of SVN HEAD build of mswin32 handy, perhaps they could give it a  
go to see if it’s resolved.

As Kiril’s said, it’d be easier and quicker to help further if you could  
simplify this down a lot, to narrow down the source of the error. For  
example, I started by removing the text writing routine, then the  
confirmation dialog. Next step might be to remove all the controls  
except the ‘generate’ button.

I don’t have time to keep tweaking and running and clicking through your  
whole app right now, but if you provide a stripped-down sample  
demonstrating the issue, I’m happy to work with that.

alex

---

<div class="post-metadata">

**Author:** ![lcyeap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9fc348/32.png) [@lcyeap](https://www.ruby-forum.com/u/lcyeap)\
**Post date:** [January 15, 2009, 2:44pm UTC](https://www.ruby-forum.com/t/segmentation-fault-i386-mswin32-in-wxruby/157568/9 "2009-01-15T14:44:52Z")

</div>

had this problem on some database calls with Windows XP today too…

Ruby 1.8.6  
WxRuby 1.9.9  
Windows Service Pack 2

What I had to do was fire the Garbage Collector before my mySQL calls

GC.start  
res.each do |row|  
…  
end

And then call the rows specifically by number =\> row[1].to\_s

I was using row[“name”] with res.each changed to res.each\_hash, but it  
just kept flipping out with Segmentation Faults so i switched to the  
more simpler method above.

After which it remained stable.

Also got problems with NET::SFTP returning Segmentation Faults for  
Upload() calls, Ok with Connect() or Dir.foreach calls, but swapped that  
out with Putty’s SCP for quickness.

---

<div class="post-metadata">

**Author:** ![lcyeap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9fc348/32.png) [@lcyeap](https://www.ruby-forum.com/u/lcyeap)\
**Post date:** [January 14, 2009, 1:44am UTC](https://www.ruby-forum.com/t/segmentation-fault-i386-mswin32-in-wxruby/157568/10 "2009-01-14T01:44:37Z")

</div>

Alex F. wrote:

> Lc Yeap wrote
> 
> > thanks for your reply. after follow your instructions, I have been  
> > confirmed the version of wxruby that i used is correct, which is 1.9.9.  
> > But, still the same error observed.
> > 
> > Attached is my sample code. The error pop up when i try to generate the  
> > 2nd file.
> 
> I can reproduce the error with mswin32 1.9.9, but not with MingW on  
> Windows (either 1.9.9 or the latest development version). If someone has  
> a build of SVN HEAD build of mswin32 handy, perhaps they could give it a  
> go to see if it’s resolved.
> 
> As Kiril’s said, it’d be easier and quicker to help further if you could  
> simplify this down a lot, to narrow down the source of the error. For  
> example, I started by removing the text writing routine, then the  
> confirmation dialog. Next step might be to remove all the controls  
> except the ‘generate’ button.
> 
> I don’t have time to keep tweaking and running and clicking through your  
> whole app right now, but if you provide a stripped-down sample  
> demonstrating the issue, I’m happy to work with that.
> 
> alex

Hi Kiril & Alex,

Thanks for the advice and helps.  
I will try to simplified my code following the guidelines provided.  
sorry for not being clear at the beginning. Meanwhile, i will continue  
with my debugging works. Will keep on update if I have any finding.

Thanks again. =)
