summaryrefslogtreecommitdiff
path: root/formula
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2022-12-15 18:29:57 +0100
committerEike Rathke <erack@redhat.com>2022-12-16 20:13:03 +0000
commit4574c4d796d285993b88075c7d003060b7ab5757 (patch)
tree8ea342e912ff02d44ecec90717b932c3c4f751e5 /formula
parent7e61545966c61102aad56bbf10bae2edfbfa9226 (diff)
crashtesting: assert seen on loading forum-mso-en4-573860.xlsx
While resolving named expression Pinnacle3 IF(AND(Pinnacle1+Pinnacle2<>11,Pinnacle1+Pinnacle2<>22,Pinnacle1+Pinnacle2>9),SUM(MID(Pinnacle1+Pinnacle2,1,1),MID(Pinnacle1+Pinnacle2,2,1)),Pinnacle1+Pinnacle2) where resolving and inserting named expressions Pinnacle1 IF(AND(SUM($Sheet1.$D$3:$E$3)<>11;SUM($Sheet1.$D$3:$E$3)<>22;SUM($Sheet1.$D$3:$E$3)>9);SUM(MID(SUM($Sheet1.$D$3:$E$3);1;1);MID(SUM($Sheet1.$D$3:$E$3);2;1));SUM($Sheet1.$D$3:$E$3)) and Pinnacle2 IF(AND(Logic1<>11;Logic1<>22;Logic1>9);SUM(MID(Logic1;1;1);MID(Logic1;2;1));Logic1) with Logic1 IF($Sheet1.$E$3+NilaiTahun>10;SUM(MID($Sheet1.$E$3+NilaiTahun;1;1);MID($Sheet1.$E$3+NilaiTahun;2;1));$Sheet1.$E$3+NilaiTahun) with NilaiTahun IF(SUM(MID($Sheet1.$F$3;1;1);MID($Sheet1.$F$3;2;1);MID($Sheet1.$F$3;3;1);MID($Sheet1.$F$3;4;1))<10;SUM(MID($Sheet1.$F$3;1;1);MID($Sheet1.$F$3;2;1);MID($Sheet1.$F$3;3;1);MID($Sheet1.$F$3;4;1));SUM(MID(SUM(MID($Sheet1.$F$3;1;1);MID($Sheet1.$F$3;2;1);MID($Sheet1.$F$3;3;1);MID($Sheet1.$F$3;4;1));1;1);SUM(MID(SUM(MID($Sheet1.$F$3;1;1);MID($Sheet1.$F$3;2;1);MID($Sheet1.$F$3;3;1);MID($Sheet1.$F$3;4;1));2;1)))) overall exceeds FORMULA_MAXTOKENS (8192) in the generated RPN code, hence an ocStop is encountered as factor token. (this cries for generating subroutine call token arrays where each named expression could have their own RPN code and interim results could be remembered for each while interpreting within one formula cell; just dreaming..). Change-Id: I744c4915a00849b107c7c25d7029aa19d976aa86 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144048 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins (cherry picked from commit 8e392437fdb8e8d3f2bb3d41a2f06693dc733229) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144269
Diffstat (limited to 'formula')
-rw-r--r--formula/source/core/api/FormulaCompiler.cxx14
1 files changed, 14 insertions, 0 deletions
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx
index 6684fd17da47..b0e21b250377 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -1934,6 +1934,11 @@ void FormulaCompiler::Factor()
case ocIfNA:
nJumpMax = 2;
break;
+ case ocStop:
+ // May happen only if PutCode(pFacToken) ran into overflow.
+ nJumpMax = 0;
+ assert(pc == FORMULA_MAXTOKENS && pArr->GetCodeError() != FormulaError::NONE);
+ break;
default:
nJumpMax = 0;
SAL_WARN("formula.core","Jump OpCode: " << +eFacOpCode);
@@ -1973,6 +1978,14 @@ void FormulaCompiler::Factor()
case ocIfNA:
bLimitOk = (nJumpCount <= 2);
break;
+ case ocStop:
+ // May happen only if PutCode(pFacToken) ran into overflow.
+ // This may had resulted from a stacked token array and
+ // error wasn't propagated so assert only the program
+ // counter.
+ bLimitOk = false;
+ assert(pc == FORMULA_MAXTOKENS);
+ break;
default:
bLimitOk = false;
SAL_WARN("formula.core","Jump OpCode: " << +eFacOpCode);
@@ -2836,6 +2849,7 @@ void FormulaCompiler::PutCode( FormulaTokenRef& p )
{
if ( pc == FORMULA_MAXTOKENS - 1 )
{
+ SAL_WARN("formula.core", "FormulaCompiler::PutCode - CodeOverflow with OpCode " << +p->GetOpCode());
p = new FormulaByteToken( ocStop );
p->IncRef();
*pCode++ = p.get();