pthread_join() problem

David Stacey drstacey@tiscali.co.uk
Sun Jun 2 22:01:00 GMT 2013


I'm trying to get Poco[1] working under Cygwin, and have hit a problem 
with the way it manages its threads. A short example (attached) shows 
what's going on.

Poco creates a global object that is used for managing various threads. 
In the destructor, the class calls pthread_join() to wait for the 
threads to finish. This works in Fedora (and presumably other Linux 
variants), but under Cygwin this call never returns. Note that the 
object is global, and so pthread_join() is being called after main() has 
returned and the global variables are being mopped up.

In the attached example, the problem only exists if the 
'thread_container' object is global. When run in this way, 
pthread_join() never returns and the programme locks up. If 
'thread_container' is moved local to main() then the programme works 
correctly. Sadly, I can't make such a trivial fix to the Poco code, 
which rather relies on this object being global.

The attached example (and indeed Poco) runs fine under Fedora 18 x64, 
but locks up on Cygwin (32-bit; haven't tried 64-bit). Problem exists 
with a vanilla cygwin-1.7.18-1 and the most recent snapshot (2013-06-02).

Any insight you could provide in this matter would be much appreciated - 
many thanks in advance for your help.

Dave.

[1] http://pocoproject.org/


-------------- next part --------------
A non-text attachment was scrubbed...
Name: testcase.cpp
Type: text/x-c++src
Size: 1677 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20130602/b9ddba85/attachment.bin>
-------------- next part --------------
--
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


More information about the Cygwin mailing list