Forum: Ruby Strange crash (interpreter bug?)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
934180817a3765d132193a5428f99051?d=identicon&s=25 sylvain.joyeux (Guest)
on 2005-12-04 15:00
(Received via mailing list)
I was trying to fix the busy_handler of the sqlite3. (version 1.1.0
makes
the interpreter crash)

Rewriting busy_handler in lib/sqlite3/native/driver.rb from

    def busy_handler( db, data=nil, &block )
      if block
        cb = API::CallbackData.new
        cb.proc = block
        cb.data = data
      end

      API.sqlite3_busy_handler( db,
        block ? API::Sqlite3_ruby_busy_handler : nil, cb )
    end


to

    def busy_handler( db, data=nil, &block )
      if block
        cb = API::CallbackData.new
        cb.proc = block
        cb.data = data
        API.sqlite3_busy_handler( db, API::Sqlite3_ruby_busy_handler,
cb)
      else
        API.sqlite3_busy_handler( db, nil, nil)
      end
    end

fixed the problem (at least on my system)

For me, those two functions are strictly equivalent. So ... where's the
difference ?
4b38034fdb66886a91d55fcd12964cee?d=identicon&s=25 pan (Guest)
on 2005-12-04 18:21
(Received via mailing list)
> For me, those two functions are strictly equivalent. So ...
> where's the difference ?

If you call the first busy_handler without a block, cb isn't
declared when calling Sqlite3_ruby_busy_handler.

gegroet,
Erik V. - http://www.erikveen.dds.nl/
934180817a3765d132193a5428f99051?d=identicon&s=25 sylvain.joyeux (Guest)
on 2005-12-04 20:23
(Received via mailing list)
> If you call the first busy_handler without a block, cb isn't
> declared when calling Sqlite3_ruby_busy_handler.
Does not seem so ... The code does run. The problem is a *crash* (i.e.
segfault).
4b38034fdb66886a91d55fcd12964cee?d=identicon&s=25 pan (Guest)
on 2005-12-04 20:36
(Received via mailing list)
> > > For me, those two functions are strictly equivalent. So
> > > ... where's the difference ?
> >
> > If you call the first busy_handler without a block, cb
> > isn't declared when calling Sqlite3_ruby_busy_handler.
>
> Does not seem so ... The code does run. The problem is a
> *crash* (i.e. segfault).

You asked about the difference between the two functions, not
why you application crashed ;)...

gegroet,
Erik V. - http://www.erikveen.dds.nl/
956f185be9eac1760a2a54e287c4c844?d=identicon&s=25 decoux (Guest)
on 2005-12-05 12:22
(Received via mailing list)
>>>>> "S" == Sylvain Joyeux <sylvain.joyeux@polytechnique.org> writes:

S> Does not seem so ... The code does run. The problem is a *crash*
(i.e.
S> segfault).

 I don't know what is a crash. Can you give a *small* example to
reproduce
 the problem, and your ruby version.


Guy Decoux
This topic is locked and can not be replied to.