delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/04/22/04:18:40

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-Id: <5.1.0.14.0.20050422082920.01fa45d0@10.10.10.100>
X-Sender: jeff AT 10 DOT 10 DOT 10 DOT 100
Date: Fri, 22 Apr 2005 09:17:03 +0100
To: cygwin AT cygwin DOT com
From: Jeff Terrell <jeff AT kc DOT com>
Subject: Multi-threaded application using STL crashes
Mime-Version: 1.0
X-IsSubscribed: yes

--=======412425FB=======
Content-Type: text/plain; x-avg-checked=avg-ok-5D117CA8; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 8bit

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.


--=======412425FB=======
Content-Type: text/plain; charset=us-ascii

--
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/
--=======412425FB=======--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019