Skip to content

Commit 3a07c63

Browse files
committed
Fixing complation error on x86
1 parent 364c361 commit 3a07c63

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

src/main.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -358,25 +358,33 @@ static int real_main(int argc, tchar **argv);
358358

359359
#if defined(_MSC_VER)
360360

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)
362364
{
363365
volatile __int64 frame = 0;
364366
EXCEPTION_RECORD *er = ep->ExceptionRecord;
365367
void *exceptionAddress = er? er->ExceptionAddress: NULL;
366368
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+
}
375382
return EXCEPTION_EXECUTE_HANDLER;
376383
}
377384

378385
int wmain(int argc, tchar **argv)
379386
{
387+
InitializeCriticalSection(&lock);
380388
SetUnhandledExceptionFilter(show_stack_trace);
381389
return real_main(argc, argv);
382390
}

src/os/win/thread.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ typedef struct ThreadParams
9090
void *arg;
9191
} ThreadParams;
9292

93-
static unsigned int __stdcall win32_thread_entry_innter(void *params)
93+
static unsigned int __stdcall win32_thread_entry_inner(void *params)
9494
{
9595
volatile ThreadParams *threadParams = (ThreadParams *)params;
9696
SgThreadEntryFunc *start;
@@ -117,7 +117,7 @@ static unsigned int __stdcall win32_thread_entry(void *params)
117117
{
118118
unsigned int status;
119119
SgInternalThread *me = ((ThreadParams *)params)->me;
120-
status = win32_thread_entry_innter(params);
120+
status = win32_thread_entry_inner(params);
121121
/* clear the stackBase, from now on, thread can't be terminated */
122122
me->stackBase = 0;
123123
return status;

0 commit comments

Comments
 (0)