misc/64347: Bug in sysv semaphore waiting processes count

Ramy M. Hassan ramy at gawab.com
Tue Mar 16 11:20:09 PST 2004


>Number:         64347
>Category:       misc
>Synopsis:       Bug in sysv semaphore waiting processes count
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 16 11:20:08 PST 2004
>Closed-Date:
>Last-Modified:
>Originator:     Ramy M. Hassan
>Release:        4.9RELEASE
>Organization:
AAST
>Environment:
FreeBSD GawabSRV01.Gawab.com 4.9-RELEASE-p2 FreeBSD 4.9-RELEASE-p2 #0: Tue Mar  2 03:21:19 EET 2004     root at GawabSRV01.Gawab.com:/usr/obj/usr/src/sys/GAWABMAINSMPWFC  i386
>Description:
When a procss is waiting for a semaphore value to be more than zero ( calling semop ) , then receives a signal, the semop() returns -1 and errno is set to EINTR. This is fine, but the problem is that the number of processes waiting for the semaphore is not decremented. So a successive call to semctl(semsetid,semid,GETNCNT,0) will return an incorrect value.
>How-To-Repeat:
Write a program that intializes a semaphore set to zero , then call semop in a loop 

struct sembuf oplist[] = { { 0 , -1 , 0 } };
while ( semop(semid,oplist,1) < 0 ) {
printf("Number of waiting processes %d \n",semctl(semid,prof,GETNCNT));
}

while the process is waiting on the semaphore , send the process any signal that the process can handle. You will see that the number of waiting processes will increment each time a signal is sent which is incorrect.

>Fix:
      
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list