Bug Hunting Session
Bug 95226 - IFERROR not working correctly under array-evaluation
Summary: IFERROR not working correctly under array-evaluation
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
4.1.5.3 release
Hardware: All All
: medium normal
Assignee: Eike Rathke
URL:
Whiteboard: target:5.1.0 target:5.0.3 target:4.4....
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-21 13:40 UTC by Wolfgang Jäger
Modified: 2016-10-25 19:09 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Demo as mentioned in the bug description (13.46 KB, application/vnd.oasis.opendocument.spreadsheet)
2015-10-21 13:40 UTC, Wolfgang Jäger
Details
new example of problem still occurring in some cases (124.11 KB, application/vnd.oasis.opendocument.spreadsheet)
2016-03-08 01:54 UTC, Robin Zalek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Jäger 2015-10-21 13:40:04 UTC
Created attachment 119828 [details]
Demo as mentioned in the bug description

Steps to reproduce the bug:
1. Create a new Calc document with V4.4.4 or higher.
2. Enter 1, =NA(), and =PI() into A1, B1, C1 respectively.
3. Type =IFERROR(A1:C1;"Error!") into A2 and enter this as an array-formula (Ctrl+Shift+Enter).

Expected result:
1, #N/A, 3,1415926536 displayed in A2:C2 consecutively.

Actual result:
1, #N/A, #NA in the respective cells.

The attached erxample is also demonstrating slightly extended examples and the complications to be accepted using a workaround (redundant calculation again which to avoid IFERROR was invented for). 

The bug is partly debasing the IFERROR function concerning its intention to avoid redundant (second) evaluation.
Comment 1 Wolfgang Jäger 2015-10-21 13:49:22 UTC
1. The description, 'Actual result:', third position should read #N/A (instead of #NA).

2. Just tested Calc version 4.1.5.3 release to the same result.
 
Version changed to 4.1.5.3 release
Comment 2 Eike Rathke 2015-10-21 15:11:38 UTC
Investigating.
Comment 3 Eike Rathke 2015-10-21 15:27:12 UTC
Actually the results should be
1, "Error!", 3.1415...
which they are if values entered in A1:A3 and IFERROR(A1:A3,...) as array formula.
Comment 4 Wolfgang Jäger 2015-10-21 16:08:55 UTC
@Eike Rathke
You are right with the result o be expected; (I wrongly accepted an #N/A):
1, Error, 3,1415926536

In my demo exactly this result is produce in rows 9 and 18 using an array formula NOT relying on IFERROR.

The basical example in row 2 is displaying the WRONG result.
1, #N/A, #N/A

So do the examples in rows 8 and 17.

In rows 2, 8, 17 the IFERROR function is used under array evaluation.
Comment 5 Commit Notification 2015-10-21 16:59:15 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=968e2faff6d4283dacd9010d31cb4c0df45eb7c5

Resolves: tdf#95226 fix broken IFERROR/IFNA array logic

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Eike Rathke 2015-10-21 17:29:10 UTC
Pending review
https://gerrit.libreoffice.org/19519 for 5-0
https://gerrit.libreoffice.org/19520 for 5-0-3
Comment 7 Eike Rathke 2015-10-22 14:02:56 UTC
https://gerrit.libreoffice.org/19522 for 4-4
https://gerrit.libreoffice.org/19523 for 4-4-6
Comment 8 Commit Notification 2015-10-22 14:08:56 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=3e06388b686e1c4f8547787baababf7ec1d0eec8

unit test for tdf#95226

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 9 Commit Notification 2015-10-22 15:50:53 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-4-4":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=748ff17f7780232729d60ef764b0f2995b887b22&h=libreoffice-4-4

Resolves: tdf#95226 fix broken IFERROR/IFNA array logic

It will be available in 4.4.7.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 10 Commit Notification 2015-10-22 15:51:03 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-5-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=e5314175b3860d2416840e1008305d3f91cee91a&h=libreoffice-5-0

Resolves: tdf#95226 fix broken IFERROR/IFNA array logic

It will be available in 5.0.4.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 11 Commit Notification 2015-10-24 09:20:05 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-5-0-3":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=5154b77b88c1b95afb0b2399e765bb3cad9f89fe&h=libreoffice-5-0-3

Resolves: tdf#95226 fix broken IFERROR/IFNA array logic

It will be available in 5.0.3.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 12 Commit Notification 2015-10-27 20:41:46 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-4-4-6":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=7dcd3a825ce521dc799cd5794c938a6d62276160&h=libreoffice-4-4-6

Resolves: tdf#95226 fix broken IFERROR/IFNA array logic

It will be available in 4.4.6.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 13 Wolfgang Jäger 2015-11-20 12:53:27 UTC
Tests repeated with V5.03. Patch works for me.
Thanks!
Comment 14 Robin Zalek 2016-03-08 01:51:38 UTC
Fix appears to be incomplete.

New document attached that shows both a working and broken example (tested Win-X64 in 5.1.2 and 2016-03-07 daily). The file has had all formulas not related to the problem removed but I don't understand enough about the problem to narrow the test case further than that.

The file is intended to keep track of materials collected in a particular video game and tell you what's currently available for you to craft and for which characters. There are two sheets for searching the data, one lists all uncrafted badges for a specified material, the other lists all uncrafted badges for a specified character.

Both searches work in a similar way: an array calculation produces a list of results and SMALL() is used to incrementally display the values returned. Depending on the search eventually SMALL() will run out of values and #VALUE! will be returned instead. IFERROR() is used to catch that and return an empty string but this only works on the material search; on the character search IFERROR() lets the #VALUE error through.

Steps to reproduce:
1. Open the attached document to either the "Material Search" or "Character Search" sheets.
2. Adjust the search value in the grey cell.

Expected Result:
In both searches the formula exists in A3:A100.
On both searches the Index column should display an incrementing number of results that can later be used to populate the remaining columns of the search.
IFERROR() should ensure blank results after all the search matches have been listed.

Actual Result:
The Material search sheet works as expected.
The Character search sheet instead shows #VALUE! up to cell A100 once search results have been exhausted.
Comment 15 Robin Zalek 2016-03-08 01:54:11 UTC
Created attachment 123394 [details]
new example of problem still occurring in some cases
Comment 16 Commit Notification 2016-03-09 15:36:59 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=62b40429946c0e5021912072dc79a60fc11fce06

Resolves: tdf#95226 second case, stack error count in JumpMatrix context

It will be available in 5.2.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 17 Eike Rathke 2016-03-09 16:01:44 UTC
Pending review
https://gerrit.libreoffice.org/23089 for 5-1
https://gerrit.libreoffice.org/23091 for 5-0
Comment 18 Commit Notification 2016-03-09 16:21:03 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-5-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=ac4560a37dacfa4fee60e36d1b3de7790b81dc20&h=libreoffice-5-1

Resolves: tdf#95226 second case, stack error count in JumpMatrix context

It will be available in 5.1.2.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 19 Commit Notification 2016-03-09 16:21:09 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-5-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=070fbda4edafb27c91c856039880099014f2b53f&h=libreoffice-5-0

Resolves: tdf#95226 second case, stack error count in JumpMatrix context

It will be available in 5.0.6.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 20 Robin Zalek 2016-03-11 15:23:58 UTC
Retested on latest daily build. Looks all fixed here.
Thanks.