Project

General

Profile

Actions

Bug #19110

closed

Thread#pending_interrupt? with an argument does not work

Added by katsu (Katsuhiro Ueno) over 1 year ago. Updated over 1 year ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.2.0dev (2022-11-08T00:47:12Z master 7456647eff) [arm64-darwin21]
[ruby-core:110650]

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 #2

Updated by mame (Yusuke Endoh) over 1 year ago

  • Status changed from Open to Closed

Applied in changeset git|c3de7a3c58bf9a138ff8720ed56c0045d2b8e01d.


Make pending_interrupt?(Exception) work

A patch from katsu (Katsuhiro Ueno)

[Bug #19110]

Actions

Also available in: Atom PDF

Like0
Like0Like0