Fix a problem where several threads throwing exceptions could cause an abort().

This makes the infamous "This application has requested the Runtime to terminate it in an unusual way" message to go away.
This commit is contained in:
Konstantin Isakov 2010-06-03 00:55:07 +04:00
parent 67ca2ee1dd
commit c33fa2c9cc

13
main.cc
View file

@ -19,6 +19,19 @@
int main( int argc, char ** argv )
{
// The following clause fixes a race in the MinGW runtime where throwing
// exceptions for the first time in several threads simultaneously can cause
// an abort(). This code throws first exception in a safe, single-threaded
// manner, thus avoiding that race.
{
class Dummy {};
try
{ throw Dummy(); }
catch( Dummy )
{}
}
if ( argc == 3 && strcmp( argv[ 1 ], "--show-error-file" ) == 0 )
{
// The program has crashed -- show a message about it