# Segmentation fault from mysql\_adapter.rb

**URL:** <https://www.ruby-forum.com/t/segmentation-fault-from-mysql-adapter-rb/163321>\
**Category:** Rails\
**Created:** [March 19, 2009, 8:27am UTC](https://www.ruby-forum.com/t/segmentation-fault-from-mysql-adapter-rb/163321 "2009-03-19T08:27:24Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![divyamohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@divyamohan](https://www.ruby-forum.com/u/divyamohan)\
**Post date:** [March 19, 2009, 8:27am UTC](https://www.ruby-forum.com/t/segmentation-fault-from-mysql-adapter-rb/163321/1 "2009-03-19T08:27:24Z")

</div>

Hello, I’m a rails newbie.

## I wrote a simple application to navigate between 2 pages. This is my controller file

class SayController \< ApplicationController

def hello  
end

def gudbye  
end

## end

I have 2 rhtml files in views/say folder hello.rhtml & gudbye.rhtml

hello.rhtml contains a line \<%= link\_to “Logout”, :action =\> “gudbye”  
%\>

Similarly, gudbye.rhtml contains \<%= link\_to “Go Back”, :action=\>  
“hello” %\>

## Then,

## demo\>ruby script/server =\> Booting Mongrel =\> Rails 2.3.2 application starting on [http://0.0.0.0:3000](http://0.0.0.0:3000) =\> Call with -d to detach =\> Ctrl-C to shutdown server

This much is working fine.  
When I go to [http://localhost:3000/say/hello](http://localhost:3000/say/hello) in browser, my hello page  
is getting displayed.

## The problem is that at random times, I get a segmentation fault, when I click the link (to either hello or gudbye page)

c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/ lib/ active\_record/  
connection\_adapters/ mysql\_adapter.rb:202: [BUG] Segmentation fault  
ruby 1.8.6 (2007-09-24) [i386-mswin32]

This application has requested the Runtime to terminate it in an  
unusual way.

Please contact the application’s support team for more information.

## demo\>

This happens only at random times, sometimes the two links work fine,  
sometimes it do not.

Can some one please help me.

---

<div class="post-metadata">

**Author:** ![divyamohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@divyamohan](https://www.ruby-forum.com/u/divyamohan)\
**Post date:** [March 30, 2009, 11:17am UTC](https://www.ruby-forum.com/t/segmentation-fault-from-mysql-adapter-rb/163321/2 "2009-03-30T11:17:54Z")

</div>

I’m getting this error message as well every morning when I’m back at  
work. I suppose monit could be of help here if I wasn’t running in a  
Windows environment.

/Nicklas

Divya M. wrote:

> ## The problem is that at random times, I get a segmentation fault, when I click the link (to either hello or gudbye page)
> 
> c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/ lib/ active\_record/  
> connection\_adapters/ mysql\_adapter.rb:202: [BUG] Segmentation fault  
> ruby 1.8.6 (2007-09-24) [i386-mswin32]
> 
> This application has requested the Runtime to terminate it in an  
> unusual way.
> 
> Please contact the application’s support team for more information.
> 
> ## demo\>
> 
> This happens only at random times, sometimes the two links work fine,  
> sometimes it do not.
> 
> Can some one please help me.

---

<div class="post-metadata">

**Author:** ![divyamohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@divyamohan](https://www.ruby-forum.com/u/divyamohan)\
**Post date:** [April 16, 2009, 8:29pm UTC](https://www.ruby-forum.com/t/segmentation-fault-from-mysql-adapter-rb/163321/3 "2009-04-16T20:29:36Z")

</div>

Solved in any way!? I got the same problem…

On Mar 30, 11:17 am, Nicklas H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![divyamohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@divyamohan](https://www.ruby-forum.com/u/divyamohan)\
**Post date:** [April 17, 2009, 11:23am UTC](https://www.ruby-forum.com/t/segmentation-fault-from-mysql-adapter-rb/163321/4 "2009-04-17T11:23:31Z")

</div>

Do you guys think that is a webserver problem? I mean switching from  
webrick to something else … would I solve it?

On Apr 17, 10:00 am, Divya M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![divyamohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@divyamohan](https://www.ruby-forum.com/u/divyamohan)\
**Post date:** [April 17, 2009, 10:00am UTC](https://www.ruby-forum.com/t/segmentation-fault-from-mysql-adapter-rb/163321/5 "2009-04-17T10:00:44Z")

</div>

Not yet solved. ☹

---

<div class="post-metadata">

**Author:** ![divyamohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@divyamohan](https://www.ruby-forum.com/u/divyamohan)\
**Post date:** [April 20, 2009, 4:36pm UTC](https://www.ruby-forum.com/t/segmentation-fault-from-mysql-adapter-rb/163321/6 "2009-04-20T16:36:58Z")

</div>

adedip wrote:

> Do you guys think that is a webserver problem? I mean switching from  
> webrick to something else .. would I solve it?
> 
> On Apr 17, 10:00ï¿½am, Divya M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

I am using Mongrel, so switching to that won’t help. This is totaly  
driving me crazy.

---

<div class="post-metadata">

**Author:** ![divyamohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@divyamohan](https://www.ruby-forum.com/u/divyamohan)\
**Post date:** [April 20, 2009, 11:09pm UTC](https://www.ruby-forum.com/t/segmentation-fault-from-mysql-adapter-rb/163321/7 "2009-04-20T23:09:15Z")

</div>

Im having the same problem too, im getting it on that tutorial for  
creating your own blog, when I try and submit the form the ruby server  
crashes and I get the same error.

MYSQL Problem?

On Apr 20, 10:36 am, Nicklas H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![divyamohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@divyamohan](https://www.ruby-forum.com/u/divyamohan)\
**Post date:** [April 21, 2009, 4:43pm UTC](https://www.ruby-forum.com/t/segmentation-fault-from-mysql-adapter-rb/163321/8 "2009-04-21T16:43:26Z")

</div>

There is really easy way to test if it’s a time out issue. Simply  
create a action in your controller that queries the database.  
Something as simple as User.find(:first). Setup a cron on either your  
server or local maching to call that method (ie curl [mystite.com/](http://mystite.com/)  
active ) once a minute or whatever your connection timeout is set in  
mysql. Wake up tomorrow, if you see an error.

Other stuff to look into:  
Double check that mysql gem is installed.  
Check your mysql timeout:

> **[Issociate-Groups](https://board.issociate.de/)**
>
> News and discussions. Nachrichten und Diskussionen.

Really version 2+ of rails shouldn’t really have this problem

On Apr 21, 2:19 am, Nicklas H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![divyamohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@divyamohan](https://www.ruby-forum.com/u/divyamohan)\
**Post date:** [April 21, 2009, 8:19am UTC](https://www.ruby-forum.com/t/segmentation-fault-from-mysql-adapter-rb/163321/9 "2009-04-21T08:19:19Z")

</div>

Drew wrote:

> Im having the same problem too, im getting it on that tutorial for  
> creating your own blog, when I try and submit the form the ruby server  
> crashes and I get the same error.
> 
> MYSQL Problem?
> 
> On Apr 20, 10:36ï¿½am, Nicklas H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Could it be some kind of timeout between MySQL and web server?

---

<div class="post-metadata">

**Author:** ![divyamohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@divyamohan](https://www.ruby-forum.com/u/divyamohan)\
**Post date:** [May 4, 2009, 6:16pm UTC](https://www.ruby-forum.com/t/segmentation-fault-from-mysql-adapter-rb/163321/10 "2009-05-04T18:16:46Z")

</div>

Divya M. wrote:

> c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/ lib/ active\_record/  
> connection\_adapters/ mysql\_adapter.rb:202: [BUG] Segmentation fault  
> ruby 1.8.6 (2007-09-24) [i386-mswin32]
> 
> This application has requested the Runtime to terminate it in an  
> unusual way.
> 
> Please contact the application’s support team for more information.
> 
> demo\>

I am getting this same problem. I am getting it after setting up a new  
dev environment on a windows machine. I first saw it in RubyMine (IDE),  
when I went to the Tools-\>Rake Tasks-\>db-\>create-\>all command. I got  
this as the output:

C:\Ruby\bin\ruby.exe -e  
STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift) C:\Ruby\bin/rake  
db:create:all  
(in H:/projects/DMS)  
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active\_record/connection\_adapters/mysql\_adapter.rb:202:  
[BUG] Segmentation fault  
ruby 1.8.6 (2008-08-11) [i386-mswin32]

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

Process finished with exit code 3

---

<div class="post-metadata">

**Author:** ![divyamohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@divyamohan](https://www.ruby-forum.com/u/divyamohan)\
**Post date:** [May 4, 2009, 6:33pm UTC](https://www.ruby-forum.com/t/segmentation-fault-from-mysql-adapter-rb/163321/11 "2009-05-04T18:33:31Z")

</div>

What version of MySQL is everybody (that is having this problem)  
running?

I tried upgrading to 5.1 a while back and couldn’t get Rails  
(ActiveRecord) to even work with it.  
I downgraded back to 5.0.x and everything worked fine again. I haven’t  
tried going to 5.1 again.

On May 4, 9:16 am, “Gregg H.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![divyamohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@divyamohan](https://www.ruby-forum.com/u/divyamohan)\
**Post date:** [May 4, 2009, 7:19pm UTC](https://www.ruby-forum.com/t/segmentation-fault-from-mysql-adapter-rb/163321/12 "2009-05-04T19:19:29Z")

</div>

E. Litwin wrote:

> What version of MySQL is everybody (that is having this problem)  
> running?
> 
> I tried upgrading to 5.1 a while back and couldn’t get Rails  
> (ActiveRecord) to even work with it.  
> I downgraded back to 5.0.x and everything worked fine again. I haven’t  
> tried going to 5.1 again.
> 
> On May 4, 9:16ï¿½am, “Gregg H.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

I am running the latest 5.1 downloaded from

> **[MySQL :: Download MySQL Community Server](https://dev.mysql.com/downloads/mysql/5.1.html)**

The strange thing is using the rake task for drop all works. And just  
as another sidenote, the create all task that seg faults for me does  
actually make the databases. I just dont know where it dies.

---

<div class="post-metadata">

**Author:** ![divyamohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@divyamohan](https://www.ruby-forum.com/u/divyamohan)\
**Post date:** [May 7, 2009, 10:58pm UTC](https://www.ruby-forum.com/t/segmentation-fault-from-mysql-adapter-rb/163321/13 "2009-05-07T22:58:34Z")

</div>

Gregg H. wrote:

> I am also getting this, which I believe is related to the same problem:
> 
> # == InitialStructureAndData: migrating
> 
> – create\_table(“areas”, {:force=\>true})  
> rake aborted!  
> An error has occurred, all later migrations canceled:
> 
> undefined method `each’ for #Mysql:0x4007ff4
> 
> (See full trace by running task with --trace)

Fixed the problem. This solves both of my errors:

[http://forums.aptana.com/viewtopic.php?f=20&t=7563&p=27407&hilit=libmysql.dll#p27407](http://forums.aptana.com/viewtopic.php?f=20&t=7563&p=27407&hilit=libmysql.dll#p27407)

---

<div class="post-metadata">

**Author:** ![divyamohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@divyamohan](https://www.ruby-forum.com/u/divyamohan)\
**Post date:** [May 7, 2009, 10:11pm UTC](https://www.ruby-forum.com/t/segmentation-fault-from-mysql-adapter-rb/163321/14 "2009-05-07T22:11:43Z")

</div>

I am also getting this, which I believe is related to the same problem:

# == InitialStructureAndData: migrating

– create\_table(“areas”, {:force=\>true})  
rake aborted!  
An error has occurred, all later migrations canceled:

undefined method `each’ for #Mysql:0x4007ff4

(See full trace by running task with --trace)

---

<div class="post-metadata">

**Author:** ![divyamohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@divyamohan](https://www.ruby-forum.com/u/divyamohan)\
**Post date:** [July 3, 2009, 4:42pm UTC](https://www.ruby-forum.com/t/segmentation-fault-from-mysql-adapter-rb/163321/15 "2009-07-03T16:42:53Z")

</div>

The help at the aptana site fixed both my strange problems. Thanks so  
much. I was looking into changing to Mongrel/Apache to fix them.

One problem was when doing a find method on an ActiveRecord , ie  
Contact.find(1), it would get a seg fault . Contact.save would work  
fine and everything was getting to the MySQL db when I used ruby  
console. I’m working my way through the Ruby on Rails Bible by  
Timothy Fisher and it was very frustrating when simple examples did  
not work but enough worked that I didn’t suspect my installation.

The solution from the aptera site was to install a MySQL 5.0 dll  
( libmsql.dll )in place of the 5.1 one. When I looked in the ruby/bin  
directory it wasn’t even there. Copying that file over (and  
restarting webrick, MySQL server & console) did the trick. I thought  
I had installed the mysql gem but I’m new to RoR so I certainly could  
have messed up somewhere. It also fixed my strange problem where  
trying to view  
pages would crash Webrick.

I am using MySQL 5.0 but I do have 5.1 installed.

On May 7, 1:58 pm, “Gregg H.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![divyamohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e274bd/32.png) [@divyamohan](https://www.ruby-forum.com/u/divyamohan)\
**Post date:** [August 3, 2010, 9:09pm UTC](https://www.ruby-forum.com/t/segmentation-fault-from-mysql-adapter-rb/163321/16 "2010-08-03T21:09:13Z")

</div>

Divya M. wrote:

> Not yet solved. ☹

I had a simular problem (i am also newbie)  
for me it was solved by adding “host: localhost” in the  
config/database.yml file

Hope it can help some others to..

grtz,  
patrick
