From ad375d611648cb36c5949a9569b48a87289ab6db Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 14 Nov 2024 23:33:13 +0200 Subject: viewer#3088 Report out of memory as a separate 'category' --- indra/newview/llappviewer.cpp | 103 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 95 insertions(+), 8 deletions(-) (limited to 'indra/newview/llappviewer.cpp') diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index c770b7c917..d61c7da93e 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -2237,12 +2237,26 @@ void errorCallback(LLError::ELevel level, const std::string &error_string) } } -void errorMSG(const std::string& title_string, const std::string& message_string) +void errorHandler(const std::string& title_string, const std::string& message_string, S32 code) { if (!message_string.empty()) { OSMessageBox(message_string, title_string.empty() ? LLTrans::getString("MBFatalError") : title_string, OSMB_OK); } + switch (code) + { + case LLError::LLUserWarningMsg::ERROR_OTHER: + LLAppViewer::instance()->createErrorMarker(LAST_EXEC_OTHER_CRASH); + break; + case LLError::LLUserWarningMsg::ERROR_BAD_ALLOC: + LLAppViewer::instance()->createErrorMarker(LAST_EXEC_BAD_ALLOC); + break; + case LLError::LLUserWarningMsg::ERROR_MISSING_FILES: + LLAppViewer::instance()->createErrorMarker(LAST_EXEC_MISSING_FILES); + break; + default: + break; + } } void LLAppViewer::initLoggingAndGetLastDuration() @@ -2256,7 +2270,7 @@ void LLAppViewer::initLoggingAndGetLastDuration() LLError::addGenericRecorder(&errorCallback); //LLError::setTimeFunction(getRuntime); - LLError::LLUserWarningMsg::setHandler(errorMSG); + LLError::LLUserWarningMsg::setHandler(errorHandler); if (mSecondInstance) @@ -3702,16 +3716,21 @@ bool LLAppViewer::markerIsSameVersion(const std::string& marker_name) const bool sameVersion = false; std::string my_version(LLVersionInfo::instance().getChannelAndVersion()); - char marker_version[MAX_MARKER_LENGTH]; + char marker_data[MAX_MARKER_LENGTH]; S32 marker_version_length; LLAPRFile marker_file; marker_file.open(marker_name, LL_APR_RB); if (marker_file.getFileHandle()) { - marker_version_length = marker_file.read(marker_version, sizeof(marker_version)); - std::string marker_string(marker_version, marker_version_length); - if ( 0 == my_version.compare( 0, my_version.length(), marker_version, 0, marker_version_length ) ) + marker_version_length = marker_file.read(marker_data, sizeof(marker_data)); + std::string marker_string(marker_data, marker_version_length); + size_t pos = marker_string.find('\n'); + if (pos != std::string::npos) + { + marker_string = marker_string.substr(0, pos); + } + if ( 0 == my_version.compare( 0, my_version.length(), marker_string, 0, marker_string.length()) ) { sameVersion = true; } @@ -3725,6 +3744,50 @@ bool LLAppViewer::markerIsSameVersion(const std::string& marker_name) const return sameVersion; } +S32 LLAppViewer::getMarkerData(const std::string& marker_name) const +{ + bool sameVersion = false; + + std::string my_version(LLVersionInfo::instance().getChannelAndVersion()); + char marker_data[MAX_MARKER_LENGTH]; + S32 marker_version_length; + + LLAPRFile marker_file; + marker_file.open(marker_name, LL_APR_RB); + if (marker_file.getFileHandle()) + { + marker_version_length = marker_file.read(marker_data, sizeof(marker_data)); + marker_file.close(); + std::string marker_string(marker_data, marker_version_length); + std::string data; + size_t pos = marker_string.find('\n'); + if (pos != std::string::npos) + { + data = marker_string.substr(pos + 1, marker_version_length - pos - 1); + marker_string = marker_string.substr(0, pos); + } + if (0 == my_version.compare(0, my_version.length(), marker_string, 0, marker_string.length())) + { + sameVersion = true; + } + else + { + return -1; + } + LL_DEBUGS("MarkerFile") << "Compare markers for '" << marker_name << "': " + << "\n mine '" << my_version << "'" + << "\n marker '" << marker_string << "'" + << "\n " << (sameVersion ? "same" : "different") << " version" + << LL_ENDL; + if (data.length() == 0) + { + return 0; + } + return std::stoi(data); + } + return -1; +} + void LLAppViewer::processMarkerFiles() { //We've got 4 things to test for here @@ -3859,17 +3922,23 @@ void LLAppViewer::processMarkerFiles() std::string error_marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, ERROR_MARKER_FILE_NAME); if(LLAPRFile::isExist(error_marker_file, NULL, LL_APR_RB)) { - if (markerIsSameVersion(error_marker_file)) + S32 marker_code = getMarkerData(error_marker_file); + if (marker_code >= 0) { if (gLastExecEvent == LAST_EXEC_LOGOUT_FROZE) { gLastExecEvent = LAST_EXEC_LOGOUT_CRASH; LL_INFOS("MarkerFile") << "Error marker '"<< error_marker_file << "' crashed, setting LastExecEvent to LOGOUT_CRASH" << LL_ENDL; } + else if (marker_code > 0 && marker_code < (S32)LAST_EXEC_COUNT) + { + gLastExecEvent = (eLastExecEvent)marker_code; + LL_INFOS("MarkerFile") << "Error marker '"<< error_marker_file << "' crashed, setting LastExecEvent to " << gLastExecEvent << LL_ENDL; + } else { gLastExecEvent = LAST_EXEC_OTHER_CRASH; - LL_INFOS("MarkerFile") << "Error marker '"<< error_marker_file << "' crashed, setting LastExecEvent to " << gLastExecEvent << LL_ENDL; + LL_INFOS("MarkerFile") << "Error marker '" << error_marker_file << "' crashed, setting LastExecEvent to " << gLastExecEvent << LL_ENDL; } } else @@ -5159,6 +5228,24 @@ void LLAppViewer::postToMainCoro(const LL::WorkQueue::Work& work) gMainloopWork.post(work); } +void LLAppViewer::createErrorMarker(eLastExecEvent error_code) const +{ + if (!mSecondInstance) + { + std::string error_marker = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, ERROR_MARKER_FILE_NAME); + + LLAPRFile file; + file.open(error_marker, LL_APR_WB); + if (file.getFileHandle()) + { + recordMarkerVersion(file); + std::string data = "\n" + std::to_string((S32)error_code); + file.write(data.data(), static_cast(data.length())); + file.close(); + } + } +} + void LLAppViewer::outOfMemorySoftQuit() { if (!mQuitRequested) -- cgit v1.2.3 From de1ff0bd10886a7f3bf6aa8f0e4d25cdcfa27038 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 5 Dec 2024 23:45:20 +0200 Subject: viewer#3088 Add graphical init and reinit --- indra/newview/llappviewer.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llappviewer.cpp') diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index d61c7da93e..4b21905d88 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -2554,6 +2554,7 @@ bool LLAppViewer::initConfiguration() OSMessageBox( "Unable to load default settings file. The installation may be corrupted.", LLStringUtil::null,OSMB_OK); + LLAppViewer::instance()->createErrorMarker(LAST_EXEC_MISSING_FILES); return false; } -- cgit v1.2.3 From 01bd15d4be5b59cca8d49bb29eb9368c80b53f13 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 21 Jan 2025 22:32:13 +0200 Subject: #3431 Include session id with last exec event --- indra/newview/llappviewer.cpp | 63 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 10 deletions(-) (limited to 'indra/newview/llappviewer.cpp') diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 4b21905d88..64a4503260 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -298,6 +298,7 @@ bool gUseQuickTime = true; eLastExecEvent gLastExecEvent = LAST_EXEC_NORMAL; S32 gLastExecDuration = -1; // (<0 indicates unknown) +LLUUID gLastAgentSessionId; #if LL_WINDOWS # define LL_PLATFORM_KEY "win" @@ -3745,7 +3746,50 @@ bool LLAppViewer::markerIsSameVersion(const std::string& marker_name) const return sameVersion; } -S32 LLAppViewer::getMarkerData(const std::string& marker_name) const +void LLAppViewer::recordSessionToMarker() +{ + std::string marker_version(LLVersionInfo::instance().getChannelAndVersion()); + std::string uuid_str = "\n" + gAgentSessionID.asString(); + if (marker_version.length() + uuid_str.length() > MAX_MARKER_LENGTH) + { + LL_WARNS_ONCE("MarkerFile") << "Version length (" << marker_version.length() << ")" + << " greater than maximum (" << MAX_MARKER_LENGTH << ")" + << ": marker matching may be incorrect" + << LL_ENDL; + } + + mMarkerFile.seek(APR_SET, (S32)marker_version.length()); + mMarkerFile.write(uuid_str.data(), (S32)uuid_str.length()); +} + +LLUUID LLAppViewer::getMarkerSessionId(const std::string& marker_name) const +{ + std::string data; + if (getMarkerData(marker_name, data)) + { + return LLUUID(data); + } + return LLUUID(); +} + +S32 LLAppViewer::getMarkerErrorCode(const std::string& marker_name) const +{ + std::string data; + if (getMarkerData(marker_name, data)) + { + if (data.empty()) + { + return 0; + } + else + { + return std::stoi(data); + } + } + return -1; +} + +bool LLAppViewer::getMarkerData(const std::string& marker_name, std::string& data) const { bool sameVersion = false; @@ -3760,7 +3804,6 @@ S32 LLAppViewer::getMarkerData(const std::string& marker_name) const marker_version_length = marker_file.read(marker_data, sizeof(marker_data)); marker_file.close(); std::string marker_string(marker_data, marker_version_length); - std::string data; size_t pos = marker_string.find('\n'); if (pos != std::string::npos) { @@ -3773,20 +3816,16 @@ S32 LLAppViewer::getMarkerData(const std::string& marker_name) const } else { - return -1; + return false; } LL_DEBUGS("MarkerFile") << "Compare markers for '" << marker_name << "': " << "\n mine '" << my_version << "'" << "\n marker '" << marker_string << "'" << "\n " << (sameVersion ? "same" : "different") << " version" << LL_ENDL; - if (data.length() == 0) - { - return 0; - } - return std::stoi(data); + return true; } - return -1; + return false; } void LLAppViewer::processMarkerFiles() @@ -3807,6 +3846,10 @@ void LLAppViewer::processMarkerFiles() // File exists... // first, read it to see if it was created by the same version (we need this later) marker_is_same_version = markerIsSameVersion(mMarkerFileName); + if (marker_is_same_version) + { + gLastAgentSessionId = getMarkerSessionId(mMarkerFileName); + } // now test to see if this file is locked by a running process (try to open for write) marker_log_stream << "Checking exec marker file for lock..."; @@ -3923,7 +3966,7 @@ void LLAppViewer::processMarkerFiles() std::string error_marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, ERROR_MARKER_FILE_NAME); if(LLAPRFile::isExist(error_marker_file, NULL, LL_APR_RB)) { - S32 marker_code = getMarkerData(error_marker_file); + S32 marker_code = getMarkerErrorCode(error_marker_file); if (marker_code >= 0) { if (gLastExecEvent == LAST_EXEC_LOGOUT_FROZE) -- cgit v1.2.3 From fd577e3bfc49181ab71f4c13c04c51d8a073dccb Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 28 Jan 2025 21:58:12 +0200 Subject: #3400 Reimplement LLError marker for crash statistics --- indra/newview/llappviewer.cpp | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) (limited to 'indra/newview/llappviewer.cpp') diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 64a4503260..9889765fff 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -373,7 +373,6 @@ const int MAX_MARKER_LENGTH = 1024; const std::string MARKER_FILE_NAME("SecondLife.exec_marker"); const std::string START_MARKER_FILE_NAME("SecondLife.start_marker"); const std::string ERROR_MARKER_FILE_NAME("SecondLife.error_marker"); -const std::string LLERROR_MARKER_FILE_NAME("SecondLife.llerror_marker"); const std::string LOGOUT_MARKER_FILE_NAME("SecondLife.logout_marker"); static bool gDoDisconnect = false; static std::string gLaunchFileOnQuit; @@ -2220,6 +2219,7 @@ bool LLAppViewer::initThreads() return true; } +// Callback for all LL_ERROR calls void errorCallback(LLError::ELevel level, const std::string &error_string) { if (level == LLError::LEVEL_ERROR) @@ -2235,9 +2235,18 @@ void errorCallback(LLError::ELevel level, const std::string &error_string) // haven't actually trashed anything yet, we can afford to write the whole // static info file. LLAppViewer::instance()->writeDebugInfo(); + + std::string error_marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, ERROR_MARKER_FILE_NAME); + if (!LLAPRFile::isExist(error_marker_file, NULL, LL_APR_RB)) + { + // If marker doesn't exist, create a marker with llerror code for next launch + // otherwise don't override existing file + LLAppViewer::instance()->createErrorMarker(LAST_EXEC_LLERROR_CRASH); + } } } +// Callback for LLError::LLUserWarningMsg void errorHandler(const std::string& title_string, const std::string& message_string, S32 code) { if (!message_string.empty()) @@ -3939,29 +3948,6 @@ void LLAppViewer::processMarkerFiles() } LLAPRFile::remove(logout_marker_file); } - // further refine based on whether or not a marker created during an llerr crash is found - std::string llerror_marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, LLERROR_MARKER_FILE_NAME); - if(LLAPRFile::isExist(llerror_marker_file, NULL, LL_APR_RB)) - { - if (markerIsSameVersion(llerror_marker_file)) - { - if ( gLastExecEvent == LAST_EXEC_LOGOUT_FROZE ) - { - gLastExecEvent = LAST_EXEC_LOGOUT_CRASH; - LL_INFOS("MarkerFile") << "LLError marker '"<< llerror_marker_file << "' crashed, setting LastExecEvent to LOGOUT_CRASH" << LL_ENDL; - } - else - { - gLastExecEvent = LAST_EXEC_LLERROR_CRASH; - LL_INFOS("MarkerFile") << "LLError marker '"<< llerror_marker_file << "' crashed, setting LastExecEvent to LLERROR_CRASH" << LL_ENDL; - } - } - else - { - LL_INFOS("MarkerFile") << "LLError marker '"<< llerror_marker_file << "' found, but versions did not match" << LL_ENDL; - } - LLAPRFile::remove(llerror_marker_file); - } // and last refine based on whether or not a marker created during a non-llerr crash is found std::string error_marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, ERROR_MARKER_FILE_NAME); if(LLAPRFile::isExist(error_marker_file, NULL, LL_APR_RB)) -- cgit v1.2.3