cygserver blocking on semctl(SETVAL)

Ethan Tira-Thompson
Thu Aug 24 22:54:00 GMT 2006

I have a piece of code:
void SemaphoreManager::setValue(semid_t id, int x) const {
	semun params;
	cout << "SEMCTL..." << flush;
	if(semctl(semid,id,SETVAL,params)<0) {
		perror("ERROR: SemaphoreManager::setValue (semctl)");
	cout << "done" << endl;

This is part of a function which gets called a number of times  
throughout the life of the program.  It works just fine up until one  
particular call (with x=0) which reliably causes it to block between  
the two cout's.  Not just my program either -- all IPC is blocked at  
this point.  So bringing up new cygwin windows, running ipcs, etc.,  
all hang.  Once I kill any one process in the group that are using  
the semaphore, it seems to jump start things a bit and may run a bit  
more, but usually eventually blocks again until all of the processes  
are killed.

My code runs fine under Linux and Mac OS X, it's only now that we're  
nearing release that I'm testing under cygwin and finding something  
has gone wrong in the past 9 months or so -- either something updated  
on your end, or a change in our code tickling an unknown issue.

The kicker to note here -- is there any reason a *SETVAL* operation  
could cause a block???  It should either go through or return an  
error.  I'm fairly convinced it's *not* this particular semctl call  
that's *causing* the block, it just gets hung up because some  
previous operation has blocked cygserver, and it's that operation  
that's causing the trouble.

One nuisance is that when I run cygserver with -d, it doesn't block  
in the same place -- something about all that debugging output  
changes the race conditions.  In any case, I've attached the  
cygserver output leading up to a block, in hopes it means something  
to you.

Thanks for taking a look -- I'm afraid I'm stumped.  (doesn't help  
gdb only reports '??' for all function calls when I attach to a  
process, so I can't tell what any of my code is doing.  And yes, I do  
have -g enabled)


This trace corresponds to the activity between entering a command in  
my program to move to a new runlevel, and the block that occurs in  
that runlevel.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cygserverout.txt
URL: <>

More information about the Cygwin-developers mailing list