[geos-devel] Ruby, FFI and ERROR_/NOTICE_MESSAGE

Charlie Savage cfis at savagexi.com
Fri Dec 10 02:25:55 EST 2010

> Alright, I think it's all good. I posted to the ruby-ffi list and got
> back a response already and the prognosis is good! See
> http://groups.google.com/group/ruby-ffi/browse_thread/thread/836d6c772d8088dc
> , wherein I picked up the science that Mr. Wayne Meissner laid down.

Ah, reading his response, your callbacks were eaten by the garbage 
collector.  That would explain the strange behavior and why commenting 
in and out lines of codes would sometimes change the results.  Sorry, I 
should have put 2 and 2 together based on your earlier description (been 
there done that with those sort of symptoms wrapping other C extensions).

> Apparently the garbage collector was collecting some objects that
> shouldn't have been collected, so the solution is to store them
> somewhere until they can more safely be discarded with. I've patched
> things up and stored the error and notice handler return values in
> Thread.current and voilà, things started working -- no segfaults, no
> weird memory errors. The full test suite is now running crash-free on
> both Ruby 1.8.7 and 1.9.2, including a new multithreading test using
> multiple WkbWriters, byte orders and dimensions and the whole shebang.


> Anyways, things are looking quite good now and we're getting closer to
> a usable state! Rad!

Nice work!


More information about the geos-devel mailing list