Bug 134161 - CPU at 100% after opening a particular spreadsheet
Summary: CPU at 100% after opening a particular spreadsheet
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.0.0.3 release
Hardware: All All
: high major
Assignee: Not Assigned
URL:
Whiteboard: target:7.1.0 target:7.0.4
Keywords: bibisected, bisected, regression
: 137202 (view as bug list)
Depends on:
Blocks: Performance CPU-AT-100%
  Show dependency treegraph
 
Reported: 2020-06-20 00:18 UTC by Jim Avera
Modified: 2024-05-02 04:01 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
demo.ods - see Steps to Reproduce (814.19 KB, application/vnd.oasis.opendocument.spreadsheet)
2020-06-20 00:19 UTC, Jim Avera
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jim Avera 2020-06-20 00:18:28 UTC
Description:
If a large number of Calc sheets are deleted in a single operation, then soffice  continues to use very high CPU (97+%) after the deletes finish.   

The high CPU usage never stops after that point (I waited for 15-20 minutes).  Meanwhile, the GUI responds normally.

So something must be in an infinite loop [conjecture: gc bug?]


Steps to Reproduce:
1.  Open the attached demo.ods spreadsheet.  
     Do NOT enable macros.
2.  Click the |< button at the left-bottom to view the first Sheet tab
3.  Click the "AAPL" tab (3rd sheet over)
    Click the >| button to view the last sheet tab
    Shift-Click "ZUO" (the last sheet).  

    This selects all except the first 2 sheets.

4.  Rightclick (in the sheet tab area)->Delete Sheet...   and confirm;

5.  In another terminal, run "top"

Actual Results:
After a while the sheets are deleted and the GUI becomes usable again, but "top" shows soffice.bin using 99% CPU forever after (tested for 15-20 minutes).

Expected Results:
CPU usage should drop to ~zero when the GUI is idle.


Reproducible: Always


User Profile Reset: Yes



Additional Info:
There is zero swap space used (I have 16M ram so didn't expect any swapping).
Comment 1 Jim Avera 2020-06-20 00:19:03 UTC
Created attachment 162221 [details]
demo.ods - see Steps to Reproduce
Comment 2 Jim Avera 2020-06-20 00:20:50 UTC
Version: 7.1.0.0.alpha0+
Build ID: 573138efec7fa28a98ba3b0301f6e0a97dac7978
CPU threads: 12; OS: Linux 5.4; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
TinderBox: Linux-rpm_deb-x86_64@86-TDF, Branch:master, Time: 2020-06-18_14:08:32
Calc: threaded
Comment 3 Buovjaga 2020-10-30 13:55:11 UTC
Actually, the CPU gets stuck immediately upon opening the file. There is no need to delete any sheets.

Bisected with Linux 7.1 repo to https://git.libreoffice.org/core/commit/4111ed76906bf6be05b704bf52fa91353dfef183
tdf#132137 Rename Default Style in Calc.

Adding Cc: to Srijan Bhatia

Also observed on Windows.
Comment 4 Aron Budea 2020-10-30 15:51:55 UTC
I can already see that this difference is a problem:
https://opengrok.libreoffice.org/xref/core/sc/source/core/data/stlsheet.cxx?r=b225980d#284

if ( rNew == aFileStdName && aFileStdName != ScResId(STR_STYLENAME_STANDARD_CELL) )
    return false;
else if ( rNew == aFileStdName && aFileStdName != ScResId(STR_STYLENAME_STANDARD_PAGE) )
    return false;
else
    return SfxStyleSheet::SetName(rNew, bReindexNow);

========

If 'rNew == aFileStdName' is true, it'll either return false in the first branch, or in the second, and never gets to the third, ie. this kind of branching makes no sense.
Comment 5 Aron Budea 2020-10-31 01:51:17 UTC
Similarly wrong if condition:
https://opengrok.libreoffice.org/xref/core/sc/source/core/data/patattr.cxx?r=b225980d#1018

However, fixing them (at least in a way that looks sensible, no idea if the fix is actually correct) doesn't help here.

In addition, in Windows with Skia rendering the menus are empty with this file open (but not with just any file, and neither without Skia).
Comment 6 Commit Notification 2020-11-06 08:53:30 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

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

tdf#134161: Revert "tdf#132137 Rename Default Style in Calc."

It will be available in 7.1.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 7 Xisco Faulí 2020-11-06 08:56:49 UTC
commit reverted, the document should no longer hang
Comment 8 Commit Notification 2020-11-06 10:24:45 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/7ccbeade150f450568f44ad6283d4a4dc3b379bf

tdf#134161: sc_anchor: Add unittest

It will be available in 7.1.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 9 Jim Avera 2020-11-09 01:30:58 UTC
Confirming fixed (CPU is low when idle) in Master.   Thanks!

Version: 7.1.0.0.alpha1+
Build ID: 03a9a80125cf887d26348486b71d78d80c99344d
CPU threads: 12; OS: Linux 5.4; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
TinderBox: Linux-rpm_deb-x86_64@86-TDF, Branch:master, Time: 2020-11-07_18:04:03
Calc: threaded
Comment 10 Aron Budea 2020-11-09 01:40:21 UTC
Let's set to verified, thanks for confirming.
Comment 11 Xisco Faulí 2020-11-10 11:09:58 UTC
Patch in libreoffice-7-0 branch has been reverted in https://cgit.freedesktop.org/libreoffice/core/commit/?h=libreoffice-7-0&id=7002053174aed5c3a7b1fe5b1785011080aa6cbe
Comment 12 Commit Notification 2020-11-10 14:26:28 UTC
Xisco Fauli committed a patch related to this issue.
It has been pushed to "libreoffice-7-0":

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

tdf#134161: sc_anchor: Add unittest

It will be available in 7.0.4.

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 13 Stéphane Guillou (stragu) 2024-05-02 04:01:21 UTC
*** Bug 137202 has been marked as a duplicate of this bug. ***