From b0a09199da3e29d2e95e5e4077c7c51ef8b6660c Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 23 Aug 2013 15:14:09 +0200 Subject: [PATCH] Resolves: rhbz#1000150, Do not call exit upon XIOError --- ...00150-Do-not-call-exit-upon-XIOError.patch | 116 ++++++++++++++++++ libreoffice.spec | 7 +- 2 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 0001-rhbz-1000150-Do-not-call-exit-upon-XIOError.patch diff --git a/0001-rhbz-1000150-Do-not-call-exit-upon-XIOError.patch b/0001-rhbz-1000150-Do-not-call-exit-upon-XIOError.patch new file mode 100644 index 0000000..2820686 --- /dev/null +++ b/0001-rhbz-1000150-Do-not-call-exit-upon-XIOError.patch @@ -0,0 +1,116 @@ +From 9ff4c35f1d8e7e603b23245afb6947b8260fabfc Mon Sep 17 00:00:00 2001 +From: Stephan Bergmann +Date: Fri, 23 Aug 2013 12:03:45 +0200 +Subject: [PATCH] rhbz#1000150: Do not call exit upon XIOError + +...as done in _XIOError (libX11-1.6.0/src/XlibInt.c) after calling the XIOError +handler function (either the one supplied with XSetIOErrorHandler or +_XDefaultIOError), as that calls the atexit handlers, which can wreak havoc in +unrelated threads that happen to be running in parallel, leading to arbitrary +crashes. So avoid that by always calling _exit already from our XIOError +handler. + +The old code was careful to /not/ call _exit when the XIOError happened on any +thread but the main one, but I do not see the sense of that---after all, +_XIOError will inevitably call exit afterwards, so this cannot be a way to +"ignore" XIOErrors from special threads (that are set up say for the sole +purpose of trying out "known-shaky" activities without affecting the stability +of the whole process). And findings like comment 12 to + "[abrt] +libreoffice-core-3.5.4.2-1.fc17: ICEConnectionWorker thread still running during +exit" ("it is very likely that this is not a normal exit from reaching the end +of main, but rather some explicit call to exit from some error handling code") +make it clear that we apparenly do suffer from such calls to _XIOError -> exit +on non-main threads. + +I have no idea why vcl/unx/gtk has its own XIOErrorHdl that is substantially +different from the vcl/unx/generic one, though. + +cherry picked from commit ffea65915b9cc6d4f3c01f829552702654a040f9, plus +follow-up b240a1c188b58e3e717335339bfc3f5e20bb2bf4: + + rhbz#1000150: Do not call exit upon XIOError, take two + + The _XDefaultIOError handler (libX11-1.6.0/src/XlibInt.c) already calls exit + (even though _XIOError calling _XDefaultIOError would call exit afterwards, + too), so our XIOError handler must not call aOrigXIOErrorHandler. + +Change-Id: Ida7d407cf5f0fa4e719118cab5e725144ceb3a35 +--- + vcl/unx/generic/app/saldata.cxx | 25 +++++++++++-------------- + vcl/unx/gtk/app/gtkdata.cxx | 12 +++++------- + 2 files changed, 16 insertions(+), 21 deletions(-) + +diff --git a/vcl/unx/generic/app/saldata.cxx b/vcl/unx/generic/app/saldata.cxx +index 3d91586..9b5e200 100644 +--- a/vcl/unx/generic/app/saldata.cxx ++++ b/vcl/unx/generic/app/saldata.cxx +@@ -307,22 +307,19 @@ int X11SalData::XErrorHdl( Display *pDisplay, XErrorEvent *pEvent ) + + int X11SalData::XIOErrorHdl( Display * ) + { +- if (::osl::Thread::getCurrentIdentifier() != Application::GetMainThreadIdentifier()) ++ if (::osl::Thread::getCurrentIdentifier() == Application::GetMainThreadIdentifier()) + { +- pthread_exit(NULL); +- return 0; ++ /* #106197# hack: until a real shutdown procedure exists ++ * _exit ASAP ++ */ ++ if( ImplGetSVData()->maAppData.mbAppQuit ) ++ _exit(1); ++ ++ // really bad hack ++ if( ! SessionManagerClient::checkDocumentsSaved() ) ++ /* oslSignalAction eToDo = */ osl_raiseSignal (OSL_SIGNAL_USER_X11SUBSYSTEMERROR, NULL); + } + +- /* #106197# hack: until a real shutdown procedure exists +- * _exit ASAP +- */ +- if( ImplGetSVData()->maAppData.mbAppQuit ) +- _exit(1); +- +- // really bad hack +- if( ! SessionManagerClient::checkDocumentsSaved() ) +- /* oslSignalAction eToDo = */ osl_raiseSignal (OSL_SIGNAL_USER_X11SUBSYSTEMERROR, NULL); +- + std::fprintf( stderr, "X IO Error\n" ); + std::fflush( stdout ); + std::fflush( stderr ); +@@ -331,7 +328,7 @@ int X11SalData::XIOErrorHdl( Display * ) + * do apply here. Since there is nothing to be done after an XIO + * error we have to _exit immediately. + */ +- _exit(0); ++ _exit(1); + return 0; + } + +diff --git a/vcl/unx/gtk/app/gtkdata.cxx b/vcl/unx/gtk/app/gtkdata.cxx +index 6abb06b..23f7931 100644 +--- a/vcl/unx/gtk/app/gtkdata.cxx ++++ b/vcl/unx/gtk/app/gtkdata.cxx +@@ -511,14 +511,12 @@ GtkData::GtkData( SalInstance *pInstance ) + + XIOErrorHandler aOrigXIOErrorHandler = NULL; + +-int XIOErrorHdl(Display *pDisplay) ++int XIOErrorHdl(Display *) + { +- if (::osl::Thread::getCurrentIdentifier() != Application::GetMainThreadIdentifier()) +- { +- pthread_exit(NULL); +- return 0; +- } +- return aOrigXIOErrorHandler ? aOrigXIOErrorHandler(pDisplay) : 0; ++ fprintf(stderr, "X IO Error\n"); ++ _exit(1); ++ // avoid crashes in unrelated threads that still run while atexit ++ // handlers are in progress + } + + GtkData::~GtkData() +-- +1.8.3.1 + diff --git a/libreoffice.spec b/libreoffice.spec index e0738bd..18abaa8 100644 --- a/libreoffice.spec +++ b/libreoffice.spec @@ -43,7 +43,7 @@ Summary: Free Software Productivity Suite Name: libreoffice Epoch: 1 Version: %{libo_version}.2 -Release: 1%{?libo_prerelease}%{?dist} +Release: 2%{?libo_prerelease}%{?dist} License: (MPLv1.1 or LGPLv3+) and LGPLv3 and LGPLv2+ and BSD and (MPLv1.1 or GPLv2 or LGPLv2 or Netscape) and Public Domain and ASL 2.0 and Artistic and MPLv2.0 Group: Applications/Productivity URL: http://www.libreoffice.org/default/ @@ -258,6 +258,7 @@ Patch17: 0001-only-use-the-SSPI-support-with-internal-neon.patch Patch18: 0001-Always-try-to-mount-in-gio-Content-getGFileInfo.patch Patch19: 0001-Resolves-rhbz-998046-store-last-size-position-of-the.patch Patch20: 0001-Make-charmap.cxx-compile-with-icu-4.4.patch +Patch21: 0001-rhbz-1000150-Do-not-call-exit-upon-XIOError.patch %define instdir %{_libdir} %define baseinstdir %{instdir}/libreoffice @@ -1010,6 +1011,7 @@ mv -f redhat.soc extras/source/palettes/standard.soc %patch18 -p1 -b .Always-try-to-mount-in-gio-Content-getGFileInfo.patch %patch19 -p1 -b .rhbz-998046-store-last-size-position-of-the.patch %patch20 -p1 -b .Make-charmap.cxx-compile-with-icu-4.4.patch +%patch21 -p1 -b .rhbz-1000150-Do-not-call-exit-upon-XIOError.patch # TODO: check this # these are horribly incomplete--empty translations and copied english @@ -2100,6 +2102,9 @@ update-desktop-database %{_datadir}/applications &> /dev/null || : %endif %changelog +* Fri Aug 23 2013 Stephan Bergmann - 1:4.1.1.2-2-UNBUILT +- Resolves: rhbz#1000150, Do not call exit upon XIOError + * Thu Aug 22 2013 David Tardon - 1:4.1.1.2-1 - 4.1.1 rc2 - Related: rhbz#895690 Always try to do a mount when opening a file via GIO