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]

Multi-threaded application using STL crashes


Hi,

I'm developing a multi-threaded application that makes extensive use of STL.

The number of threads is configurable.

If I build the application to run in one thread, it's fine. However, if I build the
application to run in 2 or more threads, it crashes in an unpredictable manner.


I'm taking all the usual safeguards to protect shared resources (semaphores,
critical sections etc), although I'm not building the application any differently
from the way that I build single-threaded applications - I'm not aware that I
have to.


I've worked around some crashes, e.g.

1.  I've replaced one use of std::vector with a proprietary solution because
the application kept crashing in vector::resize().

2.  I've had to add a call to vector::reserve() in another use of vector before
making calls to vector::push_back(), to prevent the application from
crashing.

The fundamental questions I'd like to ask are:

1. Are there problems with using STL in multi-threaded applications.

2. Do I have to build multi-threaded applications in a particular way.

Many thanks in anticipation.

Here are the details of my platform:

> uname -a
CYGWIN_NT-5.1 Tesla 1.5.11(0.116/4/2) 2004-09-04 23:17 i686 unknown unknown Cygwin


> g++ --version
g++ (GCC) 3.3.3 (cygwin special)
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Regards,
Jeff.

--
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]