Bug 162760 - Calc solver crashes on large spreadsheet but runs in LO 7.6.7
Summary: Calc solver crashes on large spreadsheet but runs in LO 7.6.7
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
24.2.5.2 release
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:25.2.0
Keywords:
Depends on:
Blocks: Solver
  Show dependency treegraph
 
Reported: 2024-09-03 09:31 UTC by brodders
Modified: 2024-09-18 19:38 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Trimmed down test Spreadsheet - made by 7.6.2 (171.19 KB, application/vnd.oasis.opendocument.spreadsheet)
2024-09-03 19:58 UTC, brodders
Details

Note You need to log in before you can comment on or make changes to this bug.
Description brodders 2024-09-03 09:31:29 UTC
Installed LibreOffice_24.8.0_Win_x86-64.msi on a long in use Windows 10 PC.

Large spreadsheet in use for years now crashes instantly when using Calc solver.

Solver is set up, option "non-negative variables" selected then solve clicked; insta crash LO. Small solver window remains up and will not go away without Windows forcing it closed.

NB Solver works as per usual with Calc in 7.6.7.

Solver used is SCO.

In Safe Mode... SCO always crashes as per above, but DEPS does not crash. Once DEPS has run OK, SCO now works.... is SCO using an uninitialised variable which DEPS sets correctly?
Comment 1 Xisco Faulí 2024-09-03 10:00:33 UTC Comment hidden (obsolete)
Comment 2 brodders 2024-09-03 17:36:57 UTC
Investigating this and editing to create a smaller sample file - the new file does not crash. But that saving was using the new/present LO version.

The original S/S still crashes with SCO; have refined the conditions such that opening and immediately selecting/using DEPS solver - does not crash. Saving the file now (using the present LO version) on re-opening the saved file SCO does not crash. Something has changed in the data written to file with the two LO versions.

Suspect that the present/new version saves internal solver data-states differently to 7.6.7, hence the initial crash (data block format has changed). However once the file is opened and DEPS solver used, saving writes the new format to file and crashing is gone as a symptom.

The only way I can create a small, releasable test file is to reload the old LO - but alas I'm not a dev and my time is on other things.

Suggest a workaround - Open solver in DEPS, save, then do what you like.
Comment 3 Rafael Lima 2024-09-03 17:49:45 UTC
(In reply to brodders from comment #2)
> Suspect that the present/new version saves internal solver data-states
> differently to 7.6.7, hence the initial crash (data block format has
> changed). However once the file is opened and DEPS solver used, saving
> writes the new format to file and crashing is gone as a symptom.

Indeed there was a change on how solver settings are saved to the file. Which is why it would be valuable to get a file where the crash happens, so we can fix it.

I could not reproduce on my machine... it's possibly some edge case.
Comment 4 brodders 2024-09-03 19:58:00 UTC Comment hidden (obsolete)
Comment 5 brodders 2024-09-03 20:01:52 UTC Comment hidden (obsolete)
Comment 6 brodders 2024-09-03 20:03:31 UTC
Comment on attachment 196213 [details]
Trimmed down test Spreadsheet - made by 7.6.2

This file is from LO Calc 7.6.2, crashes when using SCO solver in 24.8.0.3

1. Select PZX_Master sheet
2. Menu selection: Solver > Options > SCO Evolutionary and check Assume Non-Negative Variables
3. OK and Solve CRASH

However if DEPS solver used, will not crash out of the box. Saving always fixes things.
Comment 7 QA Administrators 2024-09-04 03:15:15 UTC Comment hidden (obsolete)
Comment 8 Rafael Lima 2024-09-04 13:11:42 UTC
Thanks for the sample file. I can now reproduce the crash in:

Version: 24.2.5.2 (X86_64) / LibreOffice Community
Build ID: 420(Build:2)
CPU threads: 16; OS: Linux 6.8; UI render: default; VCL: kf5 (cairo+xcb)
Locale: pt-BR (pt_BR.UTF-8); UI: en-US
Ubuntu package version: 4:24.2.5-0ubuntu0.24.04.2
Calc: threaded
Comment 9 Rafael Lima 2024-09-05 15:10:19 UTC
So the problem is that your file does not contain the solver engine settings, then the LibrarySize parameter is read as zero and then it causes the solver to crash (since this parameter can't be zero).

The saving of SCO/DEPS parameters to the file started with LO 24.2 (which is why you did not have them saved).

So there are 2 things here:
1) We need to catch exceptions by the solver engine (since they can fail unexpectedly as in this case)
2) If a certain engine setting does not exist in the file, we should use its default value (instead of zero)

Patch incoming.
Comment 10 Rafael Lima 2024-09-06 19:40:37 UTC
Proposed patch here
https://gerrit.libreoffice.org/c/core/+/172955
Comment 11 Commit Notification 2024-09-18 19:00:10 UTC
Rafael Lima committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/57ecae2843c80d67ab9a3aaaf004fe131c4f13ae

tdf#162760 Fix solver crashing with unset parameters

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.