public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Cupertino Miranda via Libc-alpha <libc-alpha@sourceware.org>
Cc: Cupertino Miranda <cupertino.miranda@oracle.com>,
	 "Jose E. Marchesi" <jose.marchesi@oracle.com>,
	 Elena Zannoni <elena.zannoni@oracle.com>
Subject: Re: [PING] [PATCH v2] Resolve-flockfile-funlockfile-differences
Date: Tue, 05 Sep 2023 10:42:39 +0200	[thread overview]
Message-ID: <878r9l80zk.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <87ilhj3bsp.fsf@oracle.com> (Cupertino Miranda via Libc-alpha's message of "Fri, 06 Jan 2023 15:47:18 +0000")

* Cupertino Miranda via Libc-alpha:

> diff --git a/stdio-common/vfscanf-internal.c b/stdio-common/vfscanf-internal.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_funlockfile, (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 ”fscanf may incorrectly unlock
FSETLOCKING_BYCALLER stream if canceled”.

Please let me know if you can make the adjustments.  I have verified
that the change fixes my test case.

Thanks,
Florian


      parent reply	other threads:[~2023-09-05  8:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-06 15:47 Cupertino Miranda
2023-01-12 15:04 ` Cupertino Miranda
2023-02-13 13:30 ` Florian Weimer
2023-09-04 16:40 ` Florian Weimer
2023-09-05  8:42 ` Florian Weimer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878r9l80zk.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=cupertino.miranda@oracle.com \
    --cc=elena.zannoni@oracle.com \
    --cc=jose.marchesi@oracle.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).