[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
kern/53998: sem_init() fails with error -1
>Synopsis: sem_init() fails with error -1
>Arrival-Date: Thu Feb 21 20:10:00 +0000 2019
>Originator: BERTRAND Joël
>Release: NetBSD-8 (stable)
NetBSD schwarz.systella.fr 8.0_STABLE NetBSD 8.0_STABLE (CUSTOM) #28: Fri Feb 1 14:16:44 CET 2019 root%legendre.systella.fr@localhost:/usr/src/netbsd-8/obj/sys/arch/amd64/compile/CUSTOM 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.
I can provide my test program if required
Main Index |
Thread Index |