Looking for some insight about rb_protect and the longjmp calls.
Is rb_protect supposed to always return back to the caller? I’m wrapping
calls in rb_protect wherever I can in my C++ application, but it seems that
rb_protect doesn’t always return.
If I call rb_raise from inside rb_protect, longjmp seems to be getting
called and I don’t get a return from rb_protect. I also noticed that if I
make certain “mistakes” such as pass an invalid value to rb_funcall where
the object VALUE is expected, my application throws a system exception even
though the rb_funcall was wrapped in rb_protect and rb_protect never
returns.
I’ve poked around as much as I know how to, and I am not sure if this is
intended behavior (perhaps: caveat emptor), or if the bcc32 .dll build is
just snafu.
Is rb_protect supposed to always return back to the caller? I’m wrapping
calls in rb_protect wherever I can in my C++ application, but it seems that
rb_protect doesn’t always return.
If I call rb_raise from inside rb_protect, longjmp seems to be getting
called and I don’t get a return from rb_protect. I also noticed that if I
make certain “mistakes” such as pass an invalid value to rb_funcall where
the object VALUE is expected, my application throws a system exception even
though the rb_funcall was wrapped in rb_protect and rb_protect never
returns.
rb_protect() should always return except for cases below:
When rb_protect “doesn’t return” what does happen? Does your code get
jumped over or does the program hang or does it crash?
I know that if you throw a C++ exception from inside an rb_protect call,
then on some platforms (g++ under Linux is one), std::terminate() will
be called.
Paul
···
On Thu, Jun 19, 2003 at 08:17:53AM +0900, Sean O’Dell wrote:
Looking for some insight about rb_protect and the longjmp calls.
Is rb_protect supposed to always return back to the caller? I’m
wrapping calls in rb_protect wherever I can in my C++ application, but
it seems that rb_protect doesn’t always return.
How do I raise a ruby exception such that the ruby script gets the
exception, but my C/C++ code is allow to continue?
see the implementation of ‘Funcall’
I think there’s a bug somewhere in rb_funcall; it doesn’t seem to notice
bad object VALUE’s. I don’t do diff’s or create patches that often so I’m
fuzzy on the procedure, but if I find where it’s happening and can fix it
myself, I’ll try and submit the fix.
Try rip my backtrace procedure from the link above, this can hopefully
help you locate the problem
···
On Thu, 19 Jun 2003 16:31:01 +0000, Sean O’Dell wrote:
Looking for some insight about rb_protect and the longjmp calls.
Is rb_protect supposed to always return back to the caller? I’m
wrapping calls in rb_protect wherever I can in my C++ application, but
it seems that rb_protect doesn’t always return.
When rb_protect “doesn’t return” what does happen? Does your code get
jumped over or does the program hang or does it crash?
I know that if you throw a C++ exception from inside an rb_protect call,
then on some platforms (g++ under Linux is one), std::terminate() will
be called.
Well, now I’m trying to determine when it does what. A simple test from the
top of the app works fine; rb_protect returns even though it called a
function that called rb_raise, but when I do the same thing from within a
ruby callback (my application embeds ruby as well as extends it, so this
ruby callback is actually a class method) rb_protect isn’t protecting
anything; rb_protect never returns, as if I were calling rb_raise directly.
I think in one other place in my code where I did this, the program actually
just crashed.
I’m thinking there must be something goofy with the .dll build. It works
trouble-free 98% of the time, but every so often something completely
unexpected happens like an invalid address access or something. I’m
guessing I may need to double-check my compile options or something.
Sean O'Dell
···
On Thu, Jun 19, 2003 at 08:17:53AM +0900, Sean O’Dell wrote:
It’s possible that if you are linking against two different ruby
libraries at the same time that what you described could happen. The
exceptions raised in one ruby library would not be caught by functions
in the other library.
Paul
···
On Fri, Jun 20, 2003 at 02:27:31AM +0900, Sean O’Dell wrote:
I’m thinking there must be something goofy with the .dll build. It works
trouble-free 98% of the time, but every so often something completely
unexpected happens like an invalid address access or something. I’m
guessing I may need to double-check my compile options or something.