changed SEH exception handling on windows (fix stack overflow/access violation reports)
@@ -434,11 +434,11 @@ DEFINE_PRIM(_DYN, call_method, _DYN _ARR);
DEFINE_PRIM(_BOOL, is_prim_loaded, _DYN);
#if defined(HL_VCC) && !defined(HL_XBO)
-static int throw_handler( int code ) {
- switch( code ) {
+static LONG CALLBACK global_handler( PEXCEPTION_POINTERS inf ) {
+ switch( inf->ExceptionRecord->ExceptionCode ) {
case EXCEPTION_ACCESS_VIOLATION: hl_error("Access violation");
case EXCEPTION_STACK_OVERFLOW: hl_error("Stack overflow");
- default: hl_error("Unknown runtime error");
+ default: break;
}
return EXCEPTION_CONTINUE_SEARCH;
}
@@ -450,9 +450,14 @@ HL_PRIM vdynamic *hl_dyn_call_safe( vclosure *c, vdynamic **args, int nargs, boo
*isException = false;
hl_trap(trap, exc, on_exception);
# if defined(HL_VCC) && !defined(HL_XBO)
- __try {
+ ULONG size = 32<<10;
+ SetThreadStackGuarantee(&size);
+ static bool first = true;
+ if( first ) {
+ first = false;
+ AddVectoredExceptionHandler(1,global_handler);
+ }
return hl_dyn_call(c,args,nargs);
- } __except( throw_handler(GetExceptionCode()) ) {}
# else
return hl_dyn_call(c,args,nargs);
# endif
