sc/source/core/data/formulacell.cxx | 17 +++++++++++++---- sc/source/core/tool/recursionhelper.cxx | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-)
New commits: commit b35fa7758d4eba2cac85527b0bd0c1dcf5ecfc09 Author: Dennis Francis <dennis.fran...@collabora.co.uk> Date: Fri May 25 12:09:41 2018 +0530 Do not do threaded group calc if... the dependency computation resulted in a breach of recursion limit of MAXRECURSION. In such a case, the formula-group we are trying to thread is at the bottom of recursion guard stack and the dependencies (up the recursion guard stack) are yet to be computed, so the formula-group is not safe for threading. This patch fixes a crash in tdf#115034/1 when threading is enabled. Change-Id: I81737d3dd00f4e5cc782e9f030c18e36f6337a1b Reviewed-on: https://gerrit.libreoffice.org/54789 Reviewed-by: Michael Meeks <michael.me...@collabora.com> Tested-by: Jenkins diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 2fd26955891c..2de28fc8d651 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -4405,8 +4405,9 @@ bool ScFormulaCell::InterpretFormulaGroup() return false; auto aScope = sc::FormulaLogger::get().enterGroup(*pDocument, *this); + ScRecursionHelper& rRecursionHelper = pDocument->GetRecursionHelper(); - if (pDocument->GetRecursionHelper().GetRecursionCount()) + if (rRecursionHelper.GetRecursionCount()) { // Do not attempt to interpret a group when calculations are already // running, otherwise we may run into a circular reference hell. See @@ -4441,7 +4442,7 @@ bool ScFormulaCell::InterpretFormulaGroup() // ScFormulaCell::InterpretFormulaGroup() must never be called through // anything else than ScFormulaCell::Interpret(), same as // ScFormulaCell::InterpretTail() - RecursionCounter aRecursionCounter( pDocument->GetRecursionHelper(), this); + RecursionCounter aRecursionCounter( rRecursionHelper, this); // Preference order: // First try OpenCL, but only if actual OpenCL is available (i.e. no SwInterpreter). @@ -4473,7 +4474,16 @@ bool ScFormulaCell::InterpretFormulaGroupThreading(sc::FormulaLogger::GroupScope // Disable or hugely enlarge subset for S/W group // threading interpreter - if (!aCalculator.DoIt()) + bool bOKToThread = aCalculator.DoIt(); + + if (pDocument->GetRecursionHelper().IsInRecursionReturn()) + { + mxGroup->meCalcState = sc::GroupCalcDisabled; + aScope.addMessage("Recursion limit reached, cannot thread this formula group now"); + return false; + } + + if (!bOKToThread) { mxGroup->meCalcState = sc::GroupCalcDisabled; aScope.addMessage("could not do new dependencies calculation thing"); @@ -4535,7 +4545,6 @@ bool ScFormulaCell::InterpretFormulaGroupThreading(sc::FormulaLogger::GroupScope nThreadCount /= 2; SAL_INFO("sc.threaded", "Running " << nThreadCount << " threads"); - { assert(!pDocument->IsThreadedGroupCalcInProgress()); pDocument->SetThreadedGroupCalcInProgress(true); diff --git a/sc/source/core/tool/recursionhelper.cxx b/sc/source/core/tool/recursionhelper.cxx index de75e8557605..665ee2ae7aeb 100644 --- a/sc/source/core/tool/recursionhelper.cxx +++ b/sc/source/core/tool/recursionhelper.cxx @@ -16,7 +16,7 @@ void ScRecursionHelper::Init() bInRecursionReturn = bDoingRecursion = bInIterationReturn = false; aInsertPos = GetIterationEnd(); ResetIteration(); - aFGList.clear(); + // Must not force clear aFGList ever. } void ScRecursionHelper::ResetIteration() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits