summaryrefslogtreecommitdiff
path: root/desktop/source/app/app.cxx
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2020-01-02 15:30:36 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2020-01-10 18:05:01 +0100
commit12b5892cf9c78dd917f2e50672cd250478e6c7d6 (patch)
treebc131525b92075e3be986bfa05de060f7e632a67 /desktop/source/app/app.cxx
parentc12358166a9bd88fe10feabca45a6ad3f65dff8e (diff)
Delete google_breakpad::ExceptionHandler before calling _exit()
While debugging tdf#129712 on Windows, I saw this sequence: 1. nullptr was dereferenced (the reason for tdf#129712). 2. ExceptionHandler::HandleException was called (in workdir/UnpackedTarball/breakpad/src/client/windows/handler/exception_handler.cc). 3. It called ExceptionHandler::WriteMinidumpOnHandlerThread. 4. Minidump was created in ExceptionHandler::ExceptionHandlerThreadMain. 5. Document Recovery dialog was shown in Desktop::Exception (in desktop/source/app/app.cxx). 6. After closing dialog, _exit() was called in Desktop::Exception. 7. All threads except main were terminated. 8. Another access violation was thrown in the "minimal CRT cleanup". 9. ExceptionHandler::HandleException called again. 10. ExceptionHandler::WriteMinidumpOnHandlerThread hung on WaitForSingleObject because handler thread that should release the semaphore was terminated already at step 7. The process had to be killed manually. This change destroys the breakpad handler at the start of Desktop::Exception, which de-registers itself (on Windows it uses SetUnhandledExceptionFilter). Other than preventing the hang, the rationale also is that keeping the handler after first minidump creation is wrong: even if the second minidump creation succeeded, uploading it to crashdump server would give not the actual problem, but some unrelated stack. Change-Id: If12d0c7db519693f733b5ab3b8a288cef800a149 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86104 Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'desktop/source/app/app.cxx')
-rw-r--r--desktop/source/app/app.cxx4
1 files changed, 4 insertions, 0 deletions
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 7fd35ee3d574..eff6f70df610 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -1136,6 +1136,10 @@ void Desktop::Exception(ExceptionCategory nCategory)
// protect against recursive calls
static bool bInException = false;
+#if HAVE_FEATURE_BREAKPAD
+ CrashReporter::removeExceptionHandler(); // disallow re-entry
+#endif
+
SystemWindowFlags nOldMode = Application::GetSystemWindowMode();
Application::SetSystemWindowMode( nOldMode & ~SystemWindowFlags::NOAUTOMODE );
if ( bInException )