Bug 80392 - Endless page counting on opening or editing a particular DOCX
Summary: Endless page counting on opening or editing a particular DOCX
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
(earliest affected)
Inherited From OOo
Hardware: Other All
: highest critical
Assignee: Not Assigned
Whiteboard: BSA
Keywords: bibisected, bisected, haveBacktrace, perf
Depends on:
Blocks: Repagination
  Show dependency treegraph
Reported: 2014-06-23 12:19 UTC by Hkais
Modified: 2021-11-09 17:27 UTC (History)
12 users (show)

See Also:
Crash report or crash signature:

the gdb "bt full" trace (22.42 KB, application/gzip)
2014-06-23 12:19 UTC, Hkais
Original file, wich, If I open in Document writer, go on endless page creation loop (9.53 MB, application/zip)
2015-05-21 15:47 UTC, Nick
shorter reproducer (680.02 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2017-02-10 10:09 UTC, Caolán McNamara
odt reproducer (671.07 KB, application/vnd.oasis.opendocument.text)
2019-11-03 11:22 UTC, Luke Deller
perf flamegraph (101.73 KB, application/x-bzip)
2020-01-27 20:39 UTC, Julien Nabet

Note You need to log in before you can comment on or make changes to this bug.
Description Hkais 2014-06-23 12:19:30 UTC
Created attachment 101580 [details]
the gdb "bt full" trace

We use Open/Libreoffice since 2006 and we love it! (I had to use MS Word since version 6, so I really love it)

But now I am facing a issue, there I cannot find a workaround.

I have a document, with a lot of changes tracking a lot of comments on authoring and also some images. The doc is 14 pages long.

If I try to insert a heading or sometimes only a text on a specific place in the doc, libreoffice is running into a loop an beginns to count page numbers. I killed it with the doc size of 15.000 pages, since the application was unresponsive.
I created a gdb file, which hopefully will help.

best wishes,
Operating System: All
Version: release
Comment 1 Yousuf Philips (jay) (retired) 2014-06-25 05:06:42 UTC Comment hidden (obsolete)
Comment 2 Hkais 2014-07-04 08:13:04 UTC
problem still exists on windows, linux and also on the current version
reverted back to ubuntu managed version of libreoffice
Comment 3 Hkais 2014-07-04 10:53:51 UTC
since I was not sure, I have opened a new bug.
bug #80904 which happens now on the same doc
and maybe it is correlated to bug #47935
Comment 4 Yousuf Philips (jay) (retired) 2014-07-05 02:48:59 UTC Comment hidden (obsolete)
Comment 5 Hkais 2014-07-16 08:29:20 UTC
Hello Jay,
see also bug #80904

I cannot provide you the doc with the details right now. How can we workaround the issue? (I could create a dev environment, if it helps, but would need some support on it)

As you see I have managed to provide stacktraces, so I think I could provide also more details on the errors, if someone hepls me.
Comment 6 Yousuf Philips (jay) (retired) 2014-07-16 15:06:55 UTC
Hi Hkais,

Is it possible for you to check earlier versions of libreoffice, which you can open the document with and scramble its contents without it crashing, so that you can provide us with a sample document.

You can find portable of old versions at these links

Comment 7 QA Administrators 2015-02-19 04:36:25 UTC Comment hidden (obsolete)
Comment 8 QA Administrators 2015-04-01 14:51:52 UTC Comment hidden (obsolete)
Comment 9 Yousuf Philips (jay) (retired) 2015-04-15 13:43:44 UTC
Setting this to NEW as it as a backtrace that devs can look at and i had set to to NeedAdvice.
Comment 10 Nick 2015-05-21 15:47:37 UTC
Created attachment 115772 [details]
Original file, wich, If I open in Document writer, go on endless page creation loop

When I open that document in .docx, or I convert it to .odt, the document go to endless page creation.

Thanks for your help on that strange case.
Comment 11 Robinson Tryon (qubit) 2015-12-10 10:18:57 UTC Comment hidden (obsolete)
Comment 12 Keith Curtis 2016-03-05 21:16:10 UTC
I can't repro this in LibreOffice 5.1 with the sample file, either by adding headings and typing text, or by saving to ODT.

Can you please try again with the latest version and if it still happens, try to give any more guidance on how to repro?
Comment 13 Yousuf Philips (jay) (retired) 2016-03-06 11:26:16 UTC
So opening attachment 115772 [details] in master and the endless page counting happens without me doing any editing and it reached over 2 thousand pages before i closed the document when the document only has 56 pages and all during that time its eating 80+ percent of my cpu.

In earlier versions, like the OP mentioned, once you start editing the document (i was adding page breaks on radom pages), the endless page counting happens and if it doesnt happen, attempt to go to the last page of the document and you'll see it start then. I can reproduce this in 3.3.0, so its inherited.

Something is majorly broken with this.

Build ID: 31e037c348ef0e04393926891617fde1b0051a35
CPU Threads: 2; OS Version: Linux 4.2; UI Render: default; 
TinderBox: Linux-rpm_deb-x86@71-TDF, Branch:master, Time: 2016-03-04_00:22:37
Locale: en-US (en_US.UTF-8)
Comment 14 Michael Meeks 2016-03-07 10:35:06 UTC
Interesting; I can get to the bottom of the document with ctrl-end after load - but clicking into the document there gives me a hang:

Thread 1 (Thread 0x7f0b252bf9c0 (LWP 25053)):
#0  0x00007f0afa4a9a02 in SwCacheObj::GetPrev() (this=0x5005790) at /data/opt/libreoffice/master/sw/source/core/inc/swcache.hxx:147
#1  0x00007f0afa4a7b04 in SwCache::Check() (this=0x28064a0) at /data/opt/libreoffice/master/sw/source/core/bastyp/swcache.cxx:45
#2  0x00007f0afa4a9017 in SwCache::Insert(SwCacheObj*) (this=0x28064a0, pNew=0x4fd7e90) at /data/opt/libreoffice/master/sw/source/core/bastyp/swcache.cxx:334
#3  0x00007f0afa4a9932 in SwCacheAccess::_Get() (this=0x7ffd65184520) at /data/opt/libreoffice/master/sw/source/core/bastyp/swcache.cxx:462
#4  0x00007f0afa9329c3 in SwCacheAccess::Get() (this=0x7ffd65184520) at /data/opt/libreoffice/master/sw/source/core/inc/swcache.hxx:266
#5  0x00007f0afaadfc54 in SwTextLineAccess::GetPara() (this=0x7ffd65184520) at /data/opt/libreoffice/master/sw/source/core/text/txtcache.cxx:47
#6  0x00007f0afaa7407a in SwTextFrame::Format(OutputDevice*, SwBorderAttrs const*) (this=0x509f930, pRenderContext=0x2b50c80) at /data/opt/libreoffice/master/sw/source/core/text/frmform.cxx:1807
#7  0x00007f0afa8f6c5d in SwContentFrame::MakeAll(OutputDevice*) (this=0x509f930) at /data/opt/libreoffice/master/sw/source/core/layout/calcmove.cxx:1392

	... this frame never completes [!] ...

#8  0x00007f0afa8f137d in SwFrame::PrepareMake(OutputDevice*) (this=0x509f930, pRenderContext=0x2b50c80) at /data/opt/libreoffice/master/sw/source/core/layout/calcmove.cxx:341
#9  0x00007f0afa9db773 in SwFrame::Calc(OutputDevice*) const (this=0x509f930, pRenderContext=0x2b50c80) at /data/opt/libreoffice/master/sw/source/core/layout/trvlfrm.cxx:1799
#10 0x00007f0afa94299f in SwHeadFootFrame::FormatSize(long, SwBorderAttrs const*) (this=0x5090ea0, nUL=674, pAttrs=0x4942580) at /data/opt/libreoffice/master/sw/source/core/layout/hffrm.cxx:253
#11 0x00007f0afa943298 in SwHeadFootFrame::Format(OutputDevice*, SwBorderAttrs const*) (this=0x5090ea0, pRenderContext=0x2b50c80, pAttrs=0x4942580) at /data/opt/libreoffice/master/sw/source/core/layout/hffrm.cxx:418
#12 0x00007f0afa8f4317 in SwLayoutFrame::MakeAll(OutputDevice*) (this=0x5090ea0) at /data/opt/libreoffice/master/sw/source/core/layout/calcmove.cxx:909
#13 0x00007f0afa8f137d in SwFrame::PrepareMake(OutputDevice*) (this=0x5090ea0, pRenderContext=0x2b50c80) at /data/opt/libreoffice/master/sw/source/core/layout/calcmove.cxx:341
#14 0x00007f0afa9db773 in SwFrame::Calc(OutputDevice*) const (this=0x5090ea0, pRenderContext=0x2b50c80) at /data/opt/libreoffice/master/sw/source/core/layout/trvlfrm.cxx:1799
#15 0x00007f0afa96c045 in lcl_FormatLay(SwLayoutFrame*) (pLay=0x5090ea0) at /data/opt/libreoffice/master/sw/source/core/layout/pagechg.cxx:357
#16 0x00007f0afa96c010 in lcl_FormatLay(SwLayoutFrame*) (pLay=0x508df80) at /data/opt/libreoffice/master/sw/source/core/layout/pagechg.cxx:354
#17 0x00007f0afa96c4e3 in SwPageFrame::PreparePage(bool) (this=0x508df80, bFootnote=false) at /data/opt/libreoffice/master/sw/source/core/layout/pagechg.cxx:453
#18 0x00007f0afa96edb8 in SwFrame::InsertPage(SwPageFrame*, bool) (this=0x50a73d0, pPrevPage=0x50a4f50, bFootnote=false) at /data/opt/libreoffice/master/sw/source/core/layout/pagechg.cxx:1226
#19 0x00007f0afa9099be in SwFrame::GetNextLeaf(MakePageType) (this=0x50a73d0, eMakePage=MAKEPAGE_INSERT) at /data/opt/libreoffice/master/sw/source/core/layout/flowfrm.cxx:983
#20 0x00007f0afa90928e in SwFrame::GetLeaf(MakePageType, bool) (this=0x50a73d0, eMakePage=MAKEPAGE_INSERT, bFwd=true) at /data/opt/libreoffice/master/sw/source/core/layout/flowfrm.cxx:793
#21 0x00007f0afa90c17e in SwFlowFrame::MoveFwd(bool, bool, bool) (this=0x50a7478, bMakePage=true, bPageBreak=false, bMoveAlways=false) at /data/opt/libreoffice/master/sw/source/core/layout/flowfrm.cxx:1839
#22 0x00007f0afa8f5c8f in SwContentFrame::MakeAll(OutputDevice*) (this=0x50a73d0) at /data/opt/libreoffice/master/sw/source/core/layout/calcmove.cxx:1225
#23 0x00007f0afa8f1945 in SwFrame::PrepareCursor() (this=0x2fcccf0) at /data/opt/libreoffice/master/sw/source/core/layout/calcmove.cxx:416
#24 0x00007f0afa4d77a2 in SwCursorShell::UpdateCursor(unsigned short, bool) (this=0x2ed1d80, eFlags=6, bIdleEnd=false) at /data/opt/libreoffice/master/sw/source/core/crsr/crsrsh.cxx:1716
#25 0x00007f0afa4d0dd6 in SwCursorShell::EndAction(bool, bool) (this=0x2ed1d80, bIdleEnd=false, DoSetPosX=true) at /data/opt/libreoffice/master/sw/source/core/crsr/crsrsh.cxx:294
#26 0x00007f0afa4d1023 in SwCursorShell::EndCursorMove(bool) (this=0x2ed1d80, bIdleEnd=false) at /data/opt/libreoffice/master/sw/source/core/crsr/crsrsh.cxx:330
#27 0x00007f0afa94cae2 in SwLayIdle::SwLayIdle(SwRootFrame*, SwViewShellImp*) (this=0x7ffd65185f90, pRt=0x2a8f8a0, pI=0x29f5eb0) at /data/opt/libreoffice/master/sw/source/core/layout/layact.cxx:2229
#28 0x00007f0afadfa8ac in SwViewShell::LayoutIdle() (this=0x2ed1d80) at /data/opt/libreoffice/master/sw/source/core/view/viewsh.cxx:719
#29 0x00007f0afa66e700 in sw::DocumentTimerManager::DoIdleJobs(Idle*) (this=0x2878a70, pIdle=0x2878a88) at /data/opt/libreoffice/master/sw/source/core/doc/DocumentTimerManager.cxx:119
#30 0x00007f0afa66e43b in sw::DocumentTimerManager::LinkStubDoIdleJobs(void*, Idle*) (instance=0x2878a70, data=0x2878a88) at /data/opt/libreoffice/master/sw/source/core/doc/DocumentTimerManager.cxx:81
#31 0x00007f0b1c8fbcff in Link<Idle*, void>::Call(Idle*) const (this=0x2878aa8, data=0x2878a88) at /data/opt/libreoffice/master/include/tools/link.hxx:84
#32 0x00007f0b1ce4b929 in Idle::Invoke() (this=0x2878a88) at /data/opt/libreoffice/master/vcl/source/app/idle.cxx:25

Really though - I'm not writer expert; what advice can I give ? there is some bug specific to this document; and it'd be great to fix it. Un-CC'ing =)
Comment 15 Yousuf Philips (jay) (retired) 2016-03-07 10:47:15 UTC
@Oliver: Samuel suggested i add you here. :D
Comment 16 Xisco Faulí 2016-09-19 15:29:39 UTC Comment hidden (obsolete)
Comment 17 Julien Nabet 2016-09-29 21:06:44 UTC
I've already seen the bt provided by Michael (see https://bugs.documentfoundation.org/show_bug.cgi?id=80392#c14) in other bugs.
It should be good to list them all and put them in "See also" but, obviously, fixing this tough one may help in quite some bugs.
Comment 18 Caolán McNamara 2017-02-10 10:09:14 UTC
Created attachment 131068 [details]
shorter reproducer

cut this down to a 3 page document which reproduces the problem
Comment 19 QA Administrators 2018-05-03 02:41:52 UTC Comment hidden (obsolete)
Comment 20 Telesto 2018-05-03 18:14:30 UTC
Repro with
Build ID: 2ed7c02478968852d7d39c2c4677f2ecf3441bc7
CPU threads: 4; OS: Windows 6.3; UI render: GL; 
TinderBox: Win-x86@42, Branch:master, Time: 2018-04-22_01:00:56
Locale: nl-NL (nl_NL); Calc: CL
Comment 21 Regis Perdreau 2018-06-16 12:51:24 UTC
Repro with
Build ID: 8c76dfe1284e211954c30f219b3a38dcdd82f8a0
CPU threads: 2; OS: Linux 4.13; UI render: default; VCL: gtk2; 
Locale: fr-FR (fr_FR.UTF-8); Calc: group
Comment 22 Timur 2018-12-27 17:21:15 UTC
Looks like a duplicate of Bug 38575. But let's just CC it for now.
Comment 23 Telesto 2019-06-06 13:06:45 UTC
Repro with
Version: (x86)
Build ID: ac14e5613597e7361ce6995dacb1bb5bd55b6b00
CPU threads: 4; OS: Windows 6.3; UI render: default; VCL: win; 
TinderBox: Win-x86@42, Branch:master, Time: 2019-06-06_05:09:49
Locale: it-IT (nl_NL); UI-Language: en-US
Calc: threaded
Comment 24 Roger 2019-08-27 16:12:14 UTC Comment hidden (spam)
Comment 25 Luke Deller 2019-11-03 11:22:46 UTC
Created attachment 155485 [details]
odt reproducer

Converted Caolán's example from comment 18 to odt format, using the command line:
soffice --convert-to odt tdf80392.docx

This ODT file reproduces the same problem.
Build ID: 83658678e69ba83979c659e37fd3c950942139f9
Comment 26 Julien Nabet 2020-01-27 20:39:56 UTC
Created attachment 157464 [details]
perf flamegraph

On pc Debian x86-64 with master sources updated yesterday + last reproducer file from Luke, I could reproduce this.

The trace shows the well known layout pb (PrepareMake, MakeAll).
IMHO, fixing layout design may help a lot since it would tackle dozens of bugs.
I don't know if it would need a full redesign of layout management or just some fixes but I suppose that if it hasn't been done yet, it's because it must be very complicated.
Should be one of top priorities anyway.
Comment 27 Julien Nabet 2020-01-27 20:51:54 UTC
(In reply to Timur from comment #22)
> Looks like a duplicate of Bug 38575. But let's just CC it for now.

It seems indeed a dup of it, an image anchored in a header which brings infinite loop in layout => page count increases endlessly.
Any reason to not consider this one as a dup?
Comment 28 Timur 2020-01-28 20:39:10 UTC
No. We can mark it. But it's a pity any of these wasn't resolved.

*** This bug has been marked as a duplicate of bug 38575 ***
Comment 29 Timur 2021-06-09 09:36:47 UTC
Fixed in 7.2+. 
LO opens 65 pages and MSO 66 pages (exact differences are not this bug). 

commit ba698a8561700f503cdd7a5cb0bc83d6eaf4222b
Date:   Fri May 21 08:16:39 2021 +0200
    source sha:798b69087119c01a3b51e0bb3240ef35cfededeb
    prev sha:fb5247bf587518eaa01cf5d54dceddf73827d740

author	Daniel Arato (NISZ) <arato.daniel@nisz.hu>	2021-03-24 20:18:16 +0100
committer	László Németh <nemeth@numbertext.org>	2021-05-21 08:00:33 +0200
commit	798b69087119c01a3b51e0bb3240ef35cfededeb (patch)
tree	a498de98b34bacf760b208d3cc650c2a2f68ae58
parent	fb5247bf587518eaa01cf5d54dceddf73827d740 (diff)
tdf#104254 sw DOCX import: fix text wrapping in headers

I mark Fixed because this report was different from bug 104254. Thanks NISZ!

Note: MSO-created DOC also opens, LO opens 68 pages and MSO 61 pages.
Comment 30 Timur 2021-06-09 09:44:15 UTC
Yet another note - I set New again for remaining issue:
fixed is original 66 pages file MSO 14 attachment 115772 [details] DOCX.
not fixed shorter 3 page reproducer MSO 15 attachment 131068 [details] DOCX.
Comment 31 Xisco Faulí 2021-06-10 10:37:35 UTC
(In reply to Timur from comment #30)
> Yet another note - I set New again for remaining issue:
> fixed is original 66 pages file MSO 14 attachment 115772 [details] DOCX.
> not fixed shorter 3 page reproducer MSO 15 attachment 131068 [details] DOCX.

Hi Timur,
Please, create a follow-up ticket instead. this issue is already long enough
Comment 32 Timur 2021-07-16 09:44:15 UTC
3-page DOCX still blocks Writer in LO 7.3.
But not if image removed from header. 
I'll just write that in bug 38575.
Comment 33 Timur 2021-08-12 07:54:23 UTC
Reopen because fix was reverted.