From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from nue.mailmanlists.eu (nue.mailmanlists.eu [IPv6:2a01:4f8:1c0c:6b10::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 8D6DF1F44D for ; Tue, 26 Mar 2024 21:11:12 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; secure) header.d=ml.ruby-lang.org header.i=@ml.ruby-lang.org header.a=rsa-sha256 header.s=mail header.b=ONszDNs3; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=rDa/NRPy; dkim-atps=neutral Received: from nue.mailmanlists.eu (localhost [127.0.0.1]) by nue.mailmanlists.eu (Postfix) with ESMTP id A30BA838C1; Tue, 26 Mar 2024 21:11:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1711487464; bh=Vb6Say/4dsiscyL11+kS5gOIJVqx3Ae0Y1ta/bTIPsI=; h=Date:References:To:Reply-To:Subject:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From:Cc:From; b=ONszDNs3JGekZOKfTdL1EzWMDJSVlb2ny/u1r23KbAF8riD4oinM29wEdue3fL1k+ fQKyLCgvkxtynrkI9XEUUJKkkCFscYGjxz6jzFb0oT+AabwNd5Z0gjayFYiWRMX5EC Vsm4+MHPcYCI5srHOMA/x/83Xz+8BBmxoi348YtE= Received: from s.wrqvtvvn.outbound-mail.sendgrid.net (s.wrqvtvvn.outbound-mail.sendgrid.net [149.72.120.130]) by nue.mailmanlists.eu (Postfix) with ESMTPS id 09AFC838A1 for ; Tue, 26 Mar 2024 21:11:00 +0000 (UTC) Authentication-Results: nue.mailmanlists.eu; dkim=pass (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=rDa/NRPy; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ruby-lang.org; h=from:references:subject:mime-version:content-type: content-transfer-encoding:list-id:to:cc:content-type:from:subject:to; s=s1; bh=Pipa6V8mqeJ1t7xYfqKaJtgLO+GIIR80A+SjB9ZxlTc=; b=rDa/NRPysE/Bgmkf5FIsWdUkofLfdD0WtBUZcjCnN203/ngSkpgqhrPIVa/CJelpg/6/ /ItVMwdhmfvYA2UEvSAxbStBpEBjXxUXQ5iGYhkx6XjuSs6JTbjNAe1dyedSXcJrRYhkiI At8vw5KBhq6YrMbY9+ECNtVJaI8EmhCEhVNw3HSNHNp7or23MpgaXaprB3ja252b6yT0p/ XezKeqch8iJEXZGFvSoB/QtE46LNd9hxpPJCtQaMV+eKpP4kDkdXnUJPeRq4b2WLANKtbp TwUuQ2rKwjHDl9PQFV0BsMGBlujPtBYUEffG73Q4Y1EbVXo6OHFokbgX+qrCTcxA== Received: by filterdrecv-canary-7f5f84b4db-7lnlq with SMTP id filterdrecv-canary-7f5f84b4db-7lnlq-1-660339E3-13 2024-03-26 21:10:59.831472954 +0000 UTC m=+694669.267466986 Received: from herokuapp.com (unknown) by geopod-ismtpd-4 (SG) with ESMTP id RjuY-7f-S6G7epFrKA0zJQ for ; Tue, 26 Mar 2024 21:10:59.780 +0000 (UTC) Date: Tue, 26 Mar 2024 21:10:59 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 20393 X-Redmine-Issue-Author: ioquatix X-Redmine-Issue-Assignee: ioquatix X-Redmine-Issue-Priority: Normal X-Redmine-Sender: ioquatix 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-Redmine-MailingListIntegration-Message-Ids: 93931 X-SG-EID: =?us-ascii?Q?u001=2E3QFJPY5gaRwyNXkncYONHM3OeFnb=2FgeOrLDgg3PYIKrq5rvk81iAipQ1q?= =?us-ascii?Q?cdmuT9o5PIWGjXtTDstodNmslT=2F6xfCuIofWR2K?= =?us-ascii?Q?w8msDgVaVLx=2F2StWJcGhS=2F5z2kK07wu8xBofaK+?= =?us-ascii?Q?YAtslHEcTPINI2OMEF=2Fk2MBJmlQh6mRnkRjNr5Y?= =?us-ascii?Q?NX8M9QYY7lSSOZQs1gwyUe5rjrhegvWZi2064fA?= =?us-ascii?Q?=2FZbkJ9Q09R8Gpi+ah6AxALojFeHgkK4CNiD9p9j?= =?us-ascii?Q?qKyofcdJU=2FVPWXLvmGgArJbwEa=2F7hfgw44G3s=2F7?= =?us-ascii?Q?SgPrKWDI=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: DYMMKU6LHYEVKBIP5XSLXTEQIITQ25VM X-Message-ID-Hash: DYMMKU6LHYEVKBIP5XSLXTEQIITQ25VM X-MailFrom: bounces+313651-b711-ruby-core=ml.ruby-lang.org@em5188.ruby-lang.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list Reply-To: Ruby developers Subject: [ruby-core:117333] [Ruby master Bug#20393] `after_fork_ruby` clears all pending interrupts for both parent and child process. List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "ioquatix (Samuel Williams) via ruby-core" Cc: "ioquatix (Samuel Williams)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #20393 has been updated by ioquatix (Samuel Williams). Status changed from Open to Closed Nobu approved this change on the PR, so I've merged it: https://github.com/ruby/ruby/commit/a7ff264477105b5dc0ade6facad4176a1b73df0b I'll introduce a separate PR to add the test to ruby-spec. ---------------------------------------- Bug #20393: `after_fork_ruby` clears all pending interrupts for both parent and child process. https://bugs.ruby-lang.org/issues/20393#change-107477 * Author: ioquatix (Samuel Williams) * Status: Closed * Assignee: ioquatix (Samuel Williams) * Backport: 3.0: REQUIRED, 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED ---------------------------------------- In the following program, the behaviour of the parent process is affected by whether `Process.fork` is invoked or not. ```ruby Thread.handle_interrupt(RuntimeError => :never) do Thread.current.raise(RuntimeError, "Queued error") puts "Pending interrupt: #{Thread.pending_interrupt?}" # true pid = Process.fork do puts "Pending interrupt (child process): #{Thread.pending_interrupt?}" Thread.handle_interrupt(RuntimeError => :immediate){} end _, status = Process.waitpid2(pid) puts "Child process status: #{status.inspect}" puts "Pending interrupt: #{Thread.pending_interrupt?}" # false end puts "Exiting..." ``` I don't think the parent process pending interrupts should be cleared by `after_fork_ruby`: ```c static void after_fork_ruby(rb_pid_t pid) { rb_threadptr_pending_interrupt_clear(GET_THREAD()); if (pid == 0) { // child clear_pid_cache(); rb_thread_atfork(); } else { // parent after_exec(); } } ``` How about this implementation: ```c static void after_fork_ruby(rb_pid_t pid) { if (pid == 0) { // child rb_threadptr_pending_interrupt_clear(GET_THREAD()); clear_pid_cache(); rb_thread_atfork(); } else { // parent after_exec(); } } ``` cc @ko1 -- 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/