www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/07/22/20:23:35

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Wed, 22 Jul 2009 20:23:12 -0400
From: Christopher Faylor <cgf-use-the-mailinglist-please AT cygwin DOT com>
To: cygwin AT cygwin DOT 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 AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <20090722200521 DOT zftez7gasggsk0gw AT webmail DOT mit DOT edu>
MIME-Version: 1.0
In-Reply-To: <20090722200521.zftez7gasggsk0gw@webmail.mit.edu>
User-Agent: Mutt/1.5.20 (2009-06-14)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
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

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

- Raw text -


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