From: lars@greiz-reinsdorf.de
To: ruby-core@ruby-lang.org
Subject: [ruby-core:96849] [Ruby master Bug#15509] TCPServer#accept isn't interrupted
Date: Tue, 14 Jan 2020 10:38:09 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-83853.20200114103809.b34572f2cef5ccb6@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15509.20190105180924@ruby-lang.org
Issue #15509 has been updated by larskanis (Lars Kanis).
Status changed from Closed to Open
Thank you @jeremyevans0 for checking this! Unfortunately it still fails on Linux. I tried the following recent ruby versions and they all block infinitely:
```
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]
ruby 2.5.7p206 (2019-10-01 revision 67816) [x86_64-linux]
```
It however stops as expected on Windows:
```
$ ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [i386-mingw32]
$ ruby -d --disable-gems bug_15509.rb
Exception `Stop' at bug_15509.rb:14 - Stop
```
----------------------------------------
Bug #15509: TCPServer#accept isn't interrupted
https://bugs.ruby-lang.org/issues/15509#change-83853
* Author: larskanis (Lars Kanis)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
This is another issue I noticed with [Eventbox](https://github.com/larskanis/eventbox):
This script tries to stop `TCPServer#accept` with `Thread#raise`:
```ruby
require "socket"
Thread.abort_on_exception = true
class Stop < RuntimeError
end
serv = TCPServer.new("localhost", 12345)
th = Thread.handle_interrupt(Exception => :never) do
Thread.new do
begin
Thread.handle_interrupt(Stop => :on_blocking) do
# sleep # sleep is aborted
serv.accept # but accept isn't
end
rescue Stop
end
end
end
th.raise Stop
th.join
serv.close
```
The program freezes and if stopped per CTRL-C the output looks similar to:
```sh
$ ruby -d --disable-gems no-interrupt-while-accept.rb
^CException `Interrupt' at no-interrupt-while-accept.rb:23 -
Exception `Stop' at no-interrupt-while-accept.rb:15 - Stop
Traceback (most recent call last):
1: from no-interrupt-while-accept.rb:23:in `<main>'
no-interrupt-while-accept.rb:23:in `join': Interrupt
```
The debug output shows, that the `Stop` exception is delivered after the `Interrupt` exception has been delivered to the main thread. However it should be delivered immediately, since it's a blocking operation. In contrast `sleep` is aborted as expected.
This issue is present on all older MRI versions. However it doesn't appear on JRuby-9.2.5.0.
--
https://bugs.ruby-lang.org/
prev parent reply other threads:[~2020-01-14 10:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-15509.20190105180924@ruby-lang.org>
2019-01-05 18:09 ` [ruby-core:90900] [Ruby trunk Bug#15509] TCPServer#accept isn't interrupted lars
2019-08-28 18:32 ` [ruby-core:94633] [Ruby master " merch-redmine
2020-01-14 10:38 ` lars [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-83853.20200114103809.b34572f2cef5ccb6@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).