Kaydet (Commit) 80049d11 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

don't overwrite the crashreport info that are written before upload

There was a race condition that the OpenGL code was initialized before
the old report has been uploaded. Therefore the OpenGL setting was
overwritten by the new start and we were not getting the old value.

Now we store any value that wants to be added before the dump.ini is
ready in a temporary map and will write them as soon as we write all the
common information.

This problem was introduced by the dialog requesting permission to
upload the crash report.

Change-Id: I29391a1ff56bac6381218c5a4aefb58c2c03f024
Reviewed-on: https://gerrit.libreoffice.org/31846Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst 5e6c7d6d
...@@ -35,28 +35,54 @@ osl::Mutex CrashReporter::maMutex; ...@@ -35,28 +35,54 @@ osl::Mutex CrashReporter::maMutex;
#endif #endif
google_breakpad::ExceptionHandler* CrashReporter::mpExceptionHandler = nullptr; google_breakpad::ExceptionHandler* CrashReporter::mpExceptionHandler = nullptr;
bool CrashReporter::mbInit = false;
std::map<OUString, OUString> CrashReporter::maKeyValues;
namespace {
void writeToStream(std::ofstream& strm, const OUString& rKey, const OUString& rValue)
{
strm << rtl::OUStringToOString(rKey, RTL_TEXTENCODING_UTF8).getStr() << "=";
strm << rtl::OUStringToOString(rValue, RTL_TEXTENCODING_UTF8).getStr() << "\n";
}
}
void CrashReporter::AddKeyValue(const OUString& rKey, const OUString& rValue) void CrashReporter::AddKeyValue(const OUString& rKey, const OUString& rValue)
{ {
osl::MutexGuard aGuard(maMutex); osl::MutexGuard aGuard(maMutex);
std::string ini_path = getIniFileName(); if (mbInit)
std::ofstream ini_file(ini_path, std::ios_base::app); {
ini_file << rtl::OUStringToOString(rKey, RTL_TEXTENCODING_UTF8).getStr() << "="; std::string ini_path = getIniFileName();
ini_file << rtl::OUStringToOString(rValue, RTL_TEXTENCODING_UTF8).getStr() << "\n"; std::ofstream ini_file(ini_path, std::ios_base::app);
writeToStream(ini_file, rKey, rValue);
}
else
{
maKeyValues.insert(std::pair<OUString, OUString>(rKey, rValue));
}
} }
#endif #endif
void CrashReporter::writeCommonInfo() void CrashReporter::writeCommonInfo()
{ {
osl::MutexGuard aGuard(maMutex);
// limit the amount of code that needs to be executed before the crash reporting // limit the amount of code that needs to be executed before the crash reporting
std::string ini_path = CrashReporter::getIniFileName(); std::string ini_path = CrashReporter::getIniFileName();
std::ofstream minidump_file(ini_path, std::ios_base::trunc); std::ofstream minidump_file(ini_path, std::ios_base::trunc);
minidump_file << "ProductName=LibreOffice\n"; minidump_file << "ProductName=LibreOffice\n";
minidump_file << "Version=" LIBO_VERSION_DOTTED "\n"; minidump_file << "Version=" LIBO_VERSION_DOTTED "\n";
minidump_file << "URL=http://crashreport.libreoffice.org/submit/\n"; minidump_file << "URL=http://crashreport.libreoffice.org/submit/\n";
for (auto& keyValue : maKeyValues)
{
writeToStream(minidump_file, keyValue.first, keyValue.second);
}
maKeyValues.clear();
minidump_file.close(); minidump_file.close();
mbInit = true;
updateMinidumpLocation(); updateMinidumpLocation();
} }
......
...@@ -57,6 +57,10 @@ private: ...@@ -57,6 +57,10 @@ private:
static osl::Mutex maMutex; static osl::Mutex maMutex;
static bool mbInit;
static std::map<OUString, OUString> maKeyValues; // used to temporarily save entries before the old info has been uploaded
static google_breakpad::ExceptionHandler* mpExceptionHandler; static google_breakpad::ExceptionHandler* mpExceptionHandler;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment