From patchwork Mon Sep 6 12:33:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 44857 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A30813839409 for ; Mon, 6 Sep 2021 12:34:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A30813839409 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1630931672; bh=9A5mxojTwi/TO+h9XKlN7T2+w2pHTVCgRc5djqGNNe4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=qdGFJPrX8JhTtSZAwukDm10+03+uiCEyNXggGjI40rYM0XK499uCAgHBcpL0gTbxz Jqzy6iytlIDozk8tAvnRQjNkBGJg9jFklpSlL4pI937uEGtl/q5VAG9YzpuiX6u+Qm ITB2KZ0bNYOgBbJoRaoDasOuAcaYL81wVh/ZhGxs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 288033857014 for ; Mon, 6 Sep 2021 12:33:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 288033857014 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-551-KAFd5h5qMqWPC0VYmgvJkg-1; Mon, 06 Sep 2021 08:33:54 -0400 X-MC-Unique: KAFd5h5qMqWPC0VYmgvJkg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 050BA6D581 for ; Mon, 6 Sep 2021 12:33:54 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.194.140]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5DD1D6EA2C for ; Mon, 6 Sep 2021 12:33:53 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH v3 0/2] Fix pthread_cancel, pthread_kill race (bug 12889) X-From-Line: 360490024b83370b3f18258694b00165827d5a05 Mon Sep 17 00:00:00 2001 Message-Id: Date: Mon, 06 Sep 2021 14:33:51 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" This is a repost of the previous series, with an internal (futex-based) lock and separate flag in struct pthread. __pthread_call_with_tid is gone (it's inlined into __pthread_kill_internal). This is the version I propose to backport to glibc 2.34. I think it should go into the main branch as well, unless Adhemerval's larger series is committed first. I had to fix a defect in the tst-pthread_kill-exiting. The sending threads were not signaled in all cases, leading to a deadlock. Thanks, Florian Florian Weimer (2): nptl: pthread_kill, pthread_cancel should not fail after exit (bug 19193) nptl: Fix race between pthread_kill and thread exit (bug 12889) nptl/allocatestack.c | 3 + nptl/descr.h | 6 + nptl/pthread_cancel.c | 9 +- nptl/pthread_create.c | 14 ++ nptl/pthread_kill.c | 60 ++++++--- sysdeps/pthread/Makefile | 7 +- sysdeps/pthread/tst-kill4.c | 89 ------------- sysdeps/pthread/tst-pthread_cancel-exited.c | 45 +++++++ .../pthread/tst-pthread_cancel-select-loop.c | 87 +++++++++++++ sysdeps/pthread/tst-pthread_kill-exited.c | 46 +++++++ sysdeps/pthread/tst-pthread_kill-exiting.c | 123 ++++++++++++++++++ 11 files changed, 375 insertions(+), 114 deletions(-) delete mode 100644 sysdeps/pthread/tst-kill4.c create mode 100644 sysdeps/pthread/tst-pthread_cancel-exited.c create mode 100644 sysdeps/pthread/tst-pthread_cancel-select-loop.c create mode 100644 sysdeps/pthread/tst-pthread_kill-exited.c create mode 100644 sysdeps/pthread/tst-pthread_kill-exiting.c