threads/70975: unexpected and unreliable behaviour when using SYSV semaphore, fork and pipe

Maarten L. Hekkelman m.hekkelman at cmbi.kun.nl
Wed Aug 25 23:10:23 PDT 2004


>Number:         70975
>Category:       threads
>Synopsis:       unexpected and unreliable behaviour when using SYSV semaphore, fork and pipe
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-threads
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Aug 26 06:10:22 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Maarten L. Hekkelman
>Release:        5.2.1-RELEASE-p8
>Organization:
Radboud Universiteit Nijmegen, Afd. CMBI
>Environment:
FreeBSD cmbidb1.cmbi.kun.nl 5.2.1-RELEASE-p8 FreeBSD 5.2.1-RELEASE-p8 #6: Thu Aug 19 08:19:25 CEST 2004     root at cmbidb1.cmbi.kun.nl:/usr/obj/usr/src/sys/MY_KERNEL  i386
>Description:
I have some code that works fine on IRIX and Linux but fails on FreeBSD. What I do is start a number of threads (using pthreads) that each create a pipe and fork/exec a subprocess to read from using the pipe.

The problem is that either the code blocks on reading from the pipe, even when O_NONBLOCK is set. Or the semaphore created with semget fails when I try to call semop with it after a number of times. I'm using this semaphore to limit the number of running threads. The error code after semop fails is always "Interrupted system call".

As noted before, the code works fine on other OS's Linux and IRIX. I believe it used to work in FreeBSD 4.6 but I'm not sure, it doesn't work with 4.9.
>How-To-Repeat:
Source code for an app showing this behaviour can be found at http://www.hekkelman.com/~maarten/test.cpp

Run the app with two parameters, the first is the number of threads to use and the second is the number of subprocesses to spawn. 
>Fix:
      
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-threads mailing list