From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 34A4C1F463 for ; Sun, 29 Sep 2019 16:40:16 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 31A0B120995; Mon, 30 Sep 2019 01:40:08 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 0D5CE12099A for ; Mon, 30 Sep 2019 01:40:04 +0900 (JST) Received: by filter0142p3mdw1.sendgrid.net with SMTP id filter0142p3mdw1-17004-5D90DE61-11 2019-09-29 16:40:01.172251665 +0000 UTC m=+233272.305489780 Received: from herokuapp.com (unknown [18.215.234.148]) by ismtpd0039p1iad1.sendgrid.net (SG) with ESMTP id JBgnHJR9Qe2-U4LKUhqv-A for ; Sun, 29 Sep 2019 16:40:00.991 +0000 (UTC) Date: Sun, 29 Sep 2019 16:40:01 +0000 (UTC) From: nobu@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 70701 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 16186 X-Redmine-Issue-Author: byteit101 X-Redmine-Sender: nobu X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?q8Dly+pU2+3ektTtZVXgZtbJPXwqo7p86jCsvYTW4Bzzhu1bv0BkX5ObZViRPv?= =?us-ascii?Q?ML+GPVXEH9L5uIRXaxcfdeGChxJddAVfpmL2OVM?= =?us-ascii?Q?=2Fv45Wcn+rK7Gwd67QA5LxG=2FGKqkFbpugQqiphWV?= =?us-ascii?Q?DFX5MJyqTBpAjFKlobnfJ2cvA3JWW+eTYqu=2Fzvd?= =?us-ascii?Q?G8bK2STU87V4y1=2Fm6pLNc7v24ct0Jt0DYIw=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 95146 Subject: [ruby-core:95146] [Ruby master Bug#16186] Calling Net::HTTP from within an #inspect implementation hang when invoked from p X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "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 `
' 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/