mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] bug: sem_close always unmaps semaphore regardless of ref count
@ 2020-10-28 20:11 Rich Felker
  2020-10-28 20:18 ` Rich Felker
  0 siblings, 1 reply; 3+ messages in thread
From: Rich Felker @ 2020-10-28 20:11 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 198 bytes --]

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

[-- Attachment #2: sem_close.c --]
[-- Type: text/plain, Size: 218 bytes --]

#include <semaphore.h>

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);
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [musl] bug: sem_close always unmaps semaphore regardless of ref count
  2020-10-28 20:11 [musl] bug: sem_close always unmaps semaphore regardless of ref count Rich Felker
@ 2020-10-28 20:18 ` Rich Felker
  2020-10-28 22:01   ` Szabolcs Nagy
  0 siblings, 1 reply; 3+ messages in thread
From: Rich Felker @ 2020-10-28 20:18 UTC (permalink / raw)
  To: musl

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 <semaphore.h>
> 
> 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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [musl] bug: sem_close always unmaps semaphore regardless of ref count
  2020-10-28 20:18 ` Rich Felker
@ 2020-10-28 22:01   ` Szabolcs Nagy
  0 siblings, 0 replies; 3+ messages in thread
From: Szabolcs Nagy @ 2020-10-28 22:01 UTC (permalink / raw)
  To: Rich Felker; +Cc: musl

* Rich Felker <dalias@libc.org> [2020-10-28 16:18:16 -0400]:
> 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 <semaphore.h>
> > 
> > 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.

i added this to libc-test
thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-28 22:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-28 20:11 [musl] bug: sem_close always unmaps semaphore regardless of ref count Rich Felker
2020-10-28 20:18 ` Rich Felker
2020-10-28 22:01   ` Szabolcs Nagy

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).