From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 19605 invoked from network); 28 Oct 2020 20:18:32 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 28 Oct 2020 20:18:32 -0000 Received: (qmail 30333 invoked by uid 550); 28 Oct 2020 20:18:28 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 30315 invoked from network); 28 Oct 2020 20:18:28 -0000 Date: Wed, 28 Oct 2020 16:18:16 -0400 From: Rich Felker To: musl@lists.openwall.com Message-ID: <20201028201815.GI534@brightrain.aerifal.cx> References: <20201028201104.GH534@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201028201104.GH534@brightrain.aerifal.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] bug: sem_close always unmaps semaphore regardless of ref count On Wed, Oct 28, 2020 at 04:11:05PM -0400, Rich Felker wrote: > I found this while reading the code during review of lock usage for > MT-fork. Test case attached (can be adapted for libc-test regression > tests, I think, or improved to be a conformance test). > > Rich > #include > > int main() > { > char buf[] = "mysemXXXXXX"; > if (!mktemp(buf)) return 1; > sem_t *sem = sem_open(buf, O_CREAT|O_EXCL, 0600); > sem_open(buf, 0); > sem_unlink(buf); > sem_close(sem); > sem_post(sem); > } Fixed in f70375df85d26235a45e74559afd69be59e5ff99.