Summary: | [patch] INDEX() formula cannot contain its own location in the data array range | ||
---|---|---|---|
Product: | POI | Reporter: | David Webster <dave.webster> |
Component: | HSSF | Assignee: | POI Developers List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | P3 | ||
Version: | 3.0-dev | ||
Target Milestone: | --- | ||
Hardware: | Other | ||
OS: | Windows XP | ||
Attachments: |
Excel file showing INDEX function specified within its own range, which causes Java stack overflow
svn diff of 1 changed file (HSSFFormulaEvaluator) tar bz2 of two new classes and one test case |
Description
David Webster
2008-02-13 04:44:37 UTC
Created attachment 21518 [details]
Excel file showing INDEX function specified within its own range, which causes Java stack overflow
Created attachment 21522 [details]
svn diff of 1 changed file (HSSFFormulaEvaluator)
Created attachment 21523 [details]
tar bz2 of two new classes and one test case
Bugfix patch submitted. The root problem is that the scratchpad evaluator does(/did) not handle circular references (it crashes with SOE). Some functions like INDEX, OFFSET, VLOOKUP are distinguished by the characteristic that not every cell in the range arguments has to be evaluated. This is in contrast to more basic functions like SUM and COUNTIF where every input cell must be evaluated. Functions like INDEX can be set up to potentially cause cyclic references, but nonetheless behave OK due to careful choice of other parameters (like in this example). POI's evaluation strategy is to fully evaluate all operator arguments prior to calling the operator. So the situation described here causes SOE due to a cyclic reference on cell A4 even though cell A4 should eventually get ignored by this call to INDEX. The patch supplied here allows HSSFFormulaEvaluator to handle cyclic references (and *potential* cyclic references) gracefully. No change was made to the INDEX function. A junit test case was added to show this bug (exactly as described), and also some simpler cyclic errors involving plain cell references. Thanks for this patch Josh, I've applied to to svn (I also enabled the error code test, since the patch it depends on is now in svn too) |