The following code gives a segmentation fault on the last line
require 'rubygems' gem 'mysql' gem 'dbi' require 'dbi' require 'mysql' dsn = 'DBI:Mysql:DATABASE:www.HOST.net' # redacted dbh = DBI.connect(dsn, 'USERNAME', 'PASSWORD') # redacted sth = dbh.execute('select * from TABLE where numeric_value is not null limit 10;') # redacted
It’s definitely the last line that’s causing the problem — a print statement on the next line doesn’t ever get executed.
Does anyone know why such a simple attempt would fail?
I’m running this on Windows, in case that makes a difference.
This could be any number of things, from the version of DBI, Mysql gem, mysql version, and ruby version.
Unfortunately ruby isn’t a first class citizen on windows, nor are all configurations tested extensively on it.
First enable debugging on your VM to reproduce this issue with more information about where and why the segfault is happening. Pass the -d option the VM. From there you will hopefully have more info to where to look for the solution.
I’d suggest, check your patch level of your VM
I’d also check the level of DBI, and Mysql
You could also switch how you are accessing Mysql, ActiveRecord uses it’s own code to connect to mysql, which is more extensively tested. May not be the best solution but should not rule it out.