X-Recipient: archive-cygwin@delorie.com
X-Spam-Check-By: sourceware.org
Date: Wed, 22 Jul 2009 20:23:12 -0400
From: Christopher Faylor <cgf-use-the-mailinglist-please@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: (g++) program crashes when I throw an exception in a separate  thread
Message-ID: <20090723002312.GC14746@ednor.casa.cgf.cx>
Reply-To: cygwin@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
References: <20090722200521.zftez7gasggsk0gw@webmail.mit.edu>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20090722200521.zftez7gasggsk0gw@webmail.mit.edu>
User-Agent: Mutt/1.5.20 (2009-06-14)
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

On Wed, Jul 22, 2009 at 08:05:21PM -0400, Joshua John Bialkowski wrote:
>I've spent the entire day scouring the internet for a solution to my problem, so
>I apologize if this has already been answered. If that is the case a pointer in
>the right direction would be appreciated.
>[snip]
>#include <iostream>
>using std::cout;
>
>#include <sstream>
>using std::stringstream;
>
>#include <string>
>using std::string;
>
>#include <windows.h>
>#include <process.h>
>
>
>void throwAnException() throw(int)
>{
>    throw 5;
>}
>
>
>unsigned int __stdcall threadProc( void*  ptr )
>{
>    int             id      =    *((int *)ptr);
>    stringstream    msgStrm (stringstream::in|stringstream::out);
>    msgStrm << "Thread " << id << " says hello\n";
>    string          message = msgStrm.str();
>
>    for(int i=0; i < 30; i++)
>    {
>        cout << message;
>        cout.flush();
>        Sleep(100);
>    }
>
>    try
>    {
>        throwAnException();
>    }
>    catch(int e)
>    {
>        cout << "caught: " << e << "\n";
>        cout.flush();
>    }
>
>    return 0;
>}
>
>
>
>
>int main()
>{
>    int nThreads = 3;
>
>    int *nums = new int[nThreads];
>
>    for(int i=0; i<nThreads; i++)
>    {
>        nums[i] = i;
>        _beginthreadex( 0, 0, threadProc, nums+i, 0, 0 );
>    }
>
>    cout << "main thread exiting\n";
>    cout.flush();
>
>    Sleep(10000);
>
>    cout << "main thread exiting\n";
>    cout.flush();
>
>    return 0;
>
>}

It looks like you're using pure windows code here, i.e., this would
be a mingw, "gcc -mno-cygwin" program.  We don't support that here.
You might try the mingw mailing list for support.

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

