]> git.sesse.net Git - casparcg/commitdiff
[win32] Give the server a tiny hope of recovering from a stack overflow bug. Still...
authorHelge Norberg <helge.norberg@svt.se>
Tue, 31 Jan 2017 15:34:21 +0000 (16:34 +0100)
committerHelge Norberg <helge.norberg@svt.se>
Tue, 31 Jan 2017 15:34:21 +0000 (16:34 +0100)
common/log.cpp
common/log.h
common/os/windows/win32_exception.cpp

index b6488739dffac300eb56ea85a2b9d12e445f312d..55ee3406cc4389f0d7e25e5d28d34b4d48cbda1f 100644 (file)
@@ -163,6 +163,16 @@ void init()
        boost::log::core::get()->add_sink(stream_sink);
 }
 
+std::string current_exception_diagnostic_information()
+{
+       auto e = boost::current_exception_cast<const char*>();
+
+       if (e)
+               return std::string("[char *] = ") + *e + "\n";
+       else
+               return boost::current_exception_diagnostic_information();
+}
+
 }
 
 void add_file_sink(const std::wstring& file, const boost::log::filter& filter)
index 860c1a6466f024852cf96974d8109b37c8b26304..9df9470f2f7f364d59b106ae4df8d35f03bf1b65 100644 (file)
@@ -43,6 +43,7 @@ namespace caspar { namespace log {
 namespace internal{
 void init();
 std::wstring get_call_stack();
+std::string current_exception_diagnostic_information();
 }
 
 const char* remove_source_prefix(const char* file);
@@ -102,12 +103,12 @@ BOOST_LOG_INLINE_GLOBAL_LOGGER_INIT(logger, caspar_logger)
        catch(...){}
 
 #define CASPAR_LOG_CURRENT_EXCEPTION() try{\
-               CASPAR_LOG(error) << caspar::u16(boost::current_exception_diagnostic_information()) << L"Caught at (" << caspar::get_thread_info().name << L"):\n" << caspar::get_call_stack();\
+               CASPAR_LOG(error) << caspar::u16(::caspar::log::internal::current_exception_diagnostic_information()) << L"Caught at (" << caspar::get_thread_info().name << L"):\n" << caspar::get_call_stack();\
        }\
        catch(...){}
 
 #define CASPAR_LOG_CURRENT_EXCEPTION_AT_LEVEL(lvl) try{\
-               CASPAR_LOG(lvl) << caspar::u16(boost::current_exception_diagnostic_information()) << L"Caught at (" << caspar::get_thread_info().name << L"):\n" << caspar::get_call_stack();\
+               CASPAR_LOG(lvl) << caspar::u16(::caspar::log::internal::current_exception_diagnostic_information()) << L"Caught at (" << caspar::get_thread_info().name << L"):\n" << caspar::get_call_stack();\
        }\
        catch(...){}
 
index 75006bc25ad5e044edea19df8edd082aa0fcb393..0a65c5cebb66b9d83b022f2de6ee4bfb836be3a8 100644 (file)
@@ -31,7 +31,7 @@ inline void SetThreadName(DWORD dwThreadID, LPCSTR szThreadName)
        {
                RaiseException( 0x406D1388, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info );
        }
-       __except (EXCEPTION_CONTINUE_EXECUTION){}       
+       __except (EXCEPTION_CONTINUE_EXECUTION){}
 }
 
 } // namespace detail
@@ -41,7 +41,7 @@ bool& installed_for_thread()
        static boost::thread_specific_ptr<bool> installed;
 
        auto for_thread = installed.get();
-       
+
        if (!for_thread)
        {
                for_thread = new bool(false);
@@ -99,6 +99,8 @@ void win32_exception::Handler(unsigned int errorCode, EXCEPTION_POINTERS* pInfo)
        {
        case EXCEPTION_ACCESS_VIOLATION:
                CASPAR_THROW_EXCEPTION(win32_access_violation() << generate_message(*(pInfo->ExceptionRecord)));
+       case EXCEPTION_STACK_OVERFLOW:
+               throw "Stack overflow. Not generating stack trace to protect from further overflowing the stack";
        default:
                CASPAR_THROW_EXCEPTION(win32_exception() << generate_message(*(pInfo->ExceptionRecord)));
        }