This is the mail archive of the cygwin@cygwin.com 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: Serious problem with win32 pthreads crashing and c++ class


Hi Ross,

I'm using the Cygwin tool-chain and use the cygwin G++ (3.3.1 cygming
special) to compile, hence ending up with the unix emulation layer.
I don't use mingw32 cause of my porting requirements to *nixs.

I've made the attr variable global within the class in its private section,
however the crash still occurs. the pthread_t variable is also global and
has been from the start (inside the Thread class's private section)

I've tried compiling with the following libs:
 -lpthread
 -mthreads

In both cases the test case still crashes nearly immediately now since i've
put that attr modification as you adivsed. Its seems to me that the crash
occurs when the first thread completes its execution, i'm not sure if it
crashes before it hits the destructor or when the method passed to created
pthread ends.

To me there seems to be a really serious issue with running phtreads-win32,
If there is anything more i can do, please let me know, I'm updating the
test-case code to take in a command line paramter for the maximum number of
threads you would like to be created before you want the program to exit.
Also I'm going to add a simple CTRL+C capture via signaling so that if you
don't pass an argument it will just run forever either until you press
ctrl+c or run out of electricity.


Regards



Arash



PS: could you please tell me if this is a fixable problem in the near future, or something that maybe a long-term fix?



My last response to this was brief because I had to go somewhere. Even memory leaks don't acount for the crashing (I note you have 1GB RAM), should not have gotten worse. First, a couple of minor things: - make 'attr' a global. - initialise it once at process start, and delete it when the process exits.. You only need one of these, not one for every thread start.

Pthreads-win32 re-uses pthread_t handles rather than free them and
alloc new ones each time. There are no memory leaks that I'm aware
of, or been reported and not fixed, in the library as it is now.
There's a test in the test suite called reuse2.c which creates 10000
threads, which run immediately and complete almost immediately. This
is similar to what your sample test does (but not using C++
wrappers), and it runs fine.

Are you compiling with the '-mthreads' flag?

-mthreads Support thread-safe exception handling on Mingw32.
Code that relies on thread-safe exception handling must compile and
link all code with the -mthreads option.
When compiling,-mthreads defines -D_MT; when linking, it links in
a special thread helper library -lmingwthrd which cleans up per thread
exception handling data.

Ross



_________________________________________________________________
Get less junk mail with ninemsn Premium. Click here http://ninemsn.com.au/premium/landing.asp



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


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