# Strange crash (interpreter bug?)

**URL:** <https://www.ruby-forum.com/t/strange-crash-interpreter-bug/49437>\
**Category:** Ruby\
**Created:** [December 4, 2005, 3:00pm UTC](https://www.ruby-forum.com/t/strange-crash-interpreter-bug/49437 "2005-12-04T15:00:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sylvain.joyeux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e47c2d/32.png) [@sylvain.joyeux](https://www.ruby-forum.com/u/sylvain.joyeux)\
**Post date:** [December 4, 2005, 3:00pm UTC](https://www.ruby-forum.com/t/strange-crash-interpreter-bug/49437/1 "2005-12-04T15:00:53Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![sylvain.joyeux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e47c2d/32.png) [@sylvain.joyeux](https://www.ruby-forum.com/u/sylvain.joyeux)\
**Post date:** [December 4, 2005, 6:21pm UTC](https://www.ruby-forum.com/t/strange-crash-interpreter-bug/49437/2 "2005-12-04T18:21:44Z")

</div>

> 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/](http://www.erikveen.dds.nl/)

---

<div class="post-metadata">

**Author:** ![sylvain.joyeux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e47c2d/32.png) [@sylvain.joyeux](https://www.ruby-forum.com/u/sylvain.joyeux)\
**Post date:** [December 4, 2005, 8:23pm UTC](https://www.ruby-forum.com/t/strange-crash-interpreter-bug/49437/3 "2005-12-04T20:23:58Z")

</div>

> 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).

---

<div class="post-metadata">

**Author:** ![sylvain.joyeux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e47c2d/32.png) [@sylvain.joyeux](https://www.ruby-forum.com/u/sylvain.joyeux)\
**Post date:** [December 4, 2005, 8:36pm UTC](https://www.ruby-forum.com/t/strange-crash-interpreter-bug/49437/4 "2005-12-04T20:36:08Z")

</div>

> > > 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/](http://www.erikveen.dds.nl/)

---

<div class="post-metadata">

**Author:** ![sylvain.joyeux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e47c2d/32.png) [@sylvain.joyeux](https://www.ruby-forum.com/u/sylvain.joyeux)\
**Post date:** [December 5, 2005, 12:22pm UTC](https://www.ruby-forum.com/t/strange-crash-interpreter-bug/49437/5 "2005-12-05T12:22:05Z")

</div>

> > > > > “S” == Sylvain J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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
