From ecb742f0f65687aa5dface4f55a25b7222ba5716 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Jan 22 2015 12:18:08 +0000 Subject: Resolves: rhbz#1184582 crash in grammar checking thread --- diff --git a/0001-rhbz-1184582-At-least-catch-and-log-UNO-exceptions-i.patch b/0001-rhbz-1184582-At-least-catch-and-log-UNO-exceptions-i.patch new file mode 100644 index 0000000..9f021c5 --- /dev/null +++ b/0001-rhbz-1184582-At-least-catch-and-log-UNO-exceptions-i.patch @@ -0,0 +1,150 @@ +From e6d8765bb31410b6e3bf741c4294b590933fd6ce Mon Sep 17 00:00:00 2001 +From: Stephan Bergmann +Date: Thu, 22 Jan 2015 12:47:29 +0100 +Subject: [PATCH] rhbz#1184582: At least catch and log UNO exceptions in + grammar checking thread + +(cherry picked from commit b1dbc511eeaf88e3b4b5a8a2dce129d251d2dcb6) +Conflicts: + linguistic/source/gciterator.cxx + +Change-Id: I87744f86d1413973709a46a58ebc03a39bce842c +--- + linguistic/source/gciterator.cxx | 108 +++++++++++++++++++++------------------ + 1 file changed, 59 insertions(+), 49 deletions(-) + +diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx +index 430749e..2085a25 100644 +--- a/linguistic/source/gciterator.cxx ++++ b/linguistic/source/gciterator.cxx +@@ -528,68 +528,78 @@ void GrammarCheckingIterator::DequeueAndCheck() + + if (xFlatPara.is() && xFPIterator.is()) + { +- OUString aCurTxt( xFlatPara->getText() ); +- lang::Locale aCurLocale = lcl_GetPrimaryLanguageOfSentence( xFlatPara, aFPEntryItem.m_nStartIndex ); +- +- bModified = xFlatPara->isModified(); +- if (!bModified) ++ try + { +- // ---- THREAD SAFE START ---- +- ::osl::ClearableGuard< ::osl::Mutex > aGuard( MyMutex::get() ); ++ OUString aCurTxt( xFlatPara->getText() ); ++ lang::Locale aCurLocale = lcl_GetPrimaryLanguageOfSentence( xFlatPara, aFPEntryItem.m_nStartIndex ); + +- sal_Int32 nStartPos = aFPEntryItem.m_nStartIndex; +- sal_Int32 nSuggestedEnd = GetSuggestedEndOfSentence( aCurTxt, nStartPos, aCurLocale ); +- DBG_ASSERT( (nSuggestedEnd == 0 && aCurTxt.isEmpty()) || nSuggestedEnd > nStartPos, +- "nSuggestedEndOfSentencePos calculation failed?" ); ++ bModified = xFlatPara->isModified(); ++ if (!bModified) ++ { ++ // ---- THREAD SAFE START ---- ++ ::osl::ClearableGuard< ::osl::Mutex > aGuard( MyMutex::get() ); + +- linguistic2::ProofreadingResult aRes; ++ sal_Int32 nStartPos = aFPEntryItem.m_nStartIndex; ++ sal_Int32 nSuggestedEnd = GetSuggestedEndOfSentence( aCurTxt, nStartPos, aCurLocale ); ++ DBG_ASSERT( (nSuggestedEnd == 0 && aCurTxt.isEmpty()) || nSuggestedEnd > nStartPos, ++ "nSuggestedEndOfSentencePos calculation failed?" ); + +- uno::Reference< linguistic2::XProofreader > xGC( GetGrammarChecker( aCurLocale ), uno::UNO_QUERY ); +- if (xGC.is()) +- { +- aGuard.clear(); +- uno::Sequence< beans::PropertyValue > aEmptyProps; +- aRes = xGC->doProofreading( aCurDocId, aCurTxt, aCurLocale, nStartPos, nSuggestedEnd, aEmptyProps ); +- +- //!! work-around to prevent looping if the grammar checker +- //!! failed to properly identify the sentence end +- if ( +- aRes.nBehindEndOfSentencePosition <= nStartPos && +- aRes.nBehindEndOfSentencePosition != nSuggestedEnd +- ) ++ linguistic2::ProofreadingResult aRes; ++ ++ uno::Reference< linguistic2::XProofreader > xGC( GetGrammarChecker( aCurLocale ), uno::UNO_QUERY ); ++ if (xGC.is()) + { +- DBG_ASSERT( 0, "!! Grammarchecker failed to provide end of sentence !!" ); +- aRes.nBehindEndOfSentencePosition = nSuggestedEnd; ++ aGuard.clear(); ++ uno::Sequence< beans::PropertyValue > aEmptyProps; ++ aRes = xGC->doProofreading( aCurDocId, aCurTxt, aCurLocale, nStartPos, nSuggestedEnd, aEmptyProps ); ++ ++ //!! work-around to prevent looping if the grammar checker ++ //!! failed to properly identify the sentence end ++ if ( ++ aRes.nBehindEndOfSentencePosition <= nStartPos && ++ aRes.nBehindEndOfSentencePosition != nSuggestedEnd ++ ) ++ { ++ DBG_ASSERT( 0, "!! Grammarchecker failed to provide end of sentence !!" ); ++ aRes.nBehindEndOfSentencePosition = nSuggestedEnd; ++ } ++ ++ aRes.xFlatParagraph = xFlatPara; ++ aRes.nStartOfSentencePosition = nStartPos; + } ++ else ++ { ++ // no grammar checker -> no error ++ // but we need to provide the data below in order to continue with the next sentence ++ aRes.aDocumentIdentifier = aCurDocId; ++ aRes.xFlatParagraph = xFlatPara; ++ aRes.aText = aCurTxt; ++ aRes.aLocale = aCurLocale; ++ aRes.nStartOfSentencePosition = nStartPos; ++ aRes.nBehindEndOfSentencePosition = nSuggestedEnd; ++ } ++ aRes.nStartOfNextSentencePosition = lcl_SkipWhiteSpaces( aCurTxt, aRes.nBehindEndOfSentencePosition ); ++ aRes.nBehindEndOfSentencePosition = lcl_BacktraceWhiteSpaces( aCurTxt, aRes.nStartOfNextSentencePosition ); + +- aRes.xFlatParagraph = xFlatPara; +- aRes.nStartOfSentencePosition = nStartPos; ++ //guard has to be cleared as ProcessResult calls out of this class ++ aGuard.clear(); ++ ProcessResult( aRes, xFPIterator, aFPEntryItem.m_bAutomatic ); ++ // ---- THREAD SAFE END ---- + } + else + { +- // no grammar checker -> no error +- // but we need to provide the data below in order to continue with the next sentence +- aRes.aDocumentIdentifier = aCurDocId; +- aRes.xFlatParagraph = xFlatPara; +- aRes.aText = aCurTxt; +- aRes.aLocale = aCurLocale; +- aRes.nStartOfSentencePosition = nStartPos; +- aRes.nBehindEndOfSentencePosition = nSuggestedEnd; ++ // the paragraph changed meanwhile... (and maybe is still edited) ++ // thus we simply continue to ask for the next to be checked. ++ uno::Reference< text::XFlatParagraph > xFlatParaNext( xFPIterator->getNextPara() ); ++ AddEntry( xFPIterator, xFlatParaNext, aCurDocId, 0, aFPEntryItem.m_bAutomatic ); + } +- aRes.nStartOfNextSentencePosition = lcl_SkipWhiteSpaces( aCurTxt, aRes.nBehindEndOfSentencePosition ); +- aRes.nBehindEndOfSentencePosition = lcl_BacktraceWhiteSpaces( aCurTxt, aRes.nStartOfNextSentencePosition ); +- +- //guard has to be cleared as ProcessResult calls out of this class +- aGuard.clear(); +- ProcessResult( aRes, xFPIterator, aFPEntryItem.m_bAutomatic ); +- // ---- THREAD SAFE END ---- + } +- else ++ catch (css::uno::Exception & e) + { +- // the paragraph changed meanwhile... (and maybe is still edited) +- // thus we simply continue to ask for the next to be checked. +- uno::Reference< text::XFlatParagraph > xFlatParaNext( xFPIterator->getNextPara() ); +- AddEntry( xFPIterator, xFlatParaNext, aCurDocId, 0, aFPEntryItem.m_bAutomatic ); ++ SAL_WARN( ++ "linguistic", ++ "GrammarCheckingIterator::DequeueAndCheck ignoring UNO" ++ " exception " << e.Message); + } + } + +-- +1.9.3 + diff --git a/libreoffice.spec b/libreoffice.spec index 85fa29c..45f4757 100644 --- a/libreoffice.spec +++ b/libreoffice.spec @@ -339,6 +339,7 @@ Patch83: 0001-fdo-68385-update-references-only-if-cut-originates-f.patch Patch84: 0001-Resolves-fdo-73165-don-t-restart-timer-if-already-ru.patch Patch85: 0001-Resolves-rhbz-1162352-SwDataChanged-dtor-accesses-de.patch Patch86: 0001-font-cache-gets-broken-on-adding-an-embedded-font.patch +Patch87: 0001-rhbz-1184582-At-least-catch-and-log-UNO-exceptions-i.patch %define instdir %{_libdir} %define baseinstdir %{instdir}/libreoffice @@ -2273,9 +2274,10 @@ update-desktop-database %{_datadir}/applications &> /dev/null || : %endif %changelog -* Thu Jan 22 2015 Caolán McNamara - 1:4.2.8.2-3-UNBUILT +* Thu Jan 22 2015 Caolán McNamara - 1:4.2.8.2-3 - font cache gets broken on adding an embedded font - Resolves: rhbz#1177547 system autocorr files not detected +- Resolves: rhbz#1184582 crash in grammar checking thread * Thu Jan 15 2015 Caolán McNamara - 1:4.2.8.2-2 - Resolves: fdo#87141 Remove deletes the node but we want to release it