Actions
Bug #19110
closedThread#pending_interrupt? with an argument does not work
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.2.0dev (2022-11-08T00:47:12Z master 7456647eff) [arm64-darwin21]
Description
The following code causes segmentation fault.
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 --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; i<RARRAY_LEN(th->pending_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;
}
}
Actions
Like0
Like0Like0