NetBSD-Bugs archive

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

kern/53998: sem_init() fails with error -1

>Number:         53998
>Category:       kern
>Synopsis:       sem_init() fails with error -1
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 21 20:10:00 +0000 2019
>Originator:     BERTRAND Joël
>Release:        NetBSD-8 (stable)
NetBSD 8.0_STABLE NetBSD 8.0_STABLE (CUSTOM) #28: Fri Feb  1 14:16:44 CET 2019 amd64

A program I have written (and that perfectly runs under Linux or Solaris) randomly aborts on NetBSD. I have tried to debug and I have found that sem_init() can returns -1 without any reason.

My program use pthread_create() to start several threads. In each thread, I initialize a semaphore with sem_init(). This semaphore is deleted with sem_destroy() just before pthread_exit().

In each thread, I use fork() followed by execve() to launch a shell script.

My last execution stops with :

Interruption 16884 depuis 2 <- 16884th thread !
LAST ERROR: Unknown error: 4294967295 <- errno set by sem_init()
AT librpl_lancement_thread() FROM gestion_threads-conv.c LINE 86

Line 86 is :
if (sem_init(&((*s_etat_processus).semaphore_fork), 0, 0) != 0)

errno -1 is not set by librt (only EINVAL or ENOSPC as this semaphore is not shared).
I don't understand why sem_init() fails (and why with errno -1 !). I suspect a bug in librt or kernel itself.

Best regards,

I can provide my test program if required

Home | Main Index | Thread Index | Old Index