Bug 142980 - Assertion failed when adding a formula to a sheet with Formulas calculated action
Summary: Assertion failed when adding a formula to a sheet with Formulas calculated ac...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Eike Rathke
URL:
Whiteboard: target:7.3.0
Keywords:
Depends on:
Blocks: Crash-Assert
  Show dependency treegraph
 
Reported: 2021-06-22 09:46 UTC by Mike Kaganski
Modified: 2021-08-16 15:10 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2021-06-22 09:46:47 UTC
Using a dbgutil build:

1. Create this stub macro:

  Sub EmptyOn
  End Sub

2. In a new Calc document, assign it to a sheet's Formulas calculated action (right-click on the sheet's tab, select "Sheet Events")

3. Select an empty cell, and type into it:

  =1+1

=> debug assertion failed: back() called on empty deque

The failing code is inside '#if OSL_DEBUG_LEVEL > 0' of UndoManagerHelper_Impl::listActionLeft; it tries to read top of m_aContextAPIFlags, which is empty at this moment.

The reason is the processing sequence in ScViewFunc::EnterData, which first calls 'rFunc.EnterListAction( STR_UNDO_ENTERDATA );' before it processes the formula - at this moment, there's no listeners yet, so the action is not executed -> UndoManagerHelper_Impl::listActionEntered is not called; then it processes the formula and calls rFunc.SetFormulaCell - at which moment, a listener is added; and then it calls rFunc.EndListAction, which tries to call UndoManagerHelper_Impl::listActionLeft, which relies on UndoManagerHelper_Impl::listActionEntered being called previously.

But I don't know if simply checking if the stack is empty before the debugging code is OK - it looks hackish.

Eike: do you have an idea how to improve this?
Comment 1 Aron Budea 2021-07-19 23:59:37 UTC
Confirmed with LO Version: 7.3.0.0.alpha0+ (83a235450e6bf3c671ab9a1710e92a356d4d2052) / Windows.
Comment 2 Eike Rathke 2021-07-20 14:15:45 UTC
https://gerrit.libreoffice.org/c/core/+/119275 is my take on this.
Comment 3 Commit Notification 2021-08-16 15:10:39 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/4ecb94da9fdd00f24b02020151ac4d27d5514d5f

Resolves: tdf#142980 Special-case the very first listener added during action

It will be available in 7.3.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.