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=-2.8 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_PASS shortcircuit=no autolearn=no 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 EB66420248 for ; Wed, 6 Mar 2019 13:20:51 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id B70B4121A30; Wed, 6 Mar 2019 22:20:47 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id 1C4281216AA for ; Wed, 6 Mar 2019 22:20:45 +0900 (JST) Received: by filter0090p3iad2.sendgrid.net with SMTP id filter0090p3iad2-4470-5C7FC92D-25 2019-03-06 13:20:45.593171786 +0000 UTC m=+66369.878389536 Received: from herokuapp.com (unknown [34.204.10.139]) by ismtpd0027p1iad2.sendgrid.net (SG) with ESMTP id ERZbt6XLSPqtMoxyFpGLmA for ; Wed, 06 Mar 2019 13:20:45.563 +0000 (UTC) Date: Wed, 06 Mar 2019 13:20:45 +0000 (UTC) From: kimmo.lehto@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 67153 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15644 X-Redmine-Issue-Author: kke X-Redmine-Sender: kke 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?uzb5OtJTcS8YkZPFqpyVChJjadJHV+GHsFHgSjmJp9J0oldM2837KHkc=2Fj=2FZB2?= =?us-ascii?Q?k88g3D03=2F3TXgpKPq7OLSsKrVPDtXDvf+sEvIxf?= =?us-ascii?Q?YDEzHyiiJSrpJuaCi96ZmePGzR2AT1FbH0nJkPX?= =?us-ascii?Q?AeXIW4Nu0eLAfKI2J+J1pdq8jo0NP2m=2FGqbq8ES?= =?us-ascii?Q?AB=2F24dO4Tz20YlXKT+T9ikFSjrVq36sPDMw=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 91703 Subject: [ruby-core:91703] [Ruby trunk Bug#15644] ThreadsWait problems with Thread#report_on_exception 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 #15644 has been reported by kke (Kimmo Lehto). ---------------------------------------- Bug #15644: ThreadsWait problems with Thread#report_on_exception https://bugs.ruby-lang.org/issues/15644 * Author: kke (Kimmo Lehto) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin18] * Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- ThreadsWait spawns a new thread for waiting on a thread: ``` # thwait.rb:87 def join_nowait(*threads) threads.flatten! @threads.concat threads for th in threads Thread.start(th) do |t| begin t.join ensure @wait_queue.push t end end end end ``` As `thread.join` raises the exception from the thread, it will trigger a thread exception report. If the thread was using `report_on_exception = false`, the wait thread will report the exception anyway. If the thread was using `report_on_exception = true`, both threads will report the exception. I think this could be fixed by always setting `report_on_exception = false` for the wait thread. # Example 1 ``` require 'thwait' thread = Thread.new do Thread.current.report_on_exception = false raise "Foo" end ThreadsWait.all_waits(thread) do |terminated_thread| puts "Thread #{terminated_thread} terminated" end ``` ## Expected result No exception reports ## Actual result The wait thread will report the exception # Example 2 ``` require 'thwait' thread = Thread.new do raise "Foo" end ThreadsWait.all_waits(thread) do |terminated_thread| puts "Thread #{terminated_thread} terminated" end ``` ## Expected result One exception report ## Actual result Two exception reports -- https://bugs.ruby-lang.org/