From 680934812598d2c9116303f3245e7a9d60ff58bf Mon Sep 17 00:00:00 2001 From: Aura Linden Date: Tue, 3 Dec 2013 17:06:06 -0800 Subject: Creating a cleaner branch --- indra/newview/llappviewerwin32.cpp | 109 +++++++++++++++++++++++++++++++++---- 1 file changed, 98 insertions(+), 11 deletions(-) mode change 100755 => 100644 indra/newview/llappviewerwin32.cpp (limited to 'indra/newview/llappviewerwin32.cpp') diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp old mode 100755 new mode 100644 index 80a80f4298..c6152574c1 --- a/indra/newview/llappviewerwin32.cpp +++ b/indra/newview/llappviewerwin32.cpp @@ -65,6 +65,31 @@ #include "llwindebug.h" #endif +#include +namespace +{ + void (*gOldTerminateHandler)() = NULL; +} + +static void exceptionTerminateHandler() +{ + // reinstall default terminate() handler in case we re-terminate. + if (gOldTerminateHandler) std::set_terminate(gOldTerminateHandler); + // treat this like a regular viewer crash, with nice stacktrace etc. + long *null_ptr; + null_ptr = 0; + *null_ptr = 0xDEADBEEF; //Force an exception that will trigger breakpad. + //LLAppViewer::handleViewerCrash(); + // we've probably been killed-off before now, but... + gOldTerminateHandler(); // call old terminate() handler +} + +LONG WINAPI catchallCrashHandler(EXCEPTION_POINTERS * /*ExceptionInfo*/) +{ + llwarns << "Hit last ditch-effort attempt to catch crash." << llendl; + exceptionTerminateHandler(); + return 0; +} // *FIX:Mani - This hack is to fix a linker issue with libndofdev.lib // The lib was compiled under VS2005 - in VS2003 we need to remap assert @@ -244,8 +269,15 @@ int APIENTRY WINMAIN(HINSTANCE hInstance, LLAppViewerWin32* viewer_app_ptr = new LLAppViewerWin32(lpCmdLine); + // install unexpected exception handler SPATTERS test point + gOldTerminateHandler = std::set_terminate(exceptionTerminateHandler); + viewer_app_ptr->setErrorHandler(LLAppViewer::handleViewerCrash); +#if LL_SEND_CRASH_REPORTS + ::SetUnhandledExceptionFilter(catchallCrashHandler); //SPATTERS test point +#endif + // Set a debug info flag to indicate if multiple instances are running. bool found_other_instance = !create_app_mutex(); gDebugInfo["FoundOtherInstanceAtStartup"] = LLSD::Boolean(found_other_instance); @@ -354,6 +386,14 @@ int APIENTRY WINMAIN(HINSTANCE hInstance, hSession = 0; } + /* SPATTERS? + // Wait until child process exits. + WaitForSingleObject( mCrashReporterProcessInfo.hProcess, 30000 ); //Wait up to 30 seconds for crash report to finish up. + + // Close process and thread handles. + CloseHandle( mCrashReporterProcessInfo.hProcess ); + CloseHandle( mCrashReporterProcessInfo.hThread ); + */ return 0; } @@ -496,7 +536,19 @@ bool LLAppViewerWin32::init() LLWinDebug::instance().init(); #endif - return LLAppViewer::init(); +#if LL_WINDOWS +#if LL_SEND_CRASH_REPORTS + + + LLAppViewer* pApp = LLAppViewer::instance(); + pApp->initCrashReporting(); + +#endif +#endif + + bool success = LLAppViewer::init(); + + return success; } bool LLAppViewerWin32::cleanup() @@ -635,26 +687,61 @@ bool LLAppViewerWin32::restoreErrorTrap() //return LLWinDebug::checkExceptionHandler(); } -void LLAppViewerWin32::handleCrashReporting(bool reportFreeze) +void LLAppViewerWin32::initCrashReporting(bool reportFreeze) { const char* logger_name = "win_crash_logger.exe"; std::string exe_path = gDirUtilp->getExecutableDir(); exe_path += gDirUtilp->getDirDelimiter(); exe_path += logger_name; - const char* arg_str = logger_name; + std::stringstream pid_str; + pid_str << LLApp::getPid(); + std::string logdir = gDirUtilp->getExpandedFilename(LL_PATH_DUMP, ""); + std::string appname = gDirUtilp->getExecutableFilename(); - // *NOTE:Mani - win_crash_logger.exe no longer parses command line options. - if(reportFreeze) + std::cout << "SPATTERS in init" << std::endl; + S32 slen = logdir.length() -1; + S32 end = slen; + while (logdir.at(end) == '/' || logdir.at(end) == '\\') end--; + + if (slen !=end) { - // Spawn crash logger. - // NEEDS to wait until completion, otherwise log files will get smashed. - _spawnl(_P_WAIT, exe_path.c_str(), arg_str, NULL); + logdir = logdir.substr(0,end+1); } - else + std::string arg_str = "\"" + exe_path + "\" -dumpdir \"" + logdir + "\" -procname \"" + appname + "\" -pid " + pid_str.str(); + _spawnl(_P_NOWAIT, exe_path.c_str(), arg_str.c_str(), NULL); + +/* STARTUPINFO siStartupInfo; + + std::string arg_str = "-dumpdir \"" + logdir + "\" -procname \"" + appname + "\" -pid " + pid_str.str(); + + memset(&siStartupInfo, 0, sizeof(siStartupInfo)); + memset(&mCrashReporterProcessInfo, 0, sizeof(mCrashReporterProcessInfo)); + + siStartupInfo.cb = sizeof(siStartupInfo); + + std::wstring exe_wstr; + exe_wstr.assign(exe_path.begin(), exe_path.end()); + + std::wstring arg_wstr; + arg_wstr.assign(arg_str.begin(), arg_str.end()); + + if(CreateProcess(&exe_wstr[0], + &arg_wstr[0], // Application arguments + 0, + 0, + FALSE, + CREATE_DEFAULT_ERROR_MODE, + 0, + 0, // Working directory + &siStartupInfo, + &mCrashReporterProcessInfo) == FALSE) + // Could not start application -> call 'GetLastError()' { - _spawnl(_P_NOWAIT, exe_path.c_str(), arg_str, NULL); - } + //llinfos << "CreateProcess failed " << GetLastError() << llendl; + return; + } + */ } //virtual -- cgit v1.2.3 From ce2cd00cc516dbff712956875d4565b8d26e44ca Mon Sep 17 00:00:00 2001 From: Aura Linden Date: Wed, 4 Dec 2013 19:57:11 -0800 Subject: Removed debugging code. --- indra/newview/llappviewerwin32.cpp | 44 +------------------------------------- 1 file changed, 1 insertion(+), 43 deletions(-) (limited to 'indra/newview/llappviewerwin32.cpp') diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp index c6152574c1..6946130631 100644 --- a/indra/newview/llappviewerwin32.cpp +++ b/indra/newview/llappviewerwin32.cpp @@ -269,13 +269,12 @@ int APIENTRY WINMAIN(HINSTANCE hInstance, LLAppViewerWin32* viewer_app_ptr = new LLAppViewerWin32(lpCmdLine); - // install unexpected exception handler SPATTERS test point gOldTerminateHandler = std::set_terminate(exceptionTerminateHandler); viewer_app_ptr->setErrorHandler(LLAppViewer::handleViewerCrash); #if LL_SEND_CRASH_REPORTS - ::SetUnhandledExceptionFilter(catchallCrashHandler); //SPATTERS test point + ::SetUnhandledExceptionFilter(catchallCrashHandler); #endif // Set a debug info flag to indicate if multiple instances are running. @@ -386,14 +385,6 @@ int APIENTRY WINMAIN(HINSTANCE hInstance, hSession = 0; } - /* SPATTERS? - // Wait until child process exits. - WaitForSingleObject( mCrashReporterProcessInfo.hProcess, 30000 ); //Wait up to 30 seconds for crash report to finish up. - - // Close process and thread handles. - CloseHandle( mCrashReporterProcessInfo.hProcess ); - CloseHandle( mCrashReporterProcessInfo.hThread ); - */ return 0; } @@ -699,7 +690,6 @@ void LLAppViewerWin32::initCrashReporting(bool reportFreeze) std::string logdir = gDirUtilp->getExpandedFilename(LL_PATH_DUMP, ""); std::string appname = gDirUtilp->getExecutableFilename(); - std::cout << "SPATTERS in init" << std::endl; S32 slen = logdir.length() -1; S32 end = slen; while (logdir.at(end) == '/' || logdir.at(end) == '\\') end--; @@ -710,38 +700,6 @@ void LLAppViewerWin32::initCrashReporting(bool reportFreeze) } std::string arg_str = "\"" + exe_path + "\" -dumpdir \"" + logdir + "\" -procname \"" + appname + "\" -pid " + pid_str.str(); _spawnl(_P_NOWAIT, exe_path.c_str(), arg_str.c_str(), NULL); - -/* STARTUPINFO siStartupInfo; - - std::string arg_str = "-dumpdir \"" + logdir + "\" -procname \"" + appname + "\" -pid " + pid_str.str(); - - memset(&siStartupInfo, 0, sizeof(siStartupInfo)); - memset(&mCrashReporterProcessInfo, 0, sizeof(mCrashReporterProcessInfo)); - - siStartupInfo.cb = sizeof(siStartupInfo); - - std::wstring exe_wstr; - exe_wstr.assign(exe_path.begin(), exe_path.end()); - - std::wstring arg_wstr; - arg_wstr.assign(arg_str.begin(), arg_str.end()); - - if(CreateProcess(&exe_wstr[0], - &arg_wstr[0], // Application arguments - 0, - 0, - FALSE, - CREATE_DEFAULT_ERROR_MODE, - 0, - 0, // Working directory - &siStartupInfo, - &mCrashReporterProcessInfo) == FALSE) - // Could not start application -> call 'GetLastError()' - { - //llinfos << "CreateProcess failed " << GetLastError() << llendl; - return; - } - */ } //virtual -- cgit v1.2.3 From ea7e6a5174f1bdfc51ada864736d354706534d8b Mon Sep 17 00:00:00 2001 From: Aura Linden Date: Tue, 14 Jan 2014 15:28:35 -0800 Subject: Some cleanup of string to wstring conversion and vice versa. --- indra/newview/llappviewerwin32.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llappviewerwin32.cpp') diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp index 6946130631..c861d0a99f 100644 --- a/indra/newview/llappviewerwin32.cpp +++ b/indra/newview/llappviewerwin32.cpp @@ -65,6 +65,8 @@ #include "llwindebug.h" #endif +#include "stringize.h" + #include namespace { @@ -685,8 +687,6 @@ void LLAppViewerWin32::initCrashReporting(bool reportFreeze) exe_path += gDirUtilp->getDirDelimiter(); exe_path += logger_name; - std::stringstream pid_str; - pid_str << LLApp::getPid(); std::string logdir = gDirUtilp->getExpandedFilename(LL_PATH_DUMP, ""); std::string appname = gDirUtilp->getExecutableFilename(); @@ -698,7 +698,7 @@ void LLAppViewerWin32::initCrashReporting(bool reportFreeze) { logdir = logdir.substr(0,end+1); } - std::string arg_str = "\"" + exe_path + "\" -dumpdir \"" + logdir + "\" -procname \"" + appname + "\" -pid " + pid_str.str(); + std::string arg_str = "\"" + exe_path + "\" -dumpdir \"" + logdir + "\" -procname \"" + appname + "\" -pid " + stringize(LLApp::getPid()); _spawnl(_P_NOWAIT, exe_path.c_str(), arg_str.c_str(), NULL); } -- cgit v1.2.3 From d2bb4dae980a887a30b206875d8f9419901ed66a Mon Sep 17 00:00:00 2001 From: Aura Linden Date: Fri, 7 Mar 2014 14:58:22 -0800 Subject: Fixes for crash reporter startup race condition, crash reporter CPU use, Secondlife.log filehandle, XP Crash. --- indra/newview/llappviewerwin32.cpp | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'indra/newview/llappviewerwin32.cpp') diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp index c861d0a99f..0e4efa34c7 100644 --- a/indra/newview/llappviewerwin32.cpp +++ b/indra/newview/llappviewerwin32.cpp @@ -276,7 +276,7 @@ int APIENTRY WINMAIN(HINSTANCE hInstance, viewer_app_ptr->setErrorHandler(LLAppViewer::handleViewerCrash); #if LL_SEND_CRASH_REPORTS - ::SetUnhandledExceptionFilter(catchallCrashHandler); + // ::SetUnhandledExceptionFilter(catchallCrashHandler); #endif // Set a debug info flag to indicate if multiple instances are running. @@ -698,8 +698,35 @@ void LLAppViewerWin32::initCrashReporting(bool reportFreeze) { logdir = logdir.substr(0,end+1); } - std::string arg_str = "\"" + exe_path + "\" -dumpdir \"" + logdir + "\" -procname \"" + appname + "\" -pid " + stringize(LLApp::getPid()); - _spawnl(_P_NOWAIT, exe_path.c_str(), arg_str.c_str(), NULL); + //std::string arg_str = "\"" + exe_path + "\" -dumpdir \"" + logdir + "\" -procname \"" + appname + "\" -pid " + stringize(LLApp::getPid()); + //_spawnl(_P_NOWAIT, exe_path.c_str(), arg_str.c_str(), NULL); + std::string arg_str = "\"" + exe_path + "\" -dumpdir \"" + logdir + "\" -procname \"" + appname + "\" -pid " + stringize(LLApp::getPid()); + + STARTUPINFO startInfo={sizeof(startInfo)}; + PROCESS_INFORMATION processInfo; + + std::wstring exe_wstr; + exe_wstr=wstringize(exe_path); + + std::wstring arg_wstr; + arg_wstr=wstringize(arg_str); + + LL_INFOS("CrashReport") << "Creating crash reporter process " << exe_path << " with params: " << arg_str << LL_ENDL; + if(CreateProcess(exe_wstr.c_str(), + &arg_wstr[0], // Application arguments + 0, + 0, + FALSE, + CREATE_DEFAULT_ERROR_MODE, + 0, + 0, // Working directory + &startInfo, + &processInfo) == FALSE) + // Could not start application -> call 'GetLastError()' + { + LL_WARNS("CrashReport Launch") << "CreateProcess failed " << GetLastError() << LL_ENDL; + return; + } } //virtual -- cgit v1.2.3