A java.lang.StackOverflowError occurs on the method org.apache.poi.ss.formula.CellCacheEntry.recurseClearCachedFormulaResults in the following condition : - Create a circular reference on the cell itself (e.g. A1 on cell A1). - Remove the formula - Call the notifyUpdateCell method. Below, a sample code, tested on version 5.2.1, Java 17. : public static void main(String[] args) { try (var workbook = new XSSFWorkbook()) { var sheet = workbook.createSheet(); var row = sheet.createRow(0); var cell = row.createCell(0); cell.setCellFormula("A1"); var formulaEvaluator = workbook.getCreationHelper().createFormulaEvaluator(); formulaEvaluator.notifyUpdateCell(cell); formulaEvaluator.evaluateAll(); System.out.println(FormulaError.forInt(cell.getErrorCellValue())); cell.setCellFormula(null); formulaEvaluator.notifyUpdateCell(cell); } catch (IOException e) { e.printStackTrace(); } }
In my online copy of Excel, I set the value of cell A1 to `=A1` and was surprised to find it evaluate to `0` as opposed to a #REF error. Would you like to try to submit your own patch?
I added r1898677 but I think there is a fair amount more work to be done.
(In reply to PJ Fanning from comment #1) > In my online copy of Excel, I set the value of cell A1 to `=A1` and was > surprised to find it evaluate to `0` as opposed to a #REF error. > > Would you like to try to submit your own patch? I also get 0 in the MS Excel cell, but in the bottom left of the app, it still shows a circular reference error on cell A1.
(In reply to PJ Fanning from comment #2) > I added r1898677 but I think there is a fair amount more work to be done. Ok nice, what kind of work needs to be done in your opinion regarding this issue ?
* there are misbehaviours commented out or disabled in the new tests I added * there are other scenarios to test - like A1 set to `=A2` and A2 set to = `A1`
I added some extra test coverage and things seem ok - could certainly do with more testing but the initial test scenario seems to be fixed