From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id CDC013858C1F for ; Tue, 5 Sep 2023 08:42:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CDC013858C1F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693903365; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sVQ1OCwW1enWMRo8qlZe7Kd0g7xELTMKfJkaQUgdAYE=; b=cwYg5I9eNUk0z92VFV1ccBgpaRFRxW4CPxrasj4Hobh5XjXy02DILVya1CX8FTdNbvkanq pzGgoS1Gk9oMXT405nSEpjta012eLO65OOZ8hH5fh0RmyqAyfLsEYQWgSC4IiN0SB9ZFGn NIRA2ggpKSmsRyxvMtBhsIqq8LsjJqA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-19-fxYYCKoLPwyhCOLEoGj-iw-1; Tue, 05 Sep 2023 04:42:42 -0400 X-MC-Unique: fxYYCKoLPwyhCOLEoGj-iw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 968F19423C9; Tue, 5 Sep 2023 08:42:41 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E0C1F2026D4B; Tue, 5 Sep 2023 08:42:40 +0000 (UTC) From: Florian Weimer To: Cupertino Miranda via Libc-alpha Cc: Cupertino Miranda , "Jose E. Marchesi" , Elena Zannoni Subject: Re: [PING] [PATCH v2] Resolve-flockfile-funlockfile-differences References: <87ilhj3bsp.fsf@oracle.com> Date: Tue, 05 Sep 2023 10:42:39 +0200 In-Reply-To: <87ilhj3bsp.fsf@oracle.com> (Cupertino Miranda via Libc-alpha's message of "Fri, 06 Jan 2023 15:47:18 +0000") Message-ID: <878r9l80zk.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: * Cupertino Miranda via Libc-alpha: > diff --git a/stdio-common/vfscanf-internal.c b/stdio-common/vfscanf-inter= nal.c > index 2ad34050f3..5b55db962b 100644 > --- a/stdio-common/vfscanf-internal.c > +++ b/stdio-common/vfscanf-internal.c > @@ -177,11 +177,15 @@ > return EOF; = \ > } = \ > } while (0) > + > +static inline void checked_IO_funlockfile(FILE *s); > +static inline void checked_IO_flockfile(FILE *s); > + > #define LOCK_STREAM(S) = \ > - __libc_cleanup_region_start (1, (void (*) (void *)) &_IO_funlockfile, = (S)); \ > - _IO_flockfile (S) > + __libc_cleanup_region_start (1, (void (*) (void *)) &checked_IO_funloc= kfile, (S)); \ > + checked_IO_flockfile (S) > #define UNLOCK_STREAM(S) = \ > - _IO_funlockfile (S); = \ > + checked_IO_funlockfile (S); = \ > __libc_cleanup_region_end (0) > > struct ptrs_to_free > @@ -197,6 +201,18 @@ struct char_buffer { > struct scratch_buffer scratch; > }; > > +static inline void > +checked_IO_funlockfile(FILE *s) > +{ > + _IO_funlockfile (s); > +} > + > +static inline void > +checked_IO_flockfile(FILE *s) > +{ > + _IO_flockfile (s); > +} A couple of suggestions: We only need a wrapper for funlockfile. We should avoid the forward declaration. I think we can keep calling _IO_funlockfile on the no-cancel path. The wrapper function should have the correct type, so that the (technically undefined) cast in __libc_cleanup_region_start is no longer needed. Please file a bug, with a summary like =E2=80=9Dfscanf may incorrectly unlo= ck FSETLOCKING_BYCALLER stream if canceled=E2=80=9D. Please let me know if you can make the adjustments. I have verified that the change fixes my test case. Thanks, Florian