Menu

#5 seg fault on driver loading

open
nobody
None
5
2002-08-07
2002-08-07
No

I try and connect to a Mysql database using DBI and I get
a seg fault in ruby.

I am using ruby 1.6.4 (2001-06-04) [i686-linux] the latest
version of Ruby-DBI - 0.0.16.

I didn't realise that I had only installed the DBI and not any
DBD's (in particular dbd_mysql)

Here is the config file for the install:
***starts***
without=
so-dir=/usr/lib/ruby/site_ruby/1.6/i686-linux
ruby-path=/usr/bin/ruby
ruby-prog=/usr/bin/ruby
with=dbi
make-prog=make
rb-dir=/usr/lib/ruby/site_ruby/1.6
bin-dir=/usr/bin
data-dir=/usr/share
***ends****

The bug is in how Ruby/DBI manages a case-insensitive
load of a database driver when that driver is not installed.

The test programme is fairly simple:
***starts***
require 'dbi'
DBI.connect('DBI:Mysql:sms', 'root', 'mypassword') do | dbh
|
end
***ends***

It gives the following trace when I run it. As expected it tells
me it cannot load the driver (it is not installed)
***starts***
gordon@lesley:/opt/ruby/sms/ruby/bits> ruby DBItest.rb
/usr/lib/ruby/site_ruby/1.6/dbi/dbi.rb:434:in `load_driver':
Could not load driver (uninitialized constant Mysql at
DBI::DBD) (DBI::InterfaceError)
from /usr/lib/ruby/site_ruby/1.6/dbi/dbi.rb:349:in
`_get_full_driver'
from /usr/lib/ruby/site_ruby/1.6/dbi/dbi.rb:329:in
`connect'
from DBItest.rb:2
***ends***

By comparison when I change the case from Mysql to
mysql as per:
***starts***
require 'dbi'
DBI.connect('DBI:mysql:sms', 'root', 'mypassword') do | dbh |
end
***ends***

I get a somewhat different trace:
***starts***
gordon@lesley:/opt/ruby/sms/ruby/bits> ruby DBItest.rb
/usr/lib/ruby/site_ruby/1.6/dbi/dbi.rb:424: [BUG]
Segmentation fault
ruby 1.6.4 (2001-06-04) [i686-linux]
Aborted
***ends***

Gordon Guthrie (gordon_guthrie@hotmail.com)

Discussion


Log in to post a comment.