linguistic/source/gciterator.cxx | 106 +++++++++++++++++++++------------------ 1 file changed, 59 insertions(+), 47 deletions(-)
New commits: commit cbf4d41f0607eb5b99328c4e9c172f92a4b6aea2 Author: Rashesh Padia <[email protected]> AuthorDate: Wed Nov 26 10:39:09 2025 +0530 Commit: Caolán McNamara <[email protected]> CommitDate: Fri Nov 28 16:26:23 2025 +0100 cool#7880: langaugetool: fix crash on opening spelling dialog - crash only if when bind-mounting is enabled and languagetool is configured in online. ``` terminate called after throwing an instance of 'com::sun::star::uno::RuntimeException' kit-828243-828243 2025-11-25 22:24:07.454855 +0530 [ kitbroker_001 ] SIG Fatal signal received: SIGABRT code: fffffffffffffffa(-6) for address: 0x3e8000ca353 Recent activity: Session count: 1 view: 4, session 00b, rw, user: 'LocalUser#0', loading, type: text, lang: Commands: session: 00b: load doc: file:///tmp/user/docs/9IyZFcaPoNQhnz8a/writer-edit.fodt session: 00b: unoCommand : ToolbarMode?Mode:string=Default - 2025-11-25 16:45:28 session: 00b: unoCommand : ToolbarMode?Mode:string=notebookbar_online.ui - 2025-11-25 16:45:28 session: 00b: unoCommand : SidebarShow - 2025-11-25 16:45:29 session: 00b: unoCommand : QuickFind - 2025-11-25 16:45:29 trimAfterInactivity session: 00b: unoCommand : SpellingAndGrammarDialog - 2025-11-25 16:47:26 Backtrace 828243 - kit startup of 25.04.8.0 8ce0a0ce16: /home/rashesh/collabora/online/master/coolforkit-ns(_ZN7SigUtil13dumpBacktraceEv+0x79) [0x55c6bb69ecf9] /home/rashesh/collabora/online/master/coolforkit-ns(+0x1721e5) [0x55c6bb69f1e5] /usr/lib/libc.so.6(+0x3e4d0) [0x7f3c5223e4d0] /usr/lib/libc.so.6(+0x9890c) [0x7f3c5229890c] /usr/lib/libc.so.6(gsignal+0x20) [0x7f3c5223e3a0] /usr/lib/libc.so.6(abort+0x26) [0x7f3c5222557a] /usr/lib/libstdc++.so.6(+0x97bf6) [0x7f3c52697bf6] /usr/lib/libstdc++.so.6(+0xb1eba) [0x7f3c526b1eba] /usr/lib/libstdc++.so.6(__cxa_call_terminate+0x35) [0x7f3c52697445] /usr/lib/libstdc++.so.6(__gxx_personality_v0+0x31c) [0x7f3c526b169c] /usr/lib/libgcc_s.so.1(+0x219eb) [0x7f3c52fb19eb] /usr/lib/libgcc_s.so.1(_Unwind_Resume+0x12a) [0x7f3c52fb250a] /home/rashesh/collabora/core/co-2504/instdir/program/libvcllo.so(+0x8cc728) [0x7f3c470cc728] /home/rashesh/collabora/core/co-2504/instdir/program/libvcllo.so(+0x13deb52) [0x7f3c47bdeb52] /home/rashesh/collabora/core/co-2504/instdir/program/libvcllo.so(_ZN14SvpSalInstance12ProcessEventEN16SalUserEventList12SalUserEventE+0x96) [0x7f3c47c014b8] /home/rashesh/collabora/core/co-2504/instdir/program/libvcllo.so(+0xf85fff) [0x7f3c47785fff] /home/rashesh/collabora/core/co-2504/instdir/program/libvcllo.so(_ZN16SalUserEventList18DispatchUserEventsEb+0x2d2) [0x7f3c477862d8] /home/rashesh/collabora/core/co-2504/instdir/program/libvcllo.so(+0x1401cd1) [0x7f3c47c01cd1] /home/rashesh/collabora/core/co-2504/instdir/program/libvcllo.so(+0x1402118) [0x7f3c47c02118] /home/rashesh/collabora/core/co-2504/instdir/program/libvcllo.so(+0x103d68f) [0x7f3c4783d68f] /home/rashesh/collabora/core/co-2504/instdir/program/libvcllo.so(_ZN11Application5YieldEv+0xa3) [0x7f3c4783e3cd] /home/rashesh/collabora/core/co-2504/instdir/program/libvcllo.so(_ZN11Application7ExecuteEv+0xae) [0x7f3c4783d09e] /home/rashesh/collabora/core/co-2504/instdir/program/libsofficeapp.so(+0x437ad) [0x7f3c51e437ad] /home/rashesh/collabora/core/co-2504/instdir/program/libvcllo.so(_Z10ImplSVMainv+0x1e8) [0x7f3c47866ed3] /home/rashesh/collabora/core/co-2504/instdir/program/libvcllo.so(_Z6SVMainv+0x9) [0x7f3c47866f94] /home/rashesh/collabora/core/co-2504/instdir/program/libsofficeapp.so(soffice_main+0x133) [0x7f3c51eb0ad3] /home/rashesh/collabora/core/co-2504/instdir/program/libsofficeapp.so(+0x11f702) [0x7f3c51f1f702] /home/rashesh/collabora/online/master/coolforkit-ns(_Z10lokit_mainRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_S6_S6_S6_bbbbbbm+0x2b72) [0x55c6bb63f712] /home/rashesh/collabora/online/master/coolforkit-ns(+0xd0709) [0x55c6bb5fd709] /home/rashesh/collabora/online/master/coolforkit-ns(+0xd30d2) [0x55c6bb6000d2] /home/rashesh/collabora/online/master/coolforkit-ns(+0xd3a82) [0x55c6bb600a82] /home/rashesh/collabora/online/master/coolforkit-ns(+0xd4546) [0x55c6bb601546] /home/rashesh/collabora/online/master/coolforkit-ns(+0xd30d2) [0x55c6bb6000d2] /home/rashesh/collabora/online/master/coolforkit-ns(_Z11forkit_mainiPPc+0x2d90) [0x55c6bb6077c0] /usr/lib/libc.so.6(+0x27635) [0x7f3c52227635] /usr/lib/libc.so.6(__libc_start_main+0x89) [0x7f3c522276e9] /home/rashesh/collabora/online/master/coolforkit-ns(_start+0x25) [0x55c6bb5af195] ``` Change-Id: I4fb80da841717a43358e1bfd260486dae75bad4a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194537 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> Code-Style: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> (cherry picked from commit fd7175a2e4bbd309734649400c1bf6f0a5317dbd) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194656 Tested-by: Jenkins diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx index 72276c48caff..e68d15f98b03 100644 --- a/linguistic/source/gciterator.cxx +++ b/linguistic/source/gciterator.cxx @@ -806,61 +806,73 @@ linguistic2::ProofreadingResult SAL_CALL GrammarCheckingIterator::checkSentenceA sal_Int32 nStartPos = nStartOfSentencePos >= 0 ? nStartOfSentencePos : 0; bool bFound = false; - do + try { - lang::Locale aCurLocale = lcl_GetPrimaryLanguageOfSentence( xFlatPara, nStartPos ); - sal_Int32 nOldStartOfSentencePos = nStartPos; - uno::Reference< linguistic2::XProofreader > xGC; - OUString aDocId; - - // ---- THREAD SAFE START ---- + do { - ::osl::Guard< ::osl::Mutex > aGuard( MyMutex() ); - aDocId = GetOrCreateDocId( xComponent ); - nSuggestedEndOfSentencePos = GetSuggestedEndOfSentence( rText, nStartPos, aCurLocale ); - DBG_ASSERT( nSuggestedEndOfSentencePos > nStartPos, "nSuggestedEndOfSentencePos calculation failed?" ); + lang::Locale aCurLocale = lcl_GetPrimaryLanguageOfSentence(xFlatPara, nStartPos); + sal_Int32 nOldStartOfSentencePos = nStartPos; + uno::Reference<linguistic2::XProofreader> xGC; + OUString aDocId; - xGC = GetGrammarChecker( aCurLocale ); - } - // ---- THREAD SAFE START ---- - sal_Int32 nEndPos = -1; - if (xGC.is()) - { - uno::Sequence<beans::PropertyValue> const aProps( - lcl_makeProperties(xFlatPara, PROOFINFO_GET_PROOFRESULT)); - aTmpRes = xGC->doProofreading( aDocId, rText, - aCurLocale, nStartPos, nSuggestedEndOfSentencePos, aProps ); - - //!! work-around to prevent looping if the grammar checker - //!! failed to properly identify the sentence end - if (aTmpRes.nBehindEndOfSentencePosition <= nStartPos) + // ---- THREAD SAFE START ---- { - SAL_WARN( "linguistic", "!! Grammarchecker failed to provide end of sentence !!" ); - aTmpRes.nBehindEndOfSentencePosition = nSuggestedEndOfSentencePos; + ::osl::Guard<::osl::Mutex> aGuard(MyMutex()); + aDocId = GetOrCreateDocId(xComponent); + nSuggestedEndOfSentencePos + = GetSuggestedEndOfSentence(rText, nStartPos, aCurLocale); + DBG_ASSERT(nSuggestedEndOfSentencePos > nStartPos, + "nSuggestedEndOfSentencePos calculation failed?"); + + xGC = GetGrammarChecker(aCurLocale); } + // ---- THREAD SAFE START ---- + sal_Int32 nEndPos = -1; + if (xGC.is()) + { + uno::Sequence<beans::PropertyValue> const aProps( + lcl_makeProperties(xFlatPara, PROOFINFO_GET_PROOFRESULT)); + aTmpRes = xGC->doProofreading(aDocId, rText, aCurLocale, nStartPos, + nSuggestedEndOfSentencePos, aProps); - aTmpRes.xFlatParagraph = xFlatPara; - aTmpRes.nStartOfSentencePosition = nStartPos; - nEndPos = aTmpRes.nBehindEndOfSentencePosition; + //!! work-around to prevent looping if the grammar checker + //!! failed to properly identify the sentence end + if (aTmpRes.nBehindEndOfSentencePosition <= nStartPos) + { + SAL_WARN("linguistic", + "!! Grammarchecker failed to provide end of sentence !!"); + aTmpRes.nBehindEndOfSentencePosition = nSuggestedEndOfSentencePos; + } - if ((nErrorPosInPara< 0 || nStartPos <= nErrorPosInPara) && nErrorPosInPara < nEndPos) - bFound = true; - } - if (nEndPos == -1) // no result from grammar checker - nEndPos = nSuggestedEndOfSentencePos; - nStartPos = lcl_SkipWhiteSpaces( rText, nEndPos ); - aTmpRes.nBehindEndOfSentencePosition = nEndPos; - aTmpRes.nStartOfNextSentencePosition = nStartPos; - aTmpRes.nBehindEndOfSentencePosition = lcl_BacktraceWhiteSpaces( rText, aTmpRes.nStartOfNextSentencePosition ); - - // prevent endless loop by forcefully advancing if needs be... - if (nStartPos <= nOldStartOfSentencePos) - { - SAL_WARN( "linguistic", "end-of-sentence detection failed?" ); - nStartPos = nOldStartOfSentencePos + 1; - } + aTmpRes.xFlatParagraph = xFlatPara; + aTmpRes.nStartOfSentencePosition = nStartPos; + nEndPos = aTmpRes.nBehindEndOfSentencePosition; + + if ((nErrorPosInPara < 0 || nStartPos <= nErrorPosInPara) + && nErrorPosInPara < nEndPos) + bFound = true; + } + if (nEndPos == -1) // no result from grammar checker + nEndPos = nSuggestedEndOfSentencePos; + nStartPos = lcl_SkipWhiteSpaces(rText, nEndPos); + aTmpRes.nBehindEndOfSentencePosition = nEndPos; + aTmpRes.nStartOfNextSentencePosition = nStartPos; + aTmpRes.nBehindEndOfSentencePosition + = lcl_BacktraceWhiteSpaces(rText, aTmpRes.nStartOfNextSentencePosition); + + // prevent endless loop by forcefully advancing if needs be... + if (nStartPos <= nOldStartOfSentencePos) + { + SAL_WARN("linguistic", "end-of-sentence detection failed?"); + nStartPos = nOldStartOfSentencePos + 1; + } + } while (!bFound && nStartPos < rText.getLength()); + } + catch (css::uno::Exception&) + { + TOOLS_WARN_EXCEPTION("linguistic", + "GrammarCheckingIterator::checkSentenceAtPosition ignoring"); } - while (!bFound && nStartPos < rText.getLength()); if (bFound && !xFlatPara->isModified()) return aTmpRes;
