Bernhard Glueck wrote:

> Now when the call to the ruby method "MyRubyMethod" results in an 
> exception, the "LocalInstanceOnStack" class var will never be 
> deleted/the destructor not called.....
> 
> Is this true? Or are the problems different with the longjmp "feature"?

Yes, you are correct. The stack is not going to be "unwound" and so your 
local variable's destructors are not going to be called. Along the same 
lines, if you had dynamically allocated memory at the top of the 
function, e.g.

     void MyFunction()
     {
       SomeClass localInstanceOnStack;
       char *str = new char[50];
       CallSomeRubyMethod( "MyRubyMethod", str );
       delete [] str;
     }


then your code will leak memory when "MyRubyMethod" raises an exception.

> If this is true, is there any way around this, or any future changes 
> that will solve this?

Paul Brannan has done a lot of research into this problem and has posted 
some good information in the past. If you have a time machine handy, 
travel ahead to Saturday, November 2, when Paul Brannan will be giving a 
talk on exception handling:

	http://www.rubyconf.org/speakers.php#brannp

If time travel is out of the question, try doing a Google search for 
"ruby c++ exception" (or similar keyword combinations). It should turn 
up some posts that give suggestions about what to do; e.g. instead of 
calling a Ruby method directly via rb_funcall(), wrap it with a call to 
rb_protect() or rb_rescue();

Hope this helps,

Lyle