Subject: try/catch and mutithreading
From: Ignasi Villagrasa <[email-masked]>
To: [email-masked]
Date: Thu, 19 Dec 2002 18:09:25 +0000

Hi everyone,

I've got a problem migrating several C++ based server applications from 
Watcom 10.5 compiler to cygwin. The problem arises when diferent threads 
get into a try/catch block concurrently. Then cygwin forces me to 
include a semaphore out of try block to solve a concurrency conflict 
that I didn't have using Watcom 10.5, or I don't have now only avoiding 
the try/catch structure.

Source code

void A()
{

MySemaphore.Request();

try
{

}
catch(...)
{

}
catch(...)
{

}

MySemaphore.Release() ;

return;
}

works properly in multithreading, but

void A()
{

try
{
MySemaphore.Request();

}
catch(...)
{

}
catch(...)
{

}

MySemaphore.Release() ;

return;
}

gives me a concurrent problem.

Obviously without semaphores I get a concurrency error also.

I use here the semaphore in order to investigate where in the code the 
problem arises. Normally I cannot use it because of performance problem.

Here is Cygwin version I'm using:

cygwin  1.3.12-2
gcc                 2.95.3-5
gcc-mingw           3_1-20020516-1

I don't use pthreads emulation in order to maintain compatibility to 
previos versions. So I'm using for multithreading _beginthreadex familly 
funtions, the same that work using Watcom.

Could anyone give me a hint ?

Thanks in advance, Ignasi Villagrasa. GRI S.L.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/