formula/source/core/api/FormulaCompiler.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
New commits: commit 8e392437fdb8e8d3f2bb3d41a2f06693dc733229 Author: Eike Rathke <er...@redhat.com> AuthorDate: Thu Dec 15 18:29:57 2022 +0100 Commit: Eike Rathke <er...@redhat.com> CommitDate: Thu Dec 15 23:21:52 2022 +0000 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 <er...@redhat.com> Tested-by: Jenkins 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();