Project

General

Profile

Actions

Bug #12405

closed

Queue doesn't work inside of trap

Added by kirillrdy (Kirill Radzikhovskyy) over 8 years ago. Updated over 7 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
[ruby-core:75636]

Description

when adding things to the queue inside that trap blocking pop never unblocks

q = Queue.new
Signal.trap 'INT' do
  puts "got INT"
  q << 'something'
end

Thread.new {
  loop {
    sleep 1
    Process.kill :INT, $$
  }
}

q.pop

I know that there are limitations of what can be done inside of trap.
Looking at this https://bugs.ruby-lang.org/issues/6128 it looks like I should be able to use Queue inside a trap, but code above runs forever.
Also in jruby it behaives as expected ( at least in my understanding )

Updated by ko1 (Koichi Sasada) over 8 years ago

  • Description updated (diff)
  • Assignee set to ko1 (Koichi Sasada)
Actions #2

Updated by ko1 (Koichi Sasada) almost 8 years ago

  • Status changed from Open to Closed

Applied in changeset r57479.


allow Queue operation in trap.

  • thread_sync.c: allow spurious wakeup to check Queue status just after trap.
    [Bug #12405]

  • test/thread/test_queue.rb: add a test for it.

Updated by ko1 (Koichi Sasada) almost 8 years ago

We need to check Queue status change after trap handler.

Sorry for my late response and thank you for your reporting it.

Updated by naruse (Yui NARUSE) almost 8 years ago

  • Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: DONE

ruby_2_4 r57879 merged revision(s) 57477,57478,57479.

Updated by nagachika (Tomoyuki Chikanaga) almost 8 years ago

  • Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: DONE to 2.1: UNKNOWN, 2.2: REQUIRED, 2.3: REQUIRED, 2.4: DONE

Updated by nagachika (Tomoyuki Chikanaga) almost 8 years ago

  • Backport changed from 2.1: UNKNOWN, 2.2: REQUIRED, 2.3: REQUIRED, 2.4: DONE to 2.1: UNKNOWN, 2.2: REQUIRED, 2.3: DONE, 2.4: DONE

ruby_2_3 r58036 merged revision(s) 57477,57478,57479.

Updated by usa (Usaku NAKAMURA) over 7 years ago

  • Backport changed from 2.1: UNKNOWN, 2.2: REQUIRED, 2.3: DONE, 2.4: DONE to 2.1: UNKNOWN, 2.2: REQUIRED, 2.3: REQUIRED, 2.4: DONE

nagachika-san, r57492 is also required.

Updated by usa (Usaku NAKAMURA) over 7 years ago

  • Backport changed from 2.1: UNKNOWN, 2.2: REQUIRED, 2.3: REQUIRED, 2.4: DONE to 2.1: UNKNOWN, 2.2: DONE, 2.3: REQUIRED, 2.4: DONE

ruby_2_2 r58115 merged revision(s) 57477,57478,57479,57492.

Updated by nagachika (Tomoyuki Chikanaga) over 7 years ago

  • Backport changed from 2.1: UNKNOWN, 2.2: DONE, 2.3: REQUIRED, 2.4: DONE to 2.1: UNKNOWN, 2.2: DONE, 2.3: DONE, 2.4: DONE

ruby_2_3 r58164 merged revision(s) 57492.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0