@@ -358,25 +358,33 @@ static int real_main(int argc, tchar **argv);
358
358
359
359
#if defined(_MSC_VER )
360
360
361
- static int show_stack_trace (EXCEPTION_POINTERS * ep )
361
+ static CRITICAL_SECTION lock ;
362
+
363
+ static LONG WINAPI show_stack_trace (EXCEPTION_POINTERS * ep )
362
364
{
363
365
volatile __int64 frame = 0 ;
364
366
EXCEPTION_RECORD * er = ep -> ExceptionRecord ;
365
367
void * exceptionAddress = er ? er -> ExceptionAddress : NULL ;
366
368
int exceptionCode = er ? er -> ExceptionCode : 0 ;
367
- fprintf (stderr , "Native error occurred at %p (%x)\n" ,
368
- exceptionAddress , exceptionCode );
369
- fflush (stderr ); /* not needed but for my mental health */
370
- Sg_DumpNativeStackTrace (ep );
371
- Sg_SanitiseStack (& frame );
372
- /* ok try the caused one*/
373
- if (exceptionAddress )
374
- Sg_ShowAddressFunction (exceptionAddress );
369
+ __try {
370
+ EnterCriticalSection (& lock );
371
+ fprintf (stderr , "Native error occurred at %p (%x)\n" ,
372
+ exceptionAddress , exceptionCode );
373
+ fflush (stderr ); /* not needed but for my mental health */
374
+ Sg_DumpNativeStackTrace (ep );
375
+ Sg_SanitiseStack (& frame );
376
+ /* ok try the caused one*/
377
+ if (exceptionAddress )
378
+ Sg_ShowAddressFunction (exceptionAddress );
379
+ } __finally {
380
+ LeaveCriticalSection (& lock );
381
+ }
375
382
return EXCEPTION_EXECUTE_HANDLER ;
376
383
}
377
384
378
385
int wmain (int argc , tchar * * argv )
379
386
{
387
+ InitializeCriticalSection (& lock );
380
388
SetUnhandledExceptionFilter (show_stack_trace );
381
389
return real_main (argc , argv );
382
390
}
0 commit comments