From: "Timothy J. Wood" Date: 2006-02-06T02:50:19+09:00 Subject: Is the SQLite3 gem known to have memory corruption? Running the following produces bizarre results (trimmed down from an actual app): ----- #!/opt/local/bin/ruby require 'rubygems' require_gem 'sqlite3-ruby' def each_batch(size=1) until false batch = [] (1..20).each {|i| batch << "x"} yield batch end end database = SQLite3::Database.new("/tmp/test.db") counter = 0 each_batch {|batch| database.transaction { counter += batch.length print "OK\n" } } ----- For a while it prints "OK", but then eventually: ./test_bad_batch.rb:20: undefined method `length' for 4085314:Fixnum (NoMethodError) from /opt/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.1.0/ lib/sqlite3/database.rb:593:in `transaction' from ./test_bad_batch.rb:19 from ./test_bad_batch.rb:11:in `each_batch' from ./test_bad_batch.rb:11:in `each_batch' from ./test_bad_batch.rb:18 That is the 'batch' is getting yielded as random pointer instead of the array generated inside each_batch! I've tried narrowing this further (particularly getting rid of SQLite usage), but this is the simplest case I can come up with so far. I'm running on Mac OS X 10.4.4 with ruby 1.8.4 installed via Darwin Ports (as well as rubygems installed from there and then sqlite3 installed via that copy of gems). ---- % /opt/local/bin/ruby -v ruby 1.8.4 (2005-12-24) [powerpc-darwin8.3.0] % /opt/local/bin/gem list sqlite3-ruby *** LOCAL GEMS *** sqlite3-ruby (1.1.0) SQLite3/Ruby is a module to allow Ruby scripts to interface with a SQLite3 database. ---- I've tried both the system supplied sqlite (v3.1.3) and the latest version (installed via Darwin Ports), 3.3.3. Any info would be helpful! -tim