Bug 161511 - [CRASH] Macro using seekGoal crashes on a brand new document
Summary: [CRASH] Macro using seekGoal crashes on a brand new document
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.4.0.3 release
Hardware: All All
: high major
Assignee: Mike Kaganski
URL:
Whiteboard: target:25.2.0 target:24.8.0.0.beta2 t...
Keywords: bibisected, bisected, regression
Depends on:
Blocks: GoalSeek Crash regressions-InitialColCount-to-1
  Show dependency treegraph
 
Reported: 2024-06-11 14:38 UTC by Rafael Lima
Modified: 2024-06-17 22:08 UTC (History)
1 user (show)

See Also:
Crash report or crash signature: ["ScColumn::SetError(int, FormulaError)"]


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Lima 2024-06-11 14:38:54 UTC
Consider the following macro that runs Goal Seek (using seekGoal from the UNO API):

Sub TestGoalSeek
  oSheet = ThisComponent.Sheets(0)
  oTargetCell = oSheet.getCellRangeByName("D1")
  oVariableCell = oSheet.getCellRangeByName("C1")
  oResult = Thiscomponent.seekGoal(oTargetCell.CellAddress, oVariableCell.CellAddress, "100")
  MsgBox oResult.Result
End Sub

If you create a blank Calc document and run the macro (without changing anything in the document), LO will crash.

Steps to reproduce:
1) Copy the macro above to any module in the Standard library (so that it can be run from any document)
2) Create a blank new Calc document
3) Go to Tools - Macro - Run Macro and choose the macro TestGoalSeek
4) Run the macro
5) CRASH

The weird thing is that if you simply change the values in cells C1 or D1, the crash won't happen. For instance:

0) Create a blank Calc document
1) Enter any value in cell D1
2) Delete this value and leave the cell empty
3) Run the macro
4) No crash... the macro works, even though the document is empty
Comment 1 Stéphane Guillou (stragu) 2024-06-13 04:45:20 UTC
Reproduced.

Crash reports:
- 7.4.0.3 with signature ScColumn::SetError(int, FormulaError) : https://crashreport.libreoffice.org/stats/crash_details/6c57d5aa-7196-4622-92c4-8054a47fa9bb
- 7.6.7.2, same signature: https://crashreport.libreoffice.org/stats/crash_details/3ac22139-1e15-4f08-9136-ba59c4a0c8e5
- 24.2.3.2, "name omitted" signature: https://crashreport.libreoffice.org/stats/crash_details/243dde02-3b67-4144-bc13-a9bd2b131ea0

No repro in 7.3.0.3 -> regression

Bibisected with linux-64-7.4 to first bad build [d14c498f036bf5f6f99503115eeec2a72bd1ba83] which is:

commit 9e2d48b9e04f7ea895fb095699c32ed8a44eb129
author	Luboš Luňák 	Wed Mar 30 11:58:04 2022 +0200
committer	Luboš Luňák 	Thu Apr 28 05:51:53 2022 +0200
reduce Calc's INITIALCOLCOUNT to 1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133311

Setting priority to "high" because it's a regression and Luboš is not active. Not setting severity to "critical" because it's a corner case, one would rarely run a goal seek on empty target and variable cells.
No crash when using the GUI because it stops at checking that D1 contains a formula.
Comment 2 Mike Kaganski 2024-06-13 07:46:44 UTC
https://gerrit.libreoffice.org/c/core/+/168767
Comment 3 Mike Kaganski 2024-06-13 07:57:06 UTC
Note that even before that specific change, it would nicely crash e.g. using column like ZZ for variable cell. Just C1 was in the first pre-allocated columns before. The real cause was the Noel's work on large tables (16K columns), where the limit of pre-allocated columns was introduced.
Comment 4 Commit Notification 2024-06-13 13:21:15 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/231722a7791df5e4315aefa1cc902bc1c0dc2e00

tdf#161511: create column if not exists

It will be available in 25.2.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 5 Commit Notification 2024-06-13 15:29:47 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "libreoffice-24-8":

https://git.libreoffice.org/core/commit/9e426e966528a7e0eb357cfe2aaf4091134d80b1

tdf#161511: create column if not exists

It will be available in 24.8.0.0.beta2.

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

Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2024-06-13 19:47:20 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "libreoffice-24-2":

https://git.libreoffice.org/core/commit/280bb546140a519aac54f9865a3db8dd50e779e7

tdf#161511: create column if not exists

It will be available in 24.2.5.

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

Affected users are encouraged to test the fix and report feedback.
Comment 7 Commit Notification 2024-06-14 17:50:14 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/f1872f6e47478dfd990c0031e823624de60fa079

tdf#161511: sc_goal_seek: Add unittest

It will be available in 25.2.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 8 Commit Notification 2024-06-17 22:08:04 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "libreoffice-24-8":

https://git.libreoffice.org/core/commit/cee79f814756c0461e2793d5b01bb96e70b232af

tdf#161511: sc_goal_seek: Add unittest

It will be available in 24.8.0.0.beta2.

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

Affected users are encouraged to test the fix and report feedback.