mailing list of musl libc
 help / color / mirror / 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

mailing list of musl libc

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/musl

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 musl musl/ http://inbox.vuxu.org/musl \
		musl@inbox.vuxu.org
	public-inbox-index musl

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.musl


code repositories for the project(s) associated with this inbox:

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

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git