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 18641 invoked from network); 28 Oct 2020 20:11:20 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 28 Oct 2020 20:11:20 -0000 Received: (qmail 24421 invoked by uid 550); 28 Oct 2020 20:11:17 -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 24388 invoked from network); 28 Oct 2020 20:11:17 -0000 Date: Wed, 28 Oct 2020 16:11:05 -0400 From: Rich Felker To: musl@lists.openwall.com Message-ID: <20201028201104.GH534@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="XIiC+We3v3zHqZ6Z" Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Subject: [musl] bug: sem_close always unmaps semaphore regardless of ref count --XIiC+We3v3zHqZ6Z Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --XIiC+We3v3zHqZ6Z Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="sem_close.c" #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); } --XIiC+We3v3zHqZ6Z--