ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:102426] [Ruby master Bug#17617] When a Ractor's incoming port is closed, Ractor.receive_if does not raise Ractor::ClosedError, but instead blocks indefinitely
@ 2021-02-09 16:24 dazuma
  2021-09-14  1:40 ` [ruby-core:105233] " mame (Yusuke Endoh)
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: dazuma @ 2021-02-09 16:24 UTC (permalink / raw)
  To: ruby-core

Issue #17617 has been reported by dazuma (Daniel Azuma).

----------------------------------------
Bug #17617: When a Ractor's incoming port is closed, Ractor.receive_if does not raise Ractor::ClosedError, but instead blocks indefinitely
https://bugs.ruby-lang.org/issues/17617

* Author: dazuma (Daniel Azuma)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.1.0dev (2021-02-09T13:22:37Z master e7a831de8e) [x86_64-darwin20]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
If Ractor#close_incoming is called on a Ractor, any pending Ractor.receive call will raise Ractor::ClosedError. However, any pending Ractor.receive_if call will not; instead, it never returns.

```
r1 = Ractor.new do
  Ractor.receive
rescue => e
  e
end
r1.close_incoming
result = r1.take
puts "**** taken: #{result}"  # displays the Ractor::ClosedError

r2 = Ractor.new do
  Ractor.receive_if { true }
  puts "**** never reaches here"
rescue => e
  puts "**** never reaches here"
  e
end
r2.close_incoming
puts "**** hangs here..."
r2.take
puts "**** never reaches here"
```

This was tested against both 3.0.0 and 3.1.0 head, with the same result.

```
% ruby -v
ruby 3.1.0dev (2021-02-09T13:22:37Z master e7a831de8e) [x86_64-darwin20]
```

```
% ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin20
```

I have also tried including sleep statements to force the Ractor.receive_if to execute both before and after the Ractor#close_incoming call. The result is the same either way. receive_if hangs regardless of whether the incoming port is already closed when receive_if is invoked, or whether the port is closed while the receive_if is already blocking.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:105233] [Ruby master Bug#17617] When a Ractor's incoming port is closed, Ractor.receive_if does not raise Ractor::ClosedError, but instead blocks indefinitely
  2021-02-09 16:24 [ruby-core:102426] [Ruby master Bug#17617] When a Ractor's incoming port is closed, Ractor.receive_if does not raise Ractor::ClosedError, but instead blocks indefinitely dazuma
@ 2021-09-14  1:40 ` mame (Yusuke Endoh)
  2023-11-13 21:59 ` [ruby-core:115378] " dazuma (Daniel Azuma) via ruby-core
  2025-06-06 22:46 ` [ruby-core:122489] [Ruby " jhawthorn (John Hawthorn) via ruby-core
  2 siblings, 0 replies; 4+ messages in thread
From: mame (Yusuke Endoh) @ 2021-09-14  1:40 UTC (permalink / raw)
  To: ruby-core

Issue #17617 has been updated by mame (Yusuke Endoh).

Assignee set to ko1 (Koichi Sasada)

----------------------------------------
Bug #17617: When a Ractor's incoming port is closed, Ractor.receive_if does not raise Ractor::ClosedError, but instead blocks indefinitely
https://bugs.ruby-lang.org/issues/17617#change-93641

* Author: dazuma (Daniel Azuma)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* ruby -v: ruby 3.1.0dev (2021-02-09T13:22:37Z master e7a831de8e) [x86_64-darwin20]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
If Ractor#close_incoming is called on a Ractor, any pending Ractor.receive call will raise Ractor::ClosedError. However, any pending Ractor.receive_if call will not; instead, it never returns.

```
r1 = Ractor.new do
  Ractor.receive
rescue => e
  e
end
r1.close_incoming
result = r1.take
puts "**** taken: #{result}"  # displays the Ractor::ClosedError

r2 = Ractor.new do
  Ractor.receive_if { true }
  puts "**** never reaches here"
rescue => e
  puts "**** never reaches here"
  e
end
r2.close_incoming
puts "**** hangs here..."
r2.take
puts "**** never reaches here"
```

This was tested against both 3.0.0 and 3.1.0 head, with the same result.

```
% ruby -v
ruby 3.1.0dev (2021-02-09T13:22:37Z master e7a831de8e) [x86_64-darwin20]
```

```
% ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin20
```

I have also tried including sleep statements to force the Ractor.receive_if to execute both before and after the Ractor#close_incoming call. The result is the same either way. receive_if hangs regardless of whether the incoming port is already closed when receive_if is invoked, or whether the port is closed while the receive_if is already blocking.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:115378] [Ruby master Bug#17617] When a Ractor's incoming port is closed, Ractor.receive_if does not raise Ractor::ClosedError, but instead blocks indefinitely
  2021-02-09 16:24 [ruby-core:102426] [Ruby master Bug#17617] When a Ractor's incoming port is closed, Ractor.receive_if does not raise Ractor::ClosedError, but instead blocks indefinitely dazuma
  2021-09-14  1:40 ` [ruby-core:105233] " mame (Yusuke Endoh)
@ 2023-11-13 21:59 ` dazuma (Daniel Azuma) via ruby-core
  2025-06-06 22:46 ` [ruby-core:122489] [Ruby " jhawthorn (John Hawthorn) via ruby-core
  2 siblings, 0 replies; 4+ messages in thread
From: dazuma (Daniel Azuma) via ruby-core @ 2023-11-13 21:59 UTC (permalink / raw)
  To: ruby-core; +Cc: dazuma (Daniel Azuma)

Issue #17617 has been updated by dazuma (Daniel Azuma).

ruby -v changed from ruby 3.1.0dev (2021-02-09T13:22:37Z master e7a831de8e) [x86_64-darwin20] to ruby 3.3.0dev (2023-11-13T21:00:10Z master e8ab3f7010) [x86_64-darwin23]

Retested, still reproduces on 3.2.2 and 3.3.0-dev as of 2023 Nov 13.

----------------------------------------
Bug #17617: When a Ractor's incoming port is closed, Ractor.receive_if does not raise Ractor::ClosedError, but instead blocks indefinitely
https://bugs.ruby-lang.org/issues/17617#change-105313

* Author: dazuma (Daniel Azuma)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* ruby -v: ruby 3.3.0dev (2023-11-13T21:00:10Z master e8ab3f7010) [x86_64-darwin23]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
If Ractor#close_incoming is called on a Ractor, any pending Ractor.receive call will raise Ractor::ClosedError. However, any pending Ractor.receive_if call will not; instead, it never returns.

```
r1 = Ractor.new do
  Ractor.receive
rescue => e
  e
end
r1.close_incoming
result = r1.take
puts "**** taken: #{result}"  # displays the Ractor::ClosedError

r2 = Ractor.new do
  Ractor.receive_if { true }
  puts "**** never reaches here"
rescue => e
  puts "**** never reaches here"
  e
end
r2.close_incoming
puts "**** hangs here..."
r2.take
puts "**** never reaches here"
```

This was tested against both 3.0.0 and 3.1.0 head, with the same result.

```
% ruby -v
ruby 3.1.0dev (2021-02-09T13:22:37Z master e7a831de8e) [x86_64-darwin20]
```

```
% ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin20
```

I have also tried including sleep statements to force the Ractor.receive_if to execute both before and after the Ractor#close_incoming call. The result is the same either way. receive_if hangs regardless of whether the incoming port is already closed when receive_if is invoked, or whether the port is closed while the receive_if is already blocking.




-- 
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/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:122489] [Ruby Bug#17617] When a Ractor's incoming port is closed, Ractor.receive_if does not raise Ractor::ClosedError, but instead blocks indefinitely
  2021-02-09 16:24 [ruby-core:102426] [Ruby master Bug#17617] When a Ractor's incoming port is closed, Ractor.receive_if does not raise Ractor::ClosedError, but instead blocks indefinitely dazuma
  2021-09-14  1:40 ` [ruby-core:105233] " mame (Yusuke Endoh)
  2023-11-13 21:59 ` [ruby-core:115378] " dazuma (Daniel Azuma) via ruby-core
@ 2025-06-06 22:46 ` jhawthorn (John Hawthorn) via ruby-core
  2 siblings, 0 replies; 4+ messages in thread
From: jhawthorn (John Hawthorn) via ruby-core @ 2025-06-06 22:46 UTC (permalink / raw)
  To: ruby-core; +Cc: jhawthorn (John Hawthorn)

Issue #17617 has been updated by jhawthorn (John Hawthorn).

Status changed from Assigned to Closed

`receive_if` has been removed with the introduction of `Ractor::Port`, so this should no longer be an issue

----------------------------------------
Bug #17617: When a Ractor's incoming port is closed, Ractor.receive_if does not raise Ractor::ClosedError, but instead blocks indefinitely
https://bugs.ruby-lang.org/issues/17617#change-113678

* Author: dazuma (Daniel Azuma)
* Status: Closed
* Assignee: ractor
* ruby -v: ruby 3.3.0dev (2023-11-13T21:00:10Z master e8ab3f7010) [x86_64-darwin23]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
If Ractor#close_incoming is called on a Ractor, any pending Ractor.receive call will raise Ractor::ClosedError. However, any pending Ractor.receive_if call will not; instead, it never returns.

```
r1 = Ractor.new do
  Ractor.receive
rescue => e
  e
end
r1.close_incoming
result = r1.take
puts "**** taken: #{result}"  # displays the Ractor::ClosedError

r2 = Ractor.new do
  Ractor.receive_if { true }
  puts "**** never reaches here"
rescue => e
  puts "**** never reaches here"
  e
end
r2.close_incoming
puts "**** hangs here..."
r2.take
puts "**** never reaches here"
```

This was tested against both 3.0.0 and 3.1.0 head, with the same result.

```
% ruby -v
ruby 3.1.0dev (2021-02-09T13:22:37Z master e7a831de8e) [x86_64-darwin20]
```

```
% ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin20
```

I have also tried including sleep statements to force the Ractor.receive_if to execute both before and after the Ractor#close_incoming call. The result is the same either way. receive_if hangs regardless of whether the incoming port is already closed when receive_if is invoked, or whether the port is closed while the receive_if is already blocking.




-- 
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/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-06-06 22:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-09 16:24 [ruby-core:102426] [Ruby master Bug#17617] When a Ractor's incoming port is closed, Ractor.receive_if does not raise Ractor::ClosedError, but instead blocks indefinitely dazuma
2021-09-14  1:40 ` [ruby-core:105233] " mame (Yusuke Endoh)
2023-11-13 21:59 ` [ruby-core:115378] " dazuma (Daniel Azuma) via ruby-core
2025-06-06 22:46 ` [ruby-core:122489] [Ruby " jhawthorn (John Hawthorn) via ruby-core

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 NNTP newsgroup(s).