From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11182 Path: news.gmane.org!.POSTED!not-for-mail From: Yousong Zhou Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] pthread_sigmask: check 'how' only when 'set' is not NULL Date: Fri, 24 Mar 2017 10:14:02 +0800 Message-ID: References: <1490185183-17680-1-git-send-email-yszhou4tech@gmail.com> <20170322124921.GE17319@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1490321679 16023 195.159.176.226 (24 Mar 2017 02:14:39 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 24 Mar 2017 02:14:39 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-11197-gllmg-musl=m.gmane.org@lists.openwall.com Fri Mar 24 03:14:34 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1crEkK-0003XW-RN for gllmg-musl@m.gmane.org; Fri, 24 Mar 2017 03:14:32 +0100 Original-Received: (qmail 30341 invoked by uid 550); 24 Mar 2017 02:14:35 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 30315 invoked from network); 24 Mar 2017 02:14:35 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=cmnORXEog3YXkqF810onCtHJ0XO49M4aTaCPG31HFdU=; b=fVWNJcpTYmbFCknYMSptL5RQSQp0Ym1q7h5kVoUVdXKg5ZvcTHiD6y8GJp1kDrRDOm DrbX9IJe5uRHRJ9faLNFhu6pGwatLN6WFQldkqxzOle+m2VoMqajQV8n5emQblBW1Pyz hZn8aAWixHKmDx7i84M5l31uvvwW1JbonQprSpiXhgmxqNUVr9MCGS51QEeD/e2Eyg97 vTyNq4gRdQEFDoYdsMwg8k/oiz0wsPJBNXagAZwhr4po6ZKNjtr/LE/hBvzJfC2imsS5 8ngJNtp3cO3aiUvqd4j/ZHz6mulA8uU7455Df6LPwpn9sjjuJO6rzZ+o0abeD3J7yCpV 78/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=cmnORXEog3YXkqF810onCtHJ0XO49M4aTaCPG31HFdU=; b=RfmA8SQmr/wnV/9BdYAvYZYRRe+1ejXlJRTmAj4J8e8VEOgjF2EPce0Ss+PXzeRXzO Se8EbyBBlsuE4RHpvPR+d67HSPq2kg7bS1ybwleUFQruRnsMra55qMkNi9Sz+0yq3tbQ L28Jr0F91YWNg+TL8UZoGxFvrpIsWSt73XUElhDbOIPI00KnYzKyJo/SmgIZFBxKtaPl 7WCPAmDMcoBEMV7uMIx+uUZIOv+gxsuNPrk6VAsCldqGhfyTFFBoNKMYcwXeUNw5cHy7 a9yNKaTWBVpwQRhlsCk/GxdQulZFP1WqSHtEEWbo0eLQd92vjZzGNsORnwQv2RVMB9ck KCPw== X-Gm-Message-State: AFeK/H2bEhi1tZP7kK1i/6INZFkBh/+cKgerQISE6CGXgGniyERR/Ja9M6GH+Cg79q0FmUTekbucB1gaU1VICw== X-Received: by 10.55.66.65 with SMTP id p62mr4978764qka.191.1490321663028; Thu, 23 Mar 2017 19:14:23 -0700 (PDT) In-Reply-To: <20170322124921.GE17319@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:11182 Archived-At: On 22 March 2017 at 20:49, Rich Felker wrote: > On Wed, Mar 22, 2017 at 08:19:43PM +0800, Yousong Zhou wrote: >> According to POSIX document >> >> If set is a null pointer, the value of the argument how is not >> significant and the thread's signal mask shall be unchanged; thus >> the call can be used to enquire about currently blocked signals. >> >> This is also how the current Linux kernel syscall is doing. So the >> following function call from binutils-gdb should not fail >> >> sigprocmask (0, NULL, &original_signal_mask); >> --- >> src/thread/pthread_sigmask.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/src/thread/pthread_sigmask.c b/src/thread/pthread_sigmask.c >> index 88c333f..f188782 100644 >> --- a/src/thread/pthread_sigmask.c >> +++ b/src/thread/pthread_sigmask.c >> @@ -5,7 +5,7 @@ >> int pthread_sigmask(int how, const sigset_t *restrict set, sigset_t *restrict old) >> { >> int ret; >> - if ((unsigned)how - SIG_BLOCK > 2U) return EINVAL; >> + if (set && (unsigned)how - SIG_BLOCK > 2U) return EINVAL; >> ret = -__syscall(SYS_rt_sigprocmask, how, set, old, _NSIG/8); >> if (!ret && old) { >> if (sizeof old->__bits[0] == 8) { >> -- >> 2.6.4 > > I don't think this change is conforming. There is a requirement to > produce an error ("shall fail") independent of whether the set > argument is a null pointer: > > 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. > > http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_sigmask.html > > If gdb is calling it with an invalid argument (rather, one that's > conditionally invalid depending on the platform's definitions of the > how macros), a patch should be sent to gdb to fix it. > > Rich I think you are right in the interpretation of POSIX document on this topic. I missed the "shall fail" part in ERRORS section. But it came to me that darwin was thought to be a certificated POSIX-compliant environment, so I just ran tested that pthread_sigmask call on my osx 10.11.6 and it worked without error. https://en.wikipedia.org/wiki/Darwin_(operating_system) I will patch gdb anyway, to be correct. Regards, yousong