Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Yousong Zhou <yszhou4tech@gmail.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Fix invalid sigprocmask call
Date: Fri, 24 Mar 2017 12:55:00 -0000	[thread overview]
Message-ID: <39f28782-65e8-0f52-3c8f-134a6f05788b@redhat.com> (raw)
In-Reply-To: <CAECwjAgARveAhY=8e8J6Bcv+5=W=YnGcLY9G9Dv1sEnkNePVZA@mail.gmail.com>

On 03/24/2017 12:23 PM, Yousong Zhou wrote:
> On 24 March 2017 at 18:47, Pedro Alves <palves@redhat.com> wrote:
>> On 03/24/2017 03:01 AM, Yousong Zhou wrote:
>>> The POSIX document says
>>>
>>>     The pthread_sigmask() and sigprocmask() functions shall fail if:
>>>
>>>     [EINVAL]
>>>     The value of the how argument is not equal to one of the defined values.
>>>
>>> and this is how musl-libc is currently doing.  Fix the call to be safe
>>> and correct
>>>
>>>  [1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_sigmask.html
>>>
>>
>> I don't agree.  It's a musl bug.  Please fix it / file a musl bug.
> 
> I already did that before sending to gdb-patches
> 
>   http://www.openwall.com/lists/musl/2017/03/24/1
> 
> I am aware of the fact that the current code works with glibc and mac
> osx 10.11.6.  The Linux kernel code at the moment also accepts the
> call with how==0

Cool.

> 
> But this is more about interpretation of POSIX document itself.  And
> it says, clearly without pre-condition words or ambiguity in the
> ERRORS section of that page, to return EINVAL if how is not equal to
> one of the defined values.

The standard wasn't built on a vacuum.  It starts by ratifying common
implementation behavior.  If no historical implementation behaves like what
you're suggesting, what's the point of enforcing that, when it's clearly
NOT the intent?  You're just causing porting pain for no good reason.
Please file a bug against the standard to have the error section clarified instead.

> 
> I also tried to find some posix-compliant testsuite and to search the
> github code for samples of pthread_sigmask call.  The first I came
> across was the following code snippet at link
> https://github.com/juj/posixtestsuite/blob/master/conformance/interfaces/pthread_sigmask/8-1.c#L57
> 
>         pthread_sigmask(SIG_BLOCK, NULL, &oactl);

The fact that that call includes SIG_BLOCK doesn't say whether
passing 0 should be rejected.

So I cloned that repo, and did a quick grep.  And lo:

https://github.com/juj/posixtestsuite/blob/26372421f53aeeeeeb4b23561c417886f1930ef6/conformance/interfaces/fork/12-1.c#L187

		/* Examine the current blocked signal set. USR1 & USR2 shall be present */
		ret = sigprocmask( 0, NULL, &mask );

		if ( ret != 0 )
		{
			UNRESOLVED( errno, "Sigprocmask failed in child" );
		}

Thanks,
Pedro Alves


  parent reply	other threads:[~2017-03-24 12:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1490324519-11228-1-git-send-email-yszhou4tech@gmail.com>
2017-03-24 10:47 ` Pedro Alves
2017-03-24 12:24   ` Yousong Zhou
2017-03-24 12:39     ` Yousong Zhou
2017-03-24 12:58       ` Pedro Alves
2017-03-24 12:55     ` Pedro Alves [this message]
2017-03-24 13:05       ` Yousong Zhou
2017-03-24 13:37         ` Pedro Alves
2017-03-25  0:36           ` Yousong Zhou
2017-03-24 15:35         ` [musl] " Rich Felker
2017-03-24 15:52           ` Pedro Alves
2017-03-24 16:41             ` Rich Felker
2017-03-24 17:34           ` Andreas Schwab
2017-03-24 18:15             ` Rich Felker

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=39f28782-65e8-0f52-3c8f-134a6f05788b@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=yszhou4tech@gmail.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