From: Dave Lilley Date: 2010-12-15T16:20:35+09:00 Subject: mysql gem segfault on line 343 cross posted from mysql ruby forums hi there, using 1.8.7 p302 via rubyinstaller I can connect to a remote MYSQL server fine via mysql - trouble is i'm converting a linux app to windows and I have sequel code embedded throughout my project. I have 1 script that handles the sql calls below is a sample of what the class initialization method does and the errors generated. anyone able to help? (prefer to use sequel gem to save LOTS of recoding/debugging). converting on WINXP virtual machine end OS is going to be W2K pro - win XP systems. Doesn't seem to matter where i have the line - get_all_acccodes.each{|c| puts c} it will segfault anyway. the version of LIBmysql.dll is one I got from http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/libmySQL.dll that file is 1.484Kb large and i have another that is like 242Kb this one also segfaults too. sample code being used... require 'sequel' require 'logger' # require 'mysql' class Dopen def initialize(*arg) @path = "/logs" @log = Logger.new("#{@path}DB - info.log") @log.level = Logger::DEBUG @log.debug('initialing the DB access!') if arg[0] == 'local' #was only used for test via my local server - i want to connect to the remote server only now! else puts 'in remote side' @db = Sequel.mysql(:host => 'remote.co.nz', :user => "user", :password => "p/word", :database => "database", :logger => Logger.new( STDOUT )) # test.each{|r| puts r} <<< 1st errors belong to this line - line 22 get_all_acccodes.each{|c| puts c} <<< 2nd errors belong to this line # this connection code works fine below!!! # @db = Mysql.new('remote.co.nz', "user", "p/word",'database') # remote end rescue Sequel::Error @log.debug("An error occurred\nError code: #{Sequel}\nError message: #{Sequel.to_s}") ensure @log.debug("DB closed!") # @db.close if @db end def get_all_acccodes @log.debug('getting all account codes') @db[:cust_data].filter(:closed => 0, :contract => 0) # 1 = true account is CLOSED, 0 means it's OPEN #line below works with mysql direct # @db.query("select * from cust_data where closed = 0 and contract = 0") end end a = Dopen.new 'remote' << allows for quick switching when i was developing locally *** end of teh script file **** Now if I change the connect line from Sequel.mysql(...) to Sequel.mysql.connect(...) i get a reference to as per error 3 - No user or password for Dave @ localhost!!! I'm not conecting to a local host. I do have Mysql community installed but will need to remove it to gain disk space back, I only did this because originally i couldn't even connect to the remote Mysql server and I thought i might need it locally. any pointers on what I'm doing wrong? many thanks for any - all help. dave. 1st errors for simple show version of server being run.... C:\monitoring screen>ruby -rubygems sequel1.rb in remote side I, [2010-12-14T22:54:15.335004 #2740] INFO -- : (0.190273s) SET @@wait_timeout = 2147483 I, [2010-12-14T22:54:15.535292 #2740] INFO -- : (0.200288s) SET SQL_AUTO_IS_NUL L=0 I, [2010-12-14T22:54:15.715552 #2740] INFO -- : (0.180260s) SELECT VERSION() VERSION()5.1.52 # # sequel1.rb:22:in `initialize': undefined method `each' for nil:NilClass (NoMetho dError) from sequel1.rb:159:in `new' from sequel1.rb:159 C:\monitoring screen> 2nd error C:\monitoring screen>ruby -rubygems sequel1.rb in remote side I, [2010-12-14T22:55:11.310100 #2776] INFO -- : (0.190273s) SET @@wait_timeout = 2147483 I, [2010-12-14T22:55:11.500374 #2776] INFO -- : (0.190274s) SET SQL_AUTO_IS_NUL L=0 I, [2010-12-14T22:55:11.710676 #2776] INFO -- : (0.210302s) SELECT * FROM `cust _data` WHERE ((`closed` = 0) AND (`contract` = 0)) C:/Ruby187/lib/ruby/gems/1.8/gems/sequel-3.18.0/lib/sequel/adapters/mysql.rb:343 : [BUG] Segmentation fault ruby 1.8.7 (2010-08-16 patchlevel 302) [i386-mingw32] This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. C:\monitoring screen> 3rd error output... C:\monitoring screen>ruby -rubygems sequel1.rb in remote side C:/Ruby187/lib/ruby/gems/1.8/gems/sequel-3.18.0/lib/sequel/adapters/mysql.rb:112 :in `real_connect': Access denied for user 'dave'@'localhost' (using password: N O) (Mysql::Error) from C:/Ruby187/lib/ruby/gems/1.8/gems/sequel-3.18.0/lib/sequel/adapters /mysql.rb:112:in `connect' from sequel1.rb:20:in `initialize' from sequel1.rb:160:in `new' from sequel1.rb:160 C:\monitoring screen> -- Posted via http://www.ruby-forum.com/.