diff --git a/source/lib/debug.cpp b/source/lib/debug.cpp index 7abcc08780..38cb04b326 100644 --- a/source/lib/debug.cpp +++ b/source/lib/debug.cpp @@ -478,7 +478,9 @@ ErrorReaction display_error(const wchar_t* description, int flags, static const wchar_t fmt[] = L"%s\r\n\r\nCall stack:\r\n\r\n"; int len = swprintf(text, MAX_CHARS, fmt, description); - debug_dump_stack(text+len, MAX_CHARS-len, skip+1, context); + if(!context) + skip++; // skip this frame + debug_dump_stack(text+len, MAX_CHARS-len, skip, context); // in-place } else diff --git a/source/lib/sysdep/win/wdbg.cpp b/source/lib/sysdep/win/wdbg.cpp index 7c3eedcde4..75f1849327 100755 --- a/source/lib/sysdep/win/wdbg.cpp +++ b/source/lib/sysdep/win/wdbg.cpp @@ -907,7 +907,7 @@ static const wchar_t* get_exception_locus(const EXCEPTION_POINTERS* ep) // real location. wchar_t buf[32000]; - const wchar_t* stack_trace = debug_dump_stack(buf, ARRAY_SIZE(buf), +0, ep->ContextRecord); + const wchar_t* stack_trace = debug_dump_stack(buf, ARRAY_SIZE(buf), 1, ep->ContextRecord); const size_t MAX_LOCUS_CHARS = 256; static wchar_t locus[MAX_LOCUS_CHARS]; @@ -990,12 +990,13 @@ LONG WINAPI wdbg_exception_filter(EXCEPTION_POINTERS* ep) wchar_t func_name[DBG_SYMBOL_LEN]; char file[DBG_FILE_LEN] = {0}; int line = 0; wchar_t fmt[50]; swprintf(fmt, ARRAY_SIZE(fmt), L"%%%ds %%%dhs (%%d)", DBG_SYMBOL_LEN, DBG_FILE_LEN); + // bake in the string limits (future-proof) if(swscanf(locus, fmt, func_name, file, &line) != 3) debug_warn("error extracting file/line from exception locus"); wchar_t buf[500]; const wchar_t* msg_fmt = - L"Much to our regret we must report the program has encountered an error and cannot continue.\r\n" + L"Much to our regret we must report the program has encountered an error.\r\n" L"\r\n" L"Please let us know at http://bugs.wildfiregames.com/ and attach the crashlog.txt and crashlog.dmp files.\r\n" L"\r\n" @@ -1004,7 +1005,7 @@ LONG WINAPI wdbg_exception_filter(EXCEPTION_POINTERS* ep) int flags = 0; if(ep->ExceptionRecord->ExceptionFlags & EXCEPTION_NONCONTINUABLE) flags = DE_NO_CONTINUE; - ErrorReaction er = display_error(buf, flags, 0, ep->ContextRecord, file, line); + ErrorReaction er = display_error(buf, flags, 1, ep->ContextRecord, file, line); assert(er > 0); wdbg_write_minidump(ep); diff --git a/source/lib/sysdep/win/win.cpp b/source/lib/sysdep/win/win.cpp index 058719e210..fb615727fd 100755 --- a/source/lib/sysdep/win/win.cpp +++ b/source/lib/sysdep/win/win.cpp @@ -523,7 +523,7 @@ _PIFV pre_libc_begin[] = { 0 }; _PIFV pre_libc_end[] = { 0 }; #pragma data_seg(WIN_CALLBACK_PRE_MAIN(a)) _PIFV pre_main_begin[] = { 0 }; -#pragma data_seg(WIN_CALLBACK_PRE_MAIN(a)) +#pragma data_seg(WIN_CALLBACK_PRE_MAIN(z)) _PIFV pre_main_end[] = { 0 }; #pragma data_seg(WIN_CALLBACK_POST_ATEXIT(a)) _PIFV shutdown_begin[] = { 0 }; diff --git a/source/lib/sysdep/win/win_internal.h b/source/lib/sysdep/win/win_internal.h index 68d1d80e74..7670890202 100755 --- a/source/lib/sysdep/win/win_internal.h +++ b/source/lib/sysdep/win/win_internal.h @@ -432,8 +432,8 @@ extern void win_free(void* p); #define WIN_REGISTER_FUNC(func) static int func(void); static int(*p##func)(void) = func -#define WIN_CALLBACK_PRE_LIBC(group) ".LIB$WC" #group -#define WIN_CALLBACK_PRE_MAIN(group) ".LIB$WI" #group +#define WIN_CALLBACK_PRE_LIBC(group) ".LIB$WC" #group +#define WIN_CALLBACK_PRE_MAIN(group) ".LIB$WI" #group #define WIN_CALLBACK_POST_ATEXIT(group) ".LIB$WT" #group