Bug 135384 - Writer hangs on inserting ToC if "Enable cursor" is unchecked
Summary: Writer hangs on inserting ToC if "Enable cursor" is unchecked
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.4.0.3 release
Hardware: All All
: medium critical
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected, regression
: 147793 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-08-02 11:31 UTC by Timur
Modified: 2022-09-12 08:50 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
perf.svg: a flamegraph taken during the "hung" time. (380.69 KB, image/svg+xml)
2021-01-25 19:23 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Timur 2020-08-02 11:31:08 UTC
LO hangs on the following steps, if option LibreOffice Writer / Formatting Aids / Protected areas - Enable cursor is unchecked. 
Default is checked, so I set medium priority.

Steps to reproduce:
[1] Open a new text document.
[2] Type enter to move to 2nd line
[3] Insert letter "h" and set x¸heading on 2nd line.
[4] Insert a Table of Contents in 1st line: Insert > Table of contents.. > Table of Contents.. > OK. 

Writer hangs. Seen with LO 7.1+. 
Option appeared in LO 4.3 and it worked then. Somewhat similar bug with LO 4.4, it crashes already on insert ToC.
Comment 1 Timur 2020-08-02 12:36:49 UTC
Seems worse, another steps (with option unchecked):
1. open ODT with ToC like attachment 130778 [details] 
2. right-click ToC 
Hangs.
Comment 2 Julien Nabet 2020-08-03 11:21:42 UTC
On pc Debian x86-64 with master sources updated today, I could reproduce this.
It seems LO loops here:
https://opengrok.libreoffice.org/xref/core/sw/source/core/crsr/crsrsh.cxx?r=fb34aeb7#1846
Comment 3 Julien Nabet 2020-08-03 11:43:03 UTC
I noticed 2 fishy parts:
1)
   1799             bool bWasAllProtect = m_bAllProtect;
   1800             m_bAllProtect = false;
   1801             if( bWasAllProtect && GetDoc()->GetDocShell() &&
   1802                 GetDoc()->GetDocShell()->IsReadOnlyUI() )
   1803             {
   1804                 GetDoc()->GetDocShell()->SetReadOnlyUI( false );
   1805                 CallChgLnk();       // notify UI!
   1806             }
   1807         }
Shouldn't we add "m_bAllProtect = bWasAllProtect;" before line 1807 ?

2)
   1899                     bool bWasAllProtect = m_bAllProtect;
   1900                     m_bAllProtect = false;
   1901                     if( bWasAllProtect && GetDoc()->GetDocShell() &&
   1902                         GetDoc()->GetDocShell()->IsReadOnlyUI() )
   1903                     {
   1904                         GetDoc()->GetDocShell()->SetReadOnlyUI( false );
   1905                         CallChgLnk();       // notify UI!
   1906                     }
   1907                     m_bAllProtect = false;
shouldn't it be m_bAllProtect = bWasAllProtect;
?
Comment 4 Timur 2020-09-15 08:37:00 UTC
My 1st test and versions were in Windows. Now that I tried to Lin bibisect, simple steps from comment 2 are only seen from 7.1.
 6795676ae6d8a45cde4ba64b763d1f3baf2e5be0 is the first bad commit
Author: Jenkins Build User <tdf@pollux.tdf>
Date:   Sun Jul 5 21:23:26 2020 +0200

    source 3b9aa11d885c91a3b040cb2b103b815c75d170bc
    previous source 25c1a9be773fd3248463bdbd64c30140ac0d2406

author	Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>	2020-07-05 02:20:52 +0200
committer	Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>	2020-07-05 13:24:17 +0200
commit 3b9aa11d885c91a3b040cb2b103b815c75d170bc (patch)
tree 6d27ceaa5b4683214438523aacdd080f550c8893
parent 25c1a9be773fd3248463bdbd64c30140ac0d2406 (diff)
GotoTOXMarkBase: SwIterator no more ...
Change-Id: I60935850596eeb7209bd84782c954919c02cb259
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98050
Tested-by: Jenkins
Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>

CC: Bjoern. Please see this.
Comment 5 Timur 2021-01-21 12:54:15 UTC
Hi Xisco.I hope you can check bibisect here.
Comment 6 Justin L 2021-01-25 18:04:26 UTC
I can confirm in 7.2+ master on Ubuntu 20.04.

I also confirmed your 7.1 bibisect.

Notice that before 7.1, the right-click was NOT bringing up the TOX-context menu, but just the general page-context menu. This is also true in various versions that I checked down through 4.3. So I did not see the hang earlier than 7.1 in linux either.
Comment 7 Justin L 2021-01-25 19:23:15 UTC
Created attachment 169137 [details]
perf.svg: a flamegraph taken during the "hung" time.

It looks like it is getting hung up in a do{...}while(bAgainst) loop in sw/source/core/crsr/crsrsh.cxx's SwCursorShell::UpdateCursor.

Wow - I am a genius.  I just reproduced what was already given in comment 3...
Comment 8 Justin L 2021-01-26 07:51:11 UTC
SwViewOption::IsIgnoreProtectedArea() means Enable Cursor is checked on.

The TOX is protected because "Protected against manual changes". It probably is done via a GetProtect() property.

But I will do no more here because only a Michael-Stahl-comparable person should touch something like this.
Comment 9 Björn Michaelsen 2021-10-25 07:35:38 UTC
https://gerrit.libreoffice.org/c/core/+/124133
Comment 10 R. Bingham 2021-11-30 03:04:58 UTC
Reporting similar behavior:
Version: 7.2.3.2 (x64) / LibreOffice Community
Build ID: d166454616c1632304285822f9c83ce2e660fd92
CPU threads: 8; OS: Windows 10.0 Build 19044; UI render: Skia/Vulkan; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL

Steps to reproduce:
1) Open any Writer doc that already has any automated index table object created through Insert->Table of Contents and Index.

2) Tools->Options->LO Writer->Formatting Aids->Protected Areas->check 'Enable cursor' if not already checked. Note this Option setting is only available when a Writer doc is open.

3) Placing the cursor over an index table object should not generate any unusual behavior. If the index table object was defined for hyperlink functionality of its line entries then cntrl-click jump behavior should work.

4) Tools->Options->LO Writer->Formatting Aids->Protected Areas->UNcheck 'Enable cursor'.

5) Placing the cursor over an index table object or attempting the previously working cntrl-click hyperlink functionality will result in an LO spin hang that can only be killed via the Windows Task Manager or banging on the close window 'X.' Sometimes, merely applying OK in step 4 will cause a spin.

Regards.
Comment 11 Timur 2022-03-07 20:28:37 UTC
*** Bug 147793 has been marked as a duplicate of this bug. ***
Comment 12 Björn Michaelsen 2022-09-11 21:57:32 UTC
(In reply to Timur from comment #1)
> Seems worse, another steps (with option unchecked):
> 1. open ODT with ToC like attachment 130778 [details] 
> 2. right-click ToC 
> Hangs.

Hm, I couldnt reproduce this with current master. Can you recheck?
Comment 13 Timur 2022-09-12 08:20:27 UTC
Seems fixed somewhere in 7.3.
Comment 14 Timur 2022-09-12 08:50:14 UTC
Fixed with:

commit b14f5424dde966fa3764a7e5c813dc727390354c	[log]
author	Michael Stahl <michael.stahl@allotropia.de>	Jan 10 2022 
committer	Thorsten Behrens <thorsten.behrens@allotropia.de>Jan 12 2022
tree 7b9780e859649bf0295d9695989225c03b294bca
parent 20c819bf3bfd9d203f860f1fd078903d0b3945a7 [diff]

tdf#146605 sw: try to fix SwSectionFormat notifications
(regression from commit 2e32f4ed5af16a68c97a50806a42ffa2d10f1d7a)