History

win64: make signal handlers work somewhat

we can register a top-level exception filter which does nothing else than call into _XcptFilter (provided by the default C runtime environment) and signal handlers for the few POSIX signals that Windows can handle start working (that includes e.g. SEGV).

Michael Matz committed 7 years ago

Commit c16dadb1 parent 10510712 files · +21 −0Browse files

Unified · Split

2 files
  1. win32/lib/crt1.c +11 −0
  2. win32/lib/wincrt1.c +10 −0
win32/lib/crt1.c+11−0
@@ -4,6 +4,7 @@ · 3 unmodified lines
4// _UNICODE for tchar.h, UNICODE for API4// _UNICODE for tchar.h, UNICODE for API
5#include <tchar.h>5#include <tchar.h>
6 6
7#include <windows.h>
7#include <stdio.h>8#include <stdio.h>
8#include <stdlib.h>9#include <stdlib.h>
9 10
@@ -37,9 +38,19 @@ extern int _tmain(int argc, _TCHAR * argv[], _TCHAR * env[]); · 27 unmodified lines
37/* Allow command-line globbing with "int _dowildcard = 1;" in the user source */38/* Allow command-line globbing with "int _dowildcard = 1;" in the user source */
38int _dowildcard;39int _dowildcard;
39 40
41#ifdef __x86_64__
42static LONG WINAPI catch_sig(EXCEPTION_POINTERS *ex)
43{
44 return _XcptFilter(ex->ExceptionRecord->ExceptionCode, ex);
45}
46#endif
47
40void _tstart(void)48void _tstart(void)
41{49{
42 __TRY__50 __TRY__
51#ifdef __x86_64__
52 SetUnhandledExceptionFilter(catch_sig);
53#endif
43 _startupinfo start_info = {0};54 _startupinfo start_info = {0};
44 55
45 // Sets the current application type56 // Sets the current application type
win32/lib/wincrt1.c+10−0
@@ -26,6 +26,13 @@ int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int); · 25 unmodified lines
26typedef struct { int newmode; } _startupinfo;26typedef struct { int newmode; } _startupinfo;
27int __cdecl __tgetmainargs(int *pargc, _TCHAR ***pargv, _TCHAR ***penv, int globb, _startupinfo*);27int __cdecl __tgetmainargs(int *pargc, _TCHAR ***pargv, _TCHAR ***penv, int globb, _startupinfo*);
28 28
29#ifdef __x86_64__
30static LONG WINAPI catch_sig(EXCEPTION_POINTERS *ex)
31{
32 return _XcptFilter(ex->ExceptionRecord->ExceptionCode, ex);
33}
34#endif
35
29static int go_winmain(TCHAR *arg1)36static int go_winmain(TCHAR *arg1)
30{37{
31 STARTUPINFO si;38 STARTUPINFO si;
@@ -54,6 +61,9 @@ static int go_winmain(TCHAR *arg1) · 22 unmodified lines
54int _twinstart(void)61int _twinstart(void)
55{62{
56 __TRY__63 __TRY__
64#ifdef __x86_64__
65 SetUnhandledExceptionFilter(catch_sig);
66#endif
57 _startupinfo start_info_con = {0};67 _startupinfo start_info_con = {0};
58 __set_app_type(__GUI_APP);68 __set_app_type(__GUI_APP);
59 __tgetmainargs(&__argc, &__targv, &_tenviron, 0, &start_info_con);69 __tgetmainargs(&__argc, &__targv, &_tenviron, 0, &start_info_con);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t