From: "katsu (Katsuhiro Ueno)" Date: 2022-11-08T03:29:51+00:00 Subject: [ruby-core:110650] [Ruby master Bug#19110] Thread#pending_interrupt? with an argument does not work Issue #19110 has been reported by katsu (Katsuhiro Ueno). ---------------------------------------- Bug #19110: Thread#pending_interrupt? with an argument does not work https://bugs.ruby-lang.org/issues/19110 * Author: katsu (Katsuhiro Ueno) * Status: Open * Priority: Normal * ruby -v: ruby 3.2.0dev (2022-11-08T00:47:12Z master 7456647eff) [arm64-darwin21] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- The following code causes segmentation fault. ```ruby t = Thread.handle_interrupt(Exception => :never) { Thread.new { Thread.stop } } t.raise(Exception) p t.pending_interrupt?(Exception) # => SEGV ``` Perhaps this is due to a wrong invocation of `rb_class_inherited_p` with a non-module object. In `rb_threadptr_pending_interrupt_include_p`, `e` should be an exception, not a module. The following is my fix. ```diff diff --git a/thread.c b/thread.c index d8925e618e..2e76aef4b4 100644 --- a/thread.c +++ b/thread.c @@ -1922,7 +1922,7 @@ rb_threadptr_pending_interrupt_include_p(rb_thread_t *th, VALUE err) int i; for (i=0; ipending_interrupt_queue); i++) { VALUE e = RARRAY_AREF(th->pending_interrupt_queue, i); - if (rb_class_inherited_p(e, err)) { + if (rb_obj_is_kind_of(e, err)) { return TRUE; } } ``` -- https://bugs.ruby-lang.org/ Unsubscribe: