Bugs: Browse | Submit New | Admin

[#27693] DBD Mysql Segmentation fault

Date:
2010-01-16 10:51
Priority:
3
Submitted By:
Phil Dickinson (phild66)
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
DBD Mysql Segmentation fault

Detailed description
Hi,

I'm using Ruby 1.8.6-p383 on Windows 7 (lite) with dbi-0.4.3 and dbd-mysql-0.4.3 and am getting segmentation faults
with almost every do or execute statement.

Mysql version is 5.1.42-win32

Typical code fragment is:
---------------------------------------------------------
def insert()
  @id	= -1
  @time	= Time.now
  @status = "QUEUED"
  execStr = "INSERT INTO #{@@table_name} (account, submitted, engine, query1, query2, query3, runtime, email,
status)" +
    " VALUES (#{@account}, #{@time.to_i}, '#{@engine}', '#{@query1}', '#{@query2}', '#{@query3}', #{@runtime},
'#{@email}', '#{@status}')"
  if $DEBUG then puts execStr end
  begin 
    dbh	= connect()
    if ( dbh.do( execStr ) == 1 ) then
	if $DEBUG then puts "Inserted row..." end
	# Now try and retrieve the row ID.
	@id = dbh.func(:insert_id)
	if $DEBUG then puts "Success. Inserted row has id #{@id}." end
    end
  rescue DBI::DatabaseError => e
    puts "Exception encountered while inserting a 'request' into the database!"
    puts "Error = #{e.err} : #{e.errstr}"
  rescue 
    puts "Unhandled exception encountered while updating 'request' #{@id}!" + $!
  ensure
    puts "Disconnecting..."
    dbh.disconnect if dbh
  end
 return @id
end

Any ideas?  I will try different DBI and Mysql libs and on a different OS in the meantime.

Add A Comment: Notepad

Please login


Followup

Message
Date: 2010-01-18 16:46
Sender: Phil Dickinson

This seems to be related to Mysql version 5.1.

I tried a number of things including converting the code 
from DBI to Ruby/Mysql specific and I still got 
segmentation faults. Then I uninstalled Mysql 5.1.42 and 
installed 5.0.88 from the Mysql archives and that seems to 
cure the problem.
Date: 2010-01-17 21:39
Sender: Phil Dickinson

More debug information below.  I've got a slightly 
different setup with Ruby 1.9.1p243, gems (dbd-mysql 0.4.3, 
dbi 0.4.3, mysql 2.8.1).

INSERT INTO c9request (account, submitted, engine, query1, 
query2, query3, runti
me, email, status) VALUES (0, 
1263763414, 'Altavista', 'polar bears', 'penguins'
, 'shall never meet', 
3600, 'test.person@testdomain.com', 'QUEUED')
C:/Utils/Ruby/lib/ruby/gems/1.9.1/gems/dbi-
0.4.3/lib/dbi/sql/preparedstatement.r
b:41: [BUG] Segmentation fault
ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32]

-- control frame ----------
c:0015 p:---- s:0068 b:0068 l:000067 d:000067 CFUNC  :scan
c:0014 p:0014 s:0064 b:0064 l:000063 d:000063 METHOD 
C:/Utils/Ruby/lib/ruby/gems
/1.9.1/gems/dbi-0.4.3/lib/dbi/sql/preparedstatement.rb:41
c:0013 p:0035 s:0061 b:0061 l:000060 d:000060 METHOD 
C:/Utils/Ruby/lib/ruby/gems
/1.9.1/gems/dbi-0.4.3/lib/dbi/sql/preparedstatement.rb:89
c:0012 p:0021 s:0057 b:0057 l:000056 d:000056 METHOD 
C:/Utils/Ruby/lib/ruby/gems
/1.9.1/gems/dbi-0.4.3/lib/dbi/sql/preparedstatement.rb:27
c:0011 p:---- s:0052 b:0052 l:000051 d:000051 FINISH
c:0010 p:---- s:0050 b:0050 l:000049 d:000049 CFUNC  :new
c:0009 p:0055 s:0045 b:0045 l:000044 d:000044 METHOD 
C:/Utils/Ruby/lib/ruby/gems
/1.9.1/gems/dbd-mysql-0.4.3/lib/dbd/mysql/statement.rb:14
c:0008 p:---- s:0038 b:0038 l:000037 d:000037 FINISH
c:0007 p:---- s:0036 b:0036 l:000035 d:000035 CFUNC  :new
c:0006 p:0024 s:0029 b:0029 l:000028 d:000028 METHOD 
C:/Utils/Ruby/lib/ruby/gems
/1.9.1/gems/dbd-mysql-0.4.3/lib/dbd/mysql/database.rb:231
c:0005 p:0058 s:0021 b:0021 l:000020 d:000020 METHOD 
C:/Utils/Ruby/lib/ruby/gems
/1.9.1/gems/dbi-0.4.3/lib/dbi/handles/database.rb:106
c:0004 p:0145 s:0016 b:0016 l:000015 d:000015 METHOD 
Core9DBRequest.rb:41
c:0003 p:0216 s:0010 b:0008 l:00187c d:001f44 EVAL   
Core9DBRequest.rb:176
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:00187c d:00187c TOP
---------------------------
-- Ruby level backtrace information-------------------------
----------------
C:/Utils/Ruby/lib/ruby/gems/1.9.1/gems/dbi-
0.4.3/lib/dbi/sql/preparedstatement.r
b:41:in `scan'
C:/Utils/Ruby/lib/ruby/gems/1.9.1/gems/dbi-
0.4.3/lib/dbi/sql/preparedstatement.r
b:41:in `tokens'
C:/Utils/Ruby/lib/ruby/gems/1.9.1/gems/dbi-
0.4.3/lib/dbi/sql/preparedstatement.r
b:89:in `prepare'
C:/Utils/Ruby/lib/ruby/gems/1.9.1/gems/dbi-
0.4.3/lib/dbi/sql/preparedstatement.r
b:27:in `initialize'
C:/Utils/Ruby/lib/ruby/gems/1.9.1/gems/dbd-mysql-
0.4.3/lib/dbd/mysql/statement.r
b:14:in `new'
C:/Utils/Ruby/lib/ruby/gems/1.9.1/gems/dbd-mysql-
0.4.3/lib/dbd/mysql/statement.r
b:14:in `initialize'
C:/Utils/Ruby/lib/ruby/gems/1.9.1/gems/dbd-mysql-
0.4.3/lib/dbd/mysql/database.rb
:231:in `new'
C:/Utils/Ruby/lib/ruby/gems/1.9.1/gems/dbd-mysql-
0.4.3/lib/dbd/mysql/database.rb
:231:in `do'
C:/Utils/Ruby/lib/ruby/gems/1.9.1/gems/dbi-
0.4.3/lib/dbi/handles/database.rb:106
:in `do'
CDBRequest.rb:41:in `insert'
CDBRequest.rb:176:in `<main>'

Strange thing is that it's a little bit random.  Although 
it fails most of the time, it does occasionally work. 

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item