* [ruby-core:95135] [Ruby master Bug#16186] Calling Net::HTTP from within an #inspect implementation hang when invoked from p
[not found] <redmine.issue-16186.20190927223437@ruby-lang.org>
@ 2019-09-27 22:34 ` simonpatp
2019-09-29 16:40 ` [ruby-core:95146] " nobu
2019-09-29 17:31 ` [ruby-core:95147] " nobu
2 siblings, 0 replies; 3+ messages in thread
From: simonpatp @ 2019-09-27 22:34 UTC (permalink / raw)
To: ruby-core
Issue #16186 has been reported by byteit101 (Patrick Plenefisch).
----------------------------------------
Bug #16186: Calling Net::HTTP from within an #inspect implementation hang when invoked from p
https://bugs.ruby-lang.org/issues/16186
* Author: byteit101 (Patrick Plenefisch)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.7.0dev (2019-09-27T18:22:21Z trunk d53cf85474) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Using this script:
``` ruby
require 'net/http'
class Victim
def inspect
puts "before"
Net::HTTP.get('example.com', '/index.html') # this hangs. I haven't tried other network libraries
puts "After"
return "success"
end
end
puts Victim.new.inspect # for some reason this doesn't hang
puts "now we hang"
p Victim.new # but this implicit invocation of inspect does hang. Independent of ordering, and works on JRuby
puts "It worked!"
```
Expected:
```
$ rvm use jruby
$ ruby bug.rb
before
After
success
now we hang
before
After
success
It worked!
$
```
Actual:
```
$ rvm use ruby-head
$ ruby bug.rb
before
After
success
now we hang
before
^C^C^Z
[1] + 13423 suspended ruby bug.rb
$ kill %1
$ (time passes)
Traceback (most recent call last):
11: from bug.rb:12:in `<main>'
10: from bug.rb:12:in `p'
9: from bug.rb:5:in `inspect'
8: from /home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/net/http.rb:458:in `get'
7: from /home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/net/http.rb:476:in `get_response'
6: from /home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/net/http.rb:919:in `start'
5: from /home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/net/http.rb:930:in `do_start'
4: from /home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/net/http.rb:945:in `connect'
3: from /home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/timeout.rb:105:in `timeout'
2: from /home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/timeout.rb:99:in `block in timeout'
1: from /home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/timeout.rb:99:in `ensure in block in timeout'
/home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/timeout.rb:99:in `join': Interrupt
[1] + 13423 interrupt ruby /tmp/rng/koan.rb
$
```
The thing that is surprising to me is the explicit `print` + `inspect` works, whereas a straight `p` hangs.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:95146] [Ruby master Bug#16186] Calling Net::HTTP from within an #inspect implementation hang when invoked from p
[not found] <redmine.issue-16186.20190927223437@ruby-lang.org>
2019-09-27 22:34 ` [ruby-core:95135] [Ruby master Bug#16186] Calling Net::HTTP from within an #inspect implementation hang when invoked from p simonpatp
@ 2019-09-29 16:40 ` nobu
2019-09-29 17:31 ` [ruby-core:95147] " nobu
2 siblings, 0 replies; 3+ messages in thread
From: nobu @ 2019-09-29 16:40 UTC (permalink / raw)
To: ruby-core
Issue #16186 has been updated by nobu (Nobuyoshi Nakada).
As `Kernel#p` is equivalent to `Thread.handle_interrupt(Object => :never) {puts args.map(&:inspect)}`, all interrupts never be invoked.
----------------------------------------
Bug #16186: Calling Net::HTTP from within an #inspect implementation hang when invoked from p
https://bugs.ruby-lang.org/issues/16186#change-81785
* Author: byteit101 (Patrick Plenefisch)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.7.0dev (2019-09-27T18:22:21Z trunk d53cf85474) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Using this script:
``` ruby
require 'net/http'
class Victim
def inspect
puts "before"
Net::HTTP.get('example.com', '/index.html') # this hangs. I haven't tried other network libraries
puts "After"
return "success"
end
end
puts Victim.new.inspect # for some reason this doesn't hang
puts "now we hang"
p Victim.new # but this implicit invocation of inspect does hang. Independent of ordering, and works on JRuby
puts "It worked!"
```
Expected:
```
$ rvm use jruby
$ ruby bug.rb
before
After
success
now we hang
before
After
success
It worked!
$
```
Actual:
```
$ rvm use ruby-head
$ ruby bug.rb
before
After
success
now we hang
before
^C^C^Z
[1] + 13423 suspended ruby bug.rb
$ kill %1
$ (time passes)
Traceback (most recent call last):
11: from bug.rb:12:in `<main>'
10: from bug.rb:12:in `p'
9: from bug.rb:5:in `inspect'
8: from /home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/net/http.rb:458:in `get'
7: from /home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/net/http.rb:476:in `get_response'
6: from /home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/net/http.rb:919:in `start'
5: from /home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/net/http.rb:930:in `do_start'
4: from /home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/net/http.rb:945:in `connect'
3: from /home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/timeout.rb:105:in `timeout'
2: from /home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/timeout.rb:99:in `block in timeout'
1: from /home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/timeout.rb:99:in `ensure in block in timeout'
/home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/timeout.rb:99:in `join': Interrupt
[1] + 13423 interrupt ruby bug.rb
$
```
The thing that is surprising to me is the explicit `print` + `inspect` works, whereas a straight `p` hangs.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:95147] [Ruby master Bug#16186] Calling Net::HTTP from within an #inspect implementation hang when invoked from p
[not found] <redmine.issue-16186.20190927223437@ruby-lang.org>
2019-09-27 22:34 ` [ruby-core:95135] [Ruby master Bug#16186] Calling Net::HTTP from within an #inspect implementation hang when invoked from p simonpatp
2019-09-29 16:40 ` [ruby-core:95146] " nobu
@ 2019-09-29 17:31 ` nobu
2 siblings, 0 replies; 3+ messages in thread
From: nobu @ 2019-09-29 17:31 UTC (permalink / raw)
To: ruby-core
Issue #16186 has been updated by nobu (Nobuyoshi Nakada).
Assignee set to kosaki (Motohiro KOSAKI)
Current implementation is since r38225 (fe6b2e20e9f17ed2c2900aa72994e075ffdc7124).
I think this was discussed in the mailing list (probably ruby-dev), but I can't find it now.
And I think which should be uninterruptible is only printing the argument and a newline.
https://github.com/nobu/ruby/pull/new/bug/16186-allow-interrupts-during-inspect-in-p
----------------------------------------
Bug #16186: Calling Net::HTTP from within an #inspect implementation hang when invoked from p
https://bugs.ruby-lang.org/issues/16186#change-81786
* Author: byteit101 (Patrick Plenefisch)
* Status: Open
* Priority: Normal
* Assignee: kosaki (Motohiro KOSAKI)
* Target version:
* ruby -v: ruby 2.7.0dev (2019-09-27T18:22:21Z trunk d53cf85474) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Using this script:
``` ruby
require 'net/http'
class Victim
def inspect
puts "before"
Net::HTTP.get('example.com', '/index.html') # this hangs. I haven't tried other network libraries
puts "After"
return "success"
end
end
puts Victim.new.inspect # for some reason this doesn't hang
puts "now we hang"
p Victim.new # but this implicit invocation of inspect does hang. Independent of ordering, and works on JRuby
puts "It worked!"
```
Expected:
```
$ rvm use jruby
$ ruby bug.rb
before
After
success
now we hang
before
After
success
It worked!
$
```
Actual:
```
$ rvm use ruby-head
$ ruby bug.rb
before
After
success
now we hang
before
^C^C^Z
[1] + 13423 suspended ruby bug.rb
$ kill %1
$ (time passes)
Traceback (most recent call last):
11: from bug.rb:12:in `<main>'
10: from bug.rb:12:in `p'
9: from bug.rb:5:in `inspect'
8: from /home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/net/http.rb:458:in `get'
7: from /home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/net/http.rb:476:in `get_response'
6: from /home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/net/http.rb:919:in `start'
5: from /home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/net/http.rb:930:in `do_start'
4: from /home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/net/http.rb:945:in `connect'
3: from /home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/timeout.rb:105:in `timeout'
2: from /home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/timeout.rb:99:in `block in timeout'
1: from /home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/timeout.rb:99:in `ensure in block in timeout'
/home/byteit101/.rvm/rubies/ruby-head/lib/ruby/2.7.0/timeout.rb:99:in `join': Interrupt
[1] + 13423 interrupt ruby bug.rb
$
```
The thing that is surprising to me is the explicit `print` + `inspect` works, whereas a straight `p` hangs.
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-09-29 17:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <redmine.issue-16186.20190927223437@ruby-lang.org>
2019-09-27 22:34 ` [ruby-core:95135] [Ruby master Bug#16186] Calling Net::HTTP from within an #inspect implementation hang when invoked from p simonpatp
2019-09-29 16:40 ` [ruby-core:95146] " nobu
2019-09-29 17:31 ` [ruby-core:95147] " nobu
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).