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: AS17314 8.43.84.0/22 X-Spam-Status: No, score=-3.2 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,LOTS_OF_MONEY, MAILING_LIST_MULTI,MONEY_NOHTML,RCVD_IN_DNSWL_MED,RDNS_DYNAMIC, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (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 E16AC1F8C6 for ; Mon, 23 Aug 2021 10:12:47 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B9408385AC3F for ; Mon, 23 Aug 2021 10:12:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B9408385AC3F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1629713566; bh=2rEqsdaatMchLTCSzwZb06NuNck13Z0lqQqFdZ+oCWc=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=hfDWC1GG6dFP0Opp5hA0RaXHLlKUwKfj+AYUy3KgepJUxLSJgLOdnm/8FNv3qNf8j R7ghEvaihScMV9TcqWF0zGMyc31Tg9jltz6y3pgTCLaLYqPCKXFOp8rrTcHdNM03gG Cvoz3ISqQyEKkFGzcmFuH9SkTEMdCdOhbnLhABRw= 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 003EF385C40E for ; Mon, 23 Aug 2021 10:11:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 003EF385C40E 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-231-GoOdkrgjP_6vObaldpb5DQ-1; Mon, 23 Aug 2021 06:11:37 -0400 X-MC-Unique: GoOdkrgjP_6vObaldpb5DQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5B2D2875108; Mon, 23 Aug 2021 10:11:36 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.194.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 821AA60C9F; Mon, 23 Aug 2021 10:11:35 +0000 (UTC) To: Andreas Schwab Subject: Re: Async cacellation and pthread_cleanup_push References: <87zgtxuxa8.fsf@igel.home> <87fsvp9qcz.fsf@oldenburg.str.redhat.com> <87tuk5tcw8.fsf@igel.home> <87fsvp6vis.fsf@oldenburg.str.redhat.com> <87pmuttbyr.fsf@igel.home> <87tujgqywx.fsf@oldenburg.str.redhat.com> <87mtp8scga.fsf@igel.home> Date: Mon, 23 Aug 2021 12:11:33 +0200 In-Reply-To: <87mtp8scga.fsf@igel.home> (Andreas Schwab's message of "Mon, 23 Aug 2021 12:05:41 +0200") Message-ID: <87h7fgqxm2.fsf@oldenburg.str.redhat.com> 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.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: , From: Florian Weimer via Libc-alpha Reply-To: Florian Weimer Cc: libc-alpha@sourceware.org Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" * Andreas Schwab: > On Aug 23 2021, Florian Weimer wrote: > >> * Andreas Schwab: >> >>> On Aug 04 2021, Florian Weimer wrote: >>> >>>> * Andreas Schwab: >>>> >>>>> On Aug 04 2021, Florian Weimer wrote: >>>>> >>>>>> * Andreas Schwab: >>>>>> >>>>>>> Is pthread_cleanup_push supposed to work together with async >>>>>>> cancellation? >>>>>> >>>>>> In our implementation? I think so. >>>>> >>>>> I don't see how that can work with -fexceptions or in C++, though. I= s >>>>> that supported? >>>> >>>> I think it is supposed to work, but it probably is unreliable. >>> >>> Since the compiler puts the exception regions only over function calls >>> (and -fnon-call-exceptions only covers potentially trapping insns in >>> addition) the cleanup region will not be fully covered. >> >> I can see how this can happen in theory =E2=80=A6 > > This is not theory, it happens exactly here. > >>> testcases/open_posix_testsuite/conformance/interfaces/pthread_cancel/3-= 1.c >> >> =E2=80=A6 but I don't see how this applies to this particular test. > > There is a non-zero probability that the cancel signal arrives in > thread_func and sleep_loop while it is executing the unprotected > instructions outside of the .LEHB1 to .LEHE1 region: > > movl $sem, %edi > call sem_post > movq $0, (%rsp) > movq $1000000, 8(%rsp) > .p2align 4,,10 > .p2align 3 > .L2: > xorl %esi, %esi > movq %rsp, %rdi > .LEHB1: > call nanosleep > subl $1, %ebx > jne .L2 > movl $.LC0, %edi > call puts > .LEHE1: Odd. Does this happen because sem_post is annotated with __THROWNL? GCC should ignore __attribute__ ((nothrow)) with -fnon-call-exceptions. Thanks, Florian