public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Torvald Riegel <triegel@redhat.com>
To: Szabolcs Nagy <szabolcs.nagy@arm.com>
Cc: Adhemerval Zanella <adhemerval.zanella@linaro.org>,
	nd@arm.com, libc-alpha@sourceware.org
Subject: Re: [PATCH v7] getrandom system call wrapper [BZ #17252]
Date: Fri, 18 Nov 2016 14:21:00 -0000	[thread overview]
Message-ID: <1479478867.7146.1167.camel@localhost.localdomain> (raw)
In-Reply-To: <582EBBB5.80309@arm.com>

On Fri, 2016-11-18 at 08:28 +0000, Szabolcs Nagy wrote:
> On 17/11/16 12:52, Torvald Riegel wrote:
> > On Wed, 2016-11-16 at 17:52 -0200, Adhemerval Zanella wrote:
> >>
> >> On 16/11/2016 16:02, Torvald Riegel wrote:
> >>> On Wed, 2016-11-16 at 16:52 +0100, Florian Weimer wrote:
> >>>> On 11/16/2016 04:20 PM, Zack Weinberg wrote:
> >>>>> On 11/16/2016 10:11 AM, Florian Weimer wrote:
> >>>>>> On 11/14/2016 07:29 PM, Zack Weinberg wrote:
> >>>>>>> On 11/14/2016 12:44 PM, Florian Weimer wrote:
> >>>>>>>> This patch switches back to the ssize_t return time.  This goes against
> >>>>>>>> Theodore Ts'o preference, but seems to reflect the consensus from the
> >>>>>>>> largery community.
> >>>>>>>
> >>>>>>> I still don't think this function should be a cancellation point.
> >>>>>>
> >>>>>> I guess we'll have to agree to disagree on this matter.
> >>>>>
> >>>>> I am seriously considering escalating my disagreement here to a formal
> >>>>> objection.  I would like to know why you think it is NECESSARY - not
> >>>>> merely convenient or consistent with other stuff - for this function to
> >>>>> be a cancellation point.
> >>>>
> >>>> It's necessary if you ever want to cancel a hanging getrandom in a 
> >>>> context where you cannot install a signal handler (so that you can 
> >>>> trigger EINTR when getrandom is stuck).
> >>>
> >>> I think it would be better to split the getrandom that is a cancellation
> >>> point into two functions, getrandom (not a cancellation point) and
> >>> getrandom_cancelable (is a cancellation point).  This way, the
> >>> functionality is available for programs but requires explicit opt-in,
> >>> while the default is not going to lead to surprises in the expected
> >>> common case (ie, when randomness is available).  I don't think the
> >>> opt-in is a problem because as you said, cancellation requires careful
> >>> programming anyway.
> >>>
> >>
> >> I would advise against adding another symbol, it only adds complexity
> >> and most likely one interface would be preferable from application
> >> point of view.
> > 
> > We could add a parameter too that determines whether it is a
> > cancellation point.  That avoids your concern about adding another
> 
> why?
> 
> use pthread_setcancelstate.
> 
> works with all cancellation points not just getrandom.

As discussed in the thread, there are different opinions about what the
default should be.  There are reasonable arguments for both options.  In
such a case, it seems better to make the choice explicit, simply from an
ease-of-use and interface design perspective.  This is not about whether
it's possible for users to do (they could build their own syscall
wrappers after all too, right? ;) ) but about clean interfaces.

With your proposal, one could argue that, for example, every library has
to be aware of cancellation and how it works if one of the clients of
the library could want to use cancellation; the library either has to
disable it explicitly, or it has to document which additional
cancellation points exist and has to implement the cleanup handlers.
This is error-prone and adds complexity to those use cases.  Therefore,
it seems better to avoid that potential source of bugs and either make
the default to not support cancellation (ie, an opt-in for the
cancellation facility), or make at least make the choice explicit for
users of getrandom (ie, two functions or an additional parameter).

  reply	other threads:[~2016-11-18 14:21 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-10 21:03 [PATCH] Add getrandom implementation " Florian Weimer
2016-06-10 21:31 ` Joseph Myers
2016-06-10 21:36   ` Joseph Myers
2016-06-10 22:00   ` Paul Eggert
2016-06-10 22:06     ` Joseph Myers
2016-06-11 11:13   ` Florian Weimer
2016-06-11 20:10     ` Paul Eggert
2016-06-10 22:15 ` Roland McGrath
2016-06-10 22:40   ` Joseph Myers
2016-06-10 22:45     ` Roland McGrath
2016-06-23 17:21   ` Florian Weimer
2016-06-25 21:58     ` Paul Eggert
2016-09-02 22:23     ` Roland McGrath
2016-06-27 15:07 ` [PATCH v2] " Florian Weimer
2016-06-30  9:33   ` Rical Jasan
2016-09-08  9:53     ` Florian Weimer
2016-09-08 10:13       ` Andreas Schwab
2016-09-08 10:28         ` Florian Weimer
2016-09-08 11:58       ` Rical Jasan
2016-09-08 12:36         ` Florian Weimer
2016-06-30 12:03   ` Zack Weinberg
2016-07-13 13:10     ` Nikos Mavrogiannopoulos
2016-11-14 17:45 ` [PATCH v7] getrandom system call wrapper " Florian Weimer
2016-11-14 18:29   ` Zack Weinberg
2016-11-15 20:57     ` Richard Henderson
2016-11-16 15:11     ` Florian Weimer
2016-11-16 15:20       ` Zack Weinberg
2016-11-16 15:52         ` Florian Weimer
2016-11-16 16:41           ` Zack Weinberg
2016-11-17 13:02             ` Florian Weimer
2016-11-17 13:46               ` Zack Weinberg
2016-11-17 13:50                 ` Florian Weimer
2016-11-17 13:56                   ` Zack Weinberg
2016-11-17 15:24                     ` Florian Weimer
2016-11-17 17:16                       ` Zack Weinberg
2016-11-18 10:27                         ` Szabolcs Nagy
2016-11-18 15:46                           ` Torvald Riegel
2016-11-18 18:50                           ` Zack Weinberg
2016-11-21 16:57                             ` Torvald Riegel
2016-11-21 17:12                               ` Zack Weinberg
2016-11-21 17:30                                 ` Torvald Riegel
2016-11-21 17:34                                   ` Florian Weimer
2016-11-29  8:24                             ` Florian Weimer
2016-11-16 18:02           ` Torvald Riegel
2016-11-16 19:53             ` Adhemerval Zanella
2016-11-17 12:52               ` Torvald Riegel
2016-11-18  8:28                 ` Szabolcs Nagy
2016-11-18 14:21                   ` Torvald Riegel [this message]
2016-11-18 15:13                     ` Florian Weimer
2016-11-18 16:04                       ` Torvald Riegel
2016-11-29  8:16                         ` Florian Weimer
2016-11-29 13:56                           ` Torvald Riegel
2016-11-29 14:40                             ` Florian Weimer
2016-11-29 15:23                               ` Torvald Riegel
2016-11-29 15:32                                 ` Florian Weimer
2016-11-29 15:54                                   ` Zack Weinberg
2016-11-29 17:53                                     ` Paul Eggert
2016-11-29 18:11                                       ` Florian Weimer
2016-11-29 19:37                                         ` Paul Eggert
2016-11-30  6:09                                           ` Florian Weimer
2016-11-17  6:21   ` Mike Frysinger
2016-11-18 13:21     ` Florian Weimer

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=1479478867.7146.1167.camel@localhost.localdomain \
    --to=triegel@redhat.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    --cc=nd@arm.com \
    --cc=szabolcs.nagy@arm.com \
    /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).