NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/53273: sem_init() with pshared=1 does not actually work



>Number:         53273
>Category:       lib
>Synopsis:       sem_init() with pshared=1 does not actually work
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu May 10 02:45:00 +0000 2018
>Originator:     SODA Noriyuki
>Release:        NetBSD 7.1.2
>Organization:
the NetBSD project
>Environment:
System: NetBSD alec 7.1.2 NetBSD 7.1.2 (GENERIC.201803151611Z) amd64
Architecture: x86_64
Machine: amd64
>Description:

if sem_t is created by sem_init(*, 1, *), the sem_t has to be sharable
between processes, even if the processes don't share virtual memory space.
but our implemention doesn't satisfy this requirement.

>How-To-Repeat:

maya@ found this problem by trying to enable the multi-process feature
of recent firefox.

>Fix:

change the definition of sem_t from an opaque pointer to an actual struct
just like other UNIXes.
e.g.

Solaris 9:
typedef struct {
	/* this structure must be the same as sema_t in <synch.h> */
	uint32_t	sem_count;	/* semaphore count */
	uint16_t	sem_type;
	uint16_t	sem_magic;
	upad64_t	sem_pad1[3];	/* reserved for a mutex_t */
	upad64_t 	sem_pad2[2];	/* reserved for a cond_t */
}	sem_t;


FreeBSD-current:
struct _sem {
	__uint32_t	_magic;
	struct _usem2	_kern;
	__uint32_t	_padding;	/* Preserve structure size */
};
typedef	struct _sem	sem_t;


Linux:
typedef union
{
  char __size[__SIZEOF_SEM_T];
  long int __align;
} sem_t;

>Unformatted:
 -current has same problem, too


Home | Main Index | Thread Index | Old Index