Using rb_protect() I've realized that when the thread is killed by other thread using Thread#kill, the error_tag passed to rb_protect() is set to 8 and rb_errinfo() returns Fixnum 8:
ret = rb_protect(function, data, &error_tag);
// While executing function() in Ruby land, our thread is
// killed by Thread.kill.
// If now I inspect rb_errinfo() it returns Fixnum 8, and
// error_tag it's set to integer 8.
Is it the expected behaviour? Wouldn't make more sense rb_errinfo() to return some kind of a new exception ThreadKilledException or whatever instead of Fixnum 8?
Using rb_protect() I've realized that when the thread is killed by other thread using Thread#kill, the error_tag passed to rb_protect() is set to 8 and rb_errinfo() returns Fixnum 8:
ret = rb_protect(function, data, &error_tag);
// While executing function() in Ruby land, our thread is
// killed by Thread.kill.
// If now I inspect rb_errinfo() it returns Fixnum 8, and
// error_tag it's set to integer 8.
Is it the expected behaviour? Wouldn't make more sense rb_errinfo() to return some kind of a new exception ThreadKilledException or whatever instead of Fixnum 8?
I don't have an idea.
Could you show us the complete small example on it?
I want to try on my environment.
Running my C extension (which uses blocking region for running a libuv loop) with 1.9.3-p0 works perfectly, but using 2.0.0dev I get assertion errors due to states that should never happen in my C code. Are there important changes in the blocking-region stuff in 2.0.0?
Thanks, that's more or less the workaround I've applied in my code: if rb_protect() detects an error and rb_errinfo() returns a Fixnum, then I don't raise it, but instead set the error to Interrupt and then raise it.
If you want to know the detailed rationale, please ask ko1 in the mailing list.
If you wish, please open another feature request with the concrete motivation.