From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11184 Path: news.gmane.org!.POSTED!not-for-mail From: Yousong Zhou Newsgroups: gmane.comp.gdb.patches,gmane.linux.lib.musl.general Subject: Re: [PATCH] Fix invalid sigprocmask call Date: Fri, 24 Mar 2017 21:05:15 +0800 Message-ID: References: <1490324519-11228-1-git-send-email-yszhou4tech@gmail.com> <2b0bab84-e36e-e109-5444-dc84369dddce@redhat.com> <39f28782-65e8-0f52-3c8f-134a6f05788b@redhat.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1490360748 6026 195.159.176.226 (24 Mar 2017 13:05:48 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 24 Mar 2017 13:05:48 +0000 (UTC) Cc: gdb-patches@sourceware.org, musl@lists.openwall.com, Rich Felker To: Pedro Alves Original-X-From: gdb-patches-return-137794-gdb-gdb-patches=m.gmane.org@sourceware.org Fri Mar 24 14:05:40 2017 Return-path: Envelope-to: gdb-gdb-patches@m.gmane.org Original-Received: from server1.sourceware.org ([209.132.180.131] helo=sourceware.org) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1crOuO-0000Tz-Q0 for gdb-gdb-patches@m.gmane.org; Fri, 24 Mar 2017 14:05:37 +0100 DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; q=dns; s=default; b=dyni 01N6z02bSs4nozhg0PFWCWlP3cnYLEahTEE21gQ4ARCT6TnhCWkiRqPzmVK3OKPm XTTMgqNw0C2YTsErIXszl8jOYP/BmiufTULTnMNCHdxfVFzuDwELBOw1QUA0Quv6 QTtfB7afrzccdqd+To3YPoD1z2eLbGgMG2xrD+8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; s=default; bh=t670Z5/Rfm Lj+171IatBUxKpVEk=; b=uJ4i7YXlckuCpK5fe7Ykd1iFyYgiAoEsy10l1ItQaC B/UtyPTkdIBWKYmPFV+8UQRXm3CF9LG7UT6uB4swLXgYRIenwswLSuX86bj4puTk OBauXFubXR4p7c1C45FystwDs2+lbjqv3tDnMf/cUuajv5qJ3Cpl9E3d5epqNXP8 s= Original-Received: (qmail 78286 invoked by alias); 24 Mar 2017 13:05:39 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Original-Sender: gdb-patches-owner@sourceware.org Original-Received: (qmail 78275 invoked by uid 89); 24 Mar 2017 13:05:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-HELO: mail-qt0-f194.google.com Original-Received: from mail-qt0-f194.google.com (HELO mail-qt0-f194.google.com) (209.85.216.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 24 Mar 2017 13:05:37 +0000 Original-Received: by mail-qt0-f194.google.com with SMTP id x35so266014qtc.1 for ; Fri, 24 Mar 2017 06:05:38 -0700 (PDT) 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:cc; bh=v9ysOTEcl2KAmTHIglZjVNBkiILHwsq+/LLtrj7Fis8=; b=ceX+iI2sRDtb49zVpBo9BcSFxNXM0WSV6nQ/+ZGxvccfTLqYrVBi/b9VJI84LqtOTR U67WNDi4hyoxHzJa3a7zZDgNmkLINL2/DR5SU2uZdXNKWg+UC1D8Zm+UgjzFpRvpwvWu daKYA6eZ8BlSYHBWnttpXp7bg2bA/2deYx/PKYnujXJc5ZdooMxFR/bG/kFZtSMdsTvs XQG8/IZ0xWRHPs++lUA0/G5CeWzJneVTSOPKj8kdulcQu29clI0QiLEz1F5Sk+FkOP3E RcOqU2+Qs87VgRCRP5VIS55dDDsqNQlmlmAagBtKzIwUQdreI6PGnrUuJ1bstAu8Vcu8 msTw== X-Gm-Message-State: AFeK/H3GNJpCZtJlgq7N9lRc0OPbuljymmoszfR3D5gx1baQXfR0M3VbkTUC54rddobtr2SYBKgVxIoizgkJSQ== X-Received: by 10.200.43.185 with SMTP id m54mr7510802qtm.122.1490360736606; Fri, 24 Mar 2017 06:05:36 -0700 (PDT) Original-Received: by 10.200.39.162 with HTTP; Fri, 24 Mar 2017 06:05:15 -0700 (PDT) In-Reply-To: <39f28782-65e8-0f52-3c8f-134a6f05788b@redhat.com> Xref: news.gmane.org gmane.comp.gdb.patches:122750 gmane.linux.lib.musl.general:11184 Archived-At: On 24 March 2017 at 20:55, Pedro Alves wrote: > On 03/24/2017 12:23 PM, Yousong Zhou wrote: >> On 24 March 2017 at 18:47, Pedro Alves 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. Lol, now I will consider the idea of bumping the door of POSIX committee ;) > >> >> 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 > Okay, then another fact that the posixtestsuite project also expects to accept how==0 I am cc-ing musl-libc list now. Regards, yousong