-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved out of process crash handler #5543
Conversation
src/app/qgscrashhandler.h
Outdated
* This class doesn't need to be created by anyone as is only used to handle | ||
* crashes in the application. | ||
*/ | ||
QgsCrashHandler() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
= delete;
QString extraInfoFile = QString( argv[1] ); | ||
std::cout << "Extra Info File: " << extraInfoFile.toUtf8().data() << std::endl; | ||
|
||
QFile file( extraInfoFile ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bomb out if this doesn't exist?
src/crashhandler/main.cpp
Outdated
// bit gross but :) | ||
QString info = file.readAll(); | ||
versionInfo = info.split("\n"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Graceful exit if we can't open the file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might still show the dialog but with no info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
although this shouldn't really happen anyway but dialog might be better then just crashing out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks perfect! Just needs a . between "information Your"
Also "Stack trace unable to be generated" should be "Stack trace could not be generated"
src/crashhandler/main.cpp
Outdated
std::cout << "Exception Pointer: " << exceptionPointersString.toLocal8Bit().constData() << std::endl; | ||
std::cout << "Symbol Path :" << symbolPaths.toUtf8().data() << std::endl; | ||
|
||
QgsStackTrace *stackTrace = QgsStackTrace::trace( processId, threadId, exception, symbolPaths ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::unique_ptr
src/crashhandler/qgscrashreport.cpp
Outdated
reportData.append( QStringLiteral( "Compiled against GDAL: %1" ).arg( GDAL_RELEASE_NAME ) ); | ||
reportData.append( QStringLiteral( "Running against GDAL: %1" ).arg( GDALVersionInfo( "RELEASE_NAME" ) ) ); | ||
reportData.append( mVersionInfo ); | ||
// reportData.append( QStringLiteral( "QGIS Version: %1" ).arg( Qgis::QGIS_VERSION ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the go here?
src/crashhandler/qgscrashreport.cpp
Outdated
@@ -117,13 +129,13 @@ const QString QgsCrashReport::toHtml() const | |||
|
|||
const QString QgsCrashReport::crashID() const | |||
{ | |||
if ( mStackTrace.isEmpty() ) | |||
if (!mStackTrace->symbolsLoaded || mStackTrace->lines.isEmpty() ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
astyle
src/crashhandler/qgscrashreport.cpp
Outdated
fileName = folder + "/report.txt"; | ||
|
||
file.setFileName(fileName); | ||
if ( file.open( QIODevice::WriteOnly | QIODevice::Text ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure you'll need QIODevice::Truncate here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a new file each time so should be at the start already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point!
src/crashhandler/qgscrashreport.cpp
Outdated
|
||
QString QgsCrashReport::crashReportFolder() | ||
{ | ||
return QStandardPaths::standardLocations( QStandardPaths::AppDataLocation ).value( 0 ) + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AppLocalDataLocation ?
src/crashhandler/qgsstacktrace.cpp
Outdated
getStackTrace( stackTrace, symbolPath, trace ); | ||
trace->fullStack = QString::fromWCharArray( stackTrace->message ); | ||
|
||
// wchar_t dumpFilename[MAX_PATH + 1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's with all this? Better #if 0 it or kill it.
Speak for yourself! I've saved $1978 by following Youtube DIY surgical operation guides. |
Great move! This looks like a much better approach to me. |
bf24747
to
e2cbc5c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Let's merge and test
@jef-n let me know if you see anything out of place here and I will fix it up. qgiscrashhandler doesn't need to go into osgeo4w\bin like qgis.exe as I'm loading it from the prefix path. |
Thanks for the review @nyalldawson |
Description
This PR moves the crash handler work out into a new process called qgiscrashhandler.exe (only Windows at the moment). As part of this it will also generate a crash report folder inside %APPDATA%\QGIS\QGIS3\crashes. In future this lets us look back over the data from inside QGIS with a crash reporting tool. Report folder includes the users report in markdown format as well as the full stack trace with more info. In future, we can include a memory dump here if we want.
Main reasons for doing this:
All arguments that the crash handler needs are written to a temp file on crash and then read back into the crash handler process, this includes stuff like process id, thread id, the pointer to expectation stack.
Checklist
fixes #11111
in the commit message next to the description[FEATURE]
in the commit message[needs-docs]
in the commit message and containt sufficient information in the commit message to be documentedscripts/prepare-commit.sh
script before each commit