Issue #6575 has been updated by mame (Yusuke Endoh).

Status changed from Feedback to Rejected
Assignee set to ko1 (Koichi Sasada)

This is not a bug.  So I'm closing this ticket.

Because Thread#kill should not be rescue'd so easily, it does throw a special exception which has no class, to make it hard to rescue.

Incidentally, the value 8 means INT2FIX(TAG_FATAL) which is set in rb_threadptr_to_kill:

1690 static void
1691 rb_threadptr_to_kill(rb_thread_t *th)
1692 {
1693     rb_threadptr_async_errinfo_clear(th);
1694     th->status = THREAD_TO_KILL;
1695     th->errinfo = INT2FIX(TAG_FATAL);
1696     TH_JUMP_TAG(th, TAG_FATAL);
1697 }

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.

-- 
Yusuke Endoh <mame / tsg.ne.jp>
----------------------------------------
Bug #6575: Thread#kill sets rb_errinfo() to Fixnum 8 after rb_protect(function, data, &error_tag)
https://bugs.ruby-lang.org/issues/6575#change-32488

Author: ibc (IƱaki Baz Castillo)
Status: Rejected
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: core
Target version: 1.9.3
ruby -v: ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]


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?


-- 
http://bugs.ruby-lang.org/