From 2bc2666e4eaf8852e84cadc7c00ba7ed173b7f66 Mon Sep 17 00:00:00 2001 From: janwas Date: Mon, 19 Dec 2011 11:55:30 +0000 Subject: [PATCH] sync with work - minor fixes This was SVN commit r10770. --- source/lib/debug.cpp | 3 ++- source/lib/path.h | 2 ++ source/lib/sysdep/os/win/wvm.cpp | 9 +++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/source/lib/debug.cpp b/source/lib/debug.cpp index 5d5f821fd1..35102c38ab 100644 --- a/source/lib/debug.cpp +++ b/source/lib/debug.cpp @@ -146,7 +146,8 @@ void debug_printf(const wchar_t* fmt, ...) va_list ap; va_start(ap, fmt); const int numChars = vswprintf_s(buf, ARRAY_SIZE(buf), fmt, ap); - ENSURE(numChars >= 0); + if(numChars < 0) + debug_break(); // poor man's assert - avoid infinite loop because ENSURE also uses debug_printf va_end(ap); if(debug_filter_allows(buf)) diff --git a/source/lib/path.h b/source/lib/path.h index 2b22b13077..408f2b356b 100644 --- a/source/lib/path.h +++ b/source/lib/path.h @@ -43,6 +43,8 @@ #include +#include "lib/posix/posix.h" // wcscasecmp + namespace ERR { const Status PATH_CHARACTER_ILLEGAL = -100300; diff --git a/source/lib/sysdep/os/win/wvm.cpp b/source/lib/sysdep/os/win/wvm.cpp index c3d0471293..c53a74c0ec 100644 --- a/source/lib/sysdep/os/win/wvm.cpp +++ b/source/lib/sysdep/os/win/wvm.cpp @@ -241,9 +241,8 @@ static void* AllocateLargeOrSmallPages(uintptr_t address, size_t size, DWORD all else { MEMORY_BASIC_INFORMATION mbi = {0}; - SIZE_T ret = VirtualQuery(LPCVOID(address), &mbi, sizeof(mbi)); - debug_printf(L"Allocation failed. VirtualQuery returned %d\n", ret); - debug_printf(L"base=%p allocBase=%p allocProt=%d size=%d state=%d prot=%d type=%d\n", mbi.BaseAddress, mbi.AllocationBase, mbi.AllocationProtect, mbi.RegionSize, mbi.State, mbi.Protect, mbi.Type); + (void)VirtualQuery(LPCVOID(address), &mbi, sizeof(mbi)); // return value is #bytes written in mbi + debug_printf(L"Allocation failed: base=%p allocBase=%p allocProt=%d size=%d state=%d prot=%d type=%d\n", mbi.BaseAddress, mbi.AllocationBase, mbi.AllocationProtect, mbi.RegionSize, mbi.State, mbi.Protect, mbi.Type); } return 0; @@ -465,6 +464,8 @@ void Free(void* p, size_t UNUSED(size)) //----------------------------------------------------------------------------- // on-demand commit +// NB: avoid using debug_printf here because OutputDebugString has been +// observed to generate vectored exceptions when running outside the IDE. static LONG CALLBACK VectoredHandler(const PEXCEPTION_POINTERS ep) { const PEXCEPTION_RECORD er = ep->ExceptionRecord; @@ -485,7 +486,7 @@ static LONG CALLBACK VectoredHandler(const PEXCEPTION_POINTERS ep) // if unknown (e.g. access violation in kernel address space or // violation of alignment requirements), we don't want to handle it. - if(address == ~uintptr_t(0)) + if(address == ~uintptr_t(0)) return EXCEPTION_CONTINUE_SEARCH; // the address space must have been allocated by ReserveAddressSpace