This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Possible race in SYSV IPC (semaphores)


On Oct 26 14:36, Lavrentiev, Anton (NIH/NLM/NCBI) [C] wrote:
> Hi,
> 
> For now, I can only report the observed (mis) behavior of SYSV semop() call,
> which (on the client side) gets manifested as the following:
> 
> transport_layer_pipes::connect: lost connection to cygserver, error = 2
> 
> (this code then does a by-hand adjustment with semctl(SETVAL)).
> 
> Note that there is a dedicated cygserver process running for my single-threaded
> application.
> 
> Looking at the debugging output of cygserver, this is what I see in the log
> (around the only time semctl() is logged there):
> 
> cygserver: /home/corinna/src/cygwin/cygwin-1.7.15/cygwin-1.7.15-1/src/cygwin-1.7.15/winsup/cygserver/transport_pipes.cc, line 132: Try to create named pipe: \\.\pipe\cygwin-13a7ed34cc1953a9-lpc
> cygserver: /home/corinna/src/cygwin/cygwin-1.7.15/cygwin-1.7.15-1/src/cygwin-1.7.15/winsup/cygserver/transport_pipes.cc, line 132: Try to create named pipe: \\.\pipe\cygwin-13a7ed34cc1953a9-lpc
> 
> Note the double pipe creation call, and only a single "exit" log line such as:
> cygserver: /home/corinna/src/cygwin/cygwin-1.7.15/cygwin-1.7.15-1/src/cygwin-1.7.15/winsup/cygserver/sem.cc, line 81: leaving (3416)

That's normal, AFAICS.  Look into cygserver.cc, method
server_submission_loop::request_loop().  It calls _transport->accept()
in a loop.  _transport->accept always prints the "Try to create" log
message.  Every time a client connects, it will return, the cleint
request is put into the request queue, and then the loop returns to
call _transport->accept().  So you see this log message one more time
than clients have connected up to that point in time.

> Cygserver does not stop (also, since SIGSYS is set to ignore in the program,
> it also keeps running -- although, not always quite successfully once the semop()
> failure occurred.)
> 
> The semaphore operations are very intensive; and involve arrays of 5 sems at
> some times;  also, there are quite large chunks of shmem updated every now
> and then.
> 
> I studied the source of cygserver, and noticed that pipe_instance (transport_pipes.cc)
> is not declared "volatile".  This is strange because the compiler can rearrange lines
> of code that include this variable, otherwise.  And that seems rather critical.

You could build cygserver with the variable set to volatile and see if
it changes anything.  But I doubt it.

> Right now what I observe, is that SYSV IPC is unreliable, and I'm yet to figure
> out why;

For testing it would be most helpful if you would create a STC.  Ideally
it would be the shortest possible code which allows to reproduce the issue.

Other than that, is it possible that you just stumble over a restriction
in the sizes of the IPC objects?  Did you try to tweak /etc/cygserver.conf
for a start?


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]