From: "yamam (Masanari Yamamoto) via ruby-core" <ruby-core@ml.ruby-lang.org>
To: ruby-core@ml.ruby-lang.org
Cc: "yamam (Masanari Yamamoto)" <noreply@ruby-lang.org>
Subject: [ruby-core:117733] [Ruby master Bug#20461] Unreadable pipe included in the readable IO of IO.select
Date: Sat, 27 Apr 2024 23:21:10 +0000 (UTC) [thread overview]
Message-ID: <redmine.issue-20461.20240427232109.53318@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-20461.20240427232109.53318@ruby-lang.org
Issue #20461 has been reported by yamam (Masanari Yamamoto).
----------------------------------------
Bug #20461: Unreadable pipe included in the readable IO of IO.select
https://bugs.ruby-lang.org/issues/20461
* Author: yamam (Masanari Yamamoto)
* Status: Open
* ruby -v: ruby 3.4.0dev (2024-04-27T12:55:28Z master c844968b72) [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
When executing the following script, pipe_r is not supposed to be readable because no writing is done to pipe_w, but pipe_r is included in the return value rs of IO.select. Since it is not possible to read from pipe_r, the IO::EAGAINWaitReadable exception is raised.
```ruby
pipe_r, pipe_w = IO.pipe
1000.times do |i|
File.popen(['seq', '1', '1000']) do |popen_r|
j = 0
while true
rs, ws, = IO.select([popen_r, pipe_r])
if rs.include?(popen_r)
unless popen_r.gets
break
end
end
if rs.include?(pipe_r)
puts "IO.select BUG pipe_r is not readable! i = #{i} j = #{j}"
p pipe_r.read_nonblock(1)
end
j += 1
end
end
end
```
```
$ ruby select.rb
IO.select BUG pipe_r is not readable! i = 0 j = 20
<internal:io>:63:in `read_nonblock': Resource temporarily unavailable - read would block (IO::EAGAINWaitReadable)
from select.rb:14:in `block (2 levels) in <main>'
from select.rb:3:in `popen'
from select.rb:3:in `block in <main>'
from select.rb:2:in `times'
from select.rb:2:in `<main>'
[1] 73732 exit 1 ruby select.rb
```
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
next parent reply other threads:[~2024-04-27 23:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-27 23:21 yamam (Masanari Yamamoto) via ruby-core [this message]
2024-04-30 6:40 ` [ruby-core:117739] [Ruby master Bug#20461] Unreadable pipe included in the readable IO of IO.select yamam (Masanari Yamamoto) via ruby-core
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.issue-20461.20240427232109.53318@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
--cc=noreply@ruby-lang.org \
--cc=ruby-core@ml.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).