From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 51036 invoked by alias); 24 Mar 2017 10:47:13 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 50882 invoked by uid 89); 24 Mar 2017 10:47:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=UD:pt, books, edition, ved X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 24 Mar 2017 10:47:11 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 986E38123D; Fri, 24 Mar 2017 10:47:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 986E38123D Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 986E38123D Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC1BB17143; Fri, 24 Mar 2017 10:47:11 +0000 (UTC) Subject: Re: [PATCH] Fix invalid sigprocmask call To: Yousong Zhou , gdb-patches@sourceware.org References: <1490324519-11228-1-git-send-email-yszhou4tech@gmail.com> From: Pedro Alves Message-ID: <2b0bab84-e36e-e109-5444-dc84369dddce@redhat.com> Date: Fri, 24 Mar 2017 10:47:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1490324519-11228-1-git-send-email-yszhou4tech@gmail.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-03/txt/msg00431.txt.bz2 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. Note that that document also says (emphasis mine): If the argument set is not a null pointer, it points to a set of signals to be used to CHANGE the currently blocked set. The argument how indicates the way in which the set is CHANGED, and the application shall ensure it consists of one of the following values: So the requirement to pass in one of SIG_BLOCK/SIG_SETMASK/SIG_UNBLOCK only applies when we're CHANGING the set. The Linux man pages also say (emphasis mine): If set is NULL, then the signal mask is unchanged (i.e., how is IGNORED), but the current value of the signal mask is nevertheless returned in oldset (if it is not NULL). And this is AFAIK the historical Unix behavior. For example, "Advanced Programming in the UNIX Environment, 3rd edition" says the same, and explicitly gives such an example (section 10.13, page 347). See: https://books.google.pt/books?id=kCTMFpEcIOwC&pg=PA347&lpg=PA347&dq=sigprocmask+with+0+how&source=bl&ots=zvMvUNTumH&sig=u3b_iklV_mOcZRt0mNKkbj3dRFU&hl=en&sa=X&ved=0ahUKEwjl5b_Q9u7SAhUEPhQKHVsBCrM4ChDoAQguMAU#v=onepage&q=sigprocmask%20with%200%20how&f=false Thanks, Pedro Alves