mysql gem segfault on line 343

D

Dave Lilley

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
#<Sequel::MySQL::Dataset:0x2d6aec0>
#<Sequel::MySQL::Dataset:0x2d6a278>
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>
 
L

Luis Lavena

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.

What version of mysql gem you have installed? (gem list mysql)

You need to download mysql 5.0.x and just copy libmysql.dll from the
bin directory. You can use the noinstall zip packages:

http://downloads.mysql.com/archives.php?p=mysql-5.0&o=-win

5.0.91, Microsoft Windows 32, (first download in the list)

Place that file and let's solve the segfault, the others errors are
incorrect usage of Sequel, which I can't help you with.
 
D

Dave Lilley

Luis Lavena wrote in post #968543:
What version of mysql gem you have installed? (gem list mysql)

You need to download mysql 5.0.x and just copy libmysql.dll from the
bin directory. You can use the noinstall zip packages:

http://downloads.mysql.com/archives.php?p=mysql-5.0&o=-win

5.0.91, Microsoft Windows 32, (first download in the list)

Downloaded it and then tried it again and got the same error.
Place that file and let's solve the segfault, the others errors are
incorrect usage of Sequel, which I can't help you with.

The Sequel stuff works just fine under linux so i cannot accept that
comment.
(well okay the Sequel.mysql.connect maybe wrong but it was a test).

So now I've tried 3 versions of libmysql.dll files sizes are 242Kb,
1.484Kb and now this one 2.020Kb

So now i'll try the other mysql zip files (just in case one of them
works).

dave.
 
D

Dave Lilley

Dave Lilley wrote in post #968778:
Luis Lavena wrote in post #968543:


Downloaded it and then tried it again and got the same error.


The Sequel stuff works just fine under linux so i cannot accept that
comment.
(well okay the Sequel.mysql.connect maybe wrong but it was a test).

So now I've tried 3 versions of libmysql.dll files sizes are 242Kb,
1.484Kb and now this one 2.020Kb

So now i'll try the other mysql zip files (just in case one of them
works).

dave.




This problem is SOLVED !!!

NO more seg faults.

I had installed a very recent release of mysql (this was in an attempt
to get over the early problems I had).

Now it appears when i ran my script it went to the mysql bin directory
found and used THE libmysql.dll that was found there! no the version I
had in ruby187\lib (also tried the DLL in the ruby187\bin but with no
luck)

I've now removed the server from the system (low disk space biggest
reason) moved the DLL back to ruby187\bin and it still works (failed
with it in ruby187\lib).


regards,

Dave.
 
D

Dave Lilley

Yangtt wrote in post #968784:
HI

which sofware is best to reading ruby language?

thanks

What is you OS?

i suppose really any text editor will do.

Under windows used to use Scite but as it's not supplied with ruby1.8.7
I've gone for notepad++ as it supports multi files and can highlight
other things like Scite did for the ruby enviroment.

Linux i use Kate (I use the KDE desktop) or gedit (I think).

Mac's I've heard textpad or textmate as being the preferred editor.

HTH

Dave.

PS Yangtt you've "highjacked" a thead / set of messages that has nothing
to do with text editors and this is considered bad form almost ill
mannered.
Please in future if what you want to add isn't related even a little bit
start a new topic.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top