Bug 38575 - 2-page DOC or DOCX with image anchored to header yields page counting and block Writer
Summary: 2-page DOC or DOCX with image anchored to header yields page counting and blo...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.0.0.3 release
Hardware: All All
: high major
Assignee: Justin L
URL:
Whiteboard: target:26.8.0
Keywords: filter:doc, filter:docx
: 135708 147866 (view as bug list)
Depends on:
Blocks: Layout-Loops, Writer-Loops DOCX-Anchor-and-Text-Wrap DOC-Anchor-and-Text-Wrap DOCX-compatibilityMode-15
  Show dependency treegraph
 
Reported: 2011-06-22 11:05 UTC by Joaquín Cuenca Abela
Modified: 2026-04-16 16:33 UTC (History)
14 users (show)

See Also:
Crash report or crash signature:


Attachments
Doc file that blocks LibreOffice. (93.50 KB, application/msword)
2011-06-22 11:05 UTC, Joaquín Cuenca Abela
Details
perf flamegraph (135.96 KB, application/x-bzip)
2020-01-27 20:48 UTC, Julien Nabet
Details
Docx saved in MSO from Doc (109.98 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2020-10-08 09:17 UTC, Timur
Details
Docx saved in MSO from Doc in bug 135708 (128.44 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2020-10-08 09:57 UTC, Timur
Details
Minimal ODF reproducer (3.18 KB, application/vnd.oasis.opendocument.text)
2024-12-15 09:56 UTC, Mike Kaganski
Details
tdf38575-3_sized_compat15.docx: same problem. Now is 4 pages in MS Word 2024 (67.35 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2026-04-08 00:40 UTC, Justin L
Details
tdf38575-3_sized_compat14.docx: Identical to compat15 except hand-changed to 14. Still 2 pages in MS Word 2024 (66.86 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2026-04-08 00:43 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joaquín Cuenca Abela 2011-06-22 11:05:37 UTC
Created attachment 48294 [details]
Doc file that blocks LibreOffice.

When I try to open the attached document, LibreOffice v3.4.1RC1 blocks. An earlier version of OpenOffice also blocked, on Windows and on Linux. MS Word has no problem with this file.
Comment 1 Björn Michaelsen 2011-12-23 12:28:57 UTC Comment hidden (obsolete)
Comment 2 Joaquín Cuenca Abela 2011-12-24 11:18:48 UTC Comment hidden (obsolete)
Comment 3 Jorendc 2013-02-17 16:01:23 UTC Comment hidden (obsolete)
Comment 4 Kevin Suo 2013-06-27 13:46:28 UTC
(In reply to comment #3)
> This bug still exist using LibreOffice 4.0.0 and Linux Mint 14 x64.
> Opening this file result in an endless loop (page count increase fast and
> infinite) until memory is full.
> 

Just tested and confirms it still exists in LibreOffice 4.0.4.2 Release.

Need to confirm how the example file was created.
Comment 5 Björn Michaelsen 2014-01-17 00:43:38 UTC Comment hidden (obsolete)
Comment 6 Joaquín Cuenca Abela 2014-01-17 10:15:45 UTC
Hi,

I don't know how the original file was created. I run a site that receives word files from journalists (not affiliated with us) and we use LibreOffice to take screenshots of these files.

A good percentage of our files are hit by this bug, and it includes files coming from different sources. I didn't take accurate statistics of the percentage of files that are affected by this bug, so I may be overestimating the problem.

I believe our user sample is big enough to be representative of modern word files created today (probably different from a set of historical word files). The main bias that I know of from our sample is that most of our users are spanish.

In my opinion this bug should stay at highest priority.

Cheers,
Comment 7 Joel Madero 2015-05-02 15:44:08 UTC Comment hidden (obsolete)
Comment 8 Gordo 2015-05-15 18:43:28 UTC
Still reproducible.

The image is anchored to character in the header so that it will repeat on each page.

I was able to stop the loop by Image -> Wrap -> under Options, uncheck Contour and OK.

I also noticed the following:
Under Spacing on the Wrap tab, if you move between tabs then Top and Bottom switch places.

On Crop tab, Original Size is 2.72 cm x 27.76m.  Both Scale and Image Size are set larger.  The page height is 29.70 cm and the Size on Type tab is set to 29.92 cm.  The difference is .22cm which shows up under Spacing.

Going back into the Image dialogue and moving between the tabs and adjusting heights set the loop off again.

Windows Vista 64
Version: 4.4.3.2
Build ID: 88805f81e9fe61362df02b9941de8e38a9b5fd16
Comment 9 QA Administrators 2016-09-20 09:42:21 UTC Comment hidden (obsolete)
Comment 10 Telesto 2016-12-10 16:40:14 UTC
Repro with:
Version: 5.4.0.0.alpha0+
Build ID: b894104a0b02a9b074c76feb925389d7bee6a493
CPU Threads: 4; OS Version: Windows 6.19; UI Render: default; 
TinderBox: Win-x86@39, Branch:master, Time: 2016-12-10_01:00:52
Locale: nl-NL (nl_NL); Calc: CL

Page count increase fast and infinite
Comment 11 QA Administrators 2017-12-11 08:55:17 UTC Comment hidden (obsolete)
Comment 12 Xavier Van Wijmeersch 2017-12-11 19:45:59 UTC
Repro with:
Version: 6.1.0.0.alpha0+
Build ID: ce652a7f0d2745143a3e1078607a72695ce124f9
CPU threads: 8; OS: Linux 4.9; UI render: default; VCL: kde4; 
TinderBox: Linux-rpm_deb-x86_64@70-TDF, Branch:master, Time: 2017-12-10_00:23:13
Locale: nl-BE (en_US.UTF-8); Calc: group threaded

Page count increase fast and infinite
Comment 13 QA Administrators 2018-12-12 03:43:09 UTC Comment hidden (obsolete)
Comment 14 Timur 2018-12-27 17:18:31 UTC
OO couldn't open at all. LO 4.0 opens but counts and blocks. Repro 6.3+.
Comment 15 Timur 2019-11-15 18:01:59 UTC Comment hidden (obsolete)
Comment 16 Timur 2019-11-15 18:05:11 UTC
*** Bug 89150 has been marked as a duplicate of this bug. ***
Comment 17 Julien Nabet 2020-01-27 20:48:28 UTC
Created attachment 157465 [details]
perf flamegraph

On pc Debian x86-64 with master sources updated today, I could reproduce this.

Here's a Flamegraph
Comment 18 Timur 2020-01-28 20:39:10 UTC
*** Bug 80392 has been marked as a duplicate of this bug. ***
Comment 19 Timur 2020-10-08 09:17:28 UTC
Created attachment 166177 [details]
Docx saved in MSO from Doc

Repro 7.1+. 
Let's keep here also DOCX.
Comment 20 Timur 2020-10-08 09:54:38 UTC
*** Bug 135708 has been marked as a duplicate of this bug. ***
Comment 21 Timur 2020-10-08 09:57:15 UTC
Created attachment 166180 [details]
Docx saved in MSO from Doc in bug 135708

DOC attachment 164253 [details] and here attached MSO created DOCX are from bug 135708.
Comment 22 NISZ LibreOffice Team 2020-10-08 10:21:34 UTC Comment hidden (obsolete)
Comment 23 Timur 2020-10-08 12:11:18 UTC Comment hidden (obsolete)
Comment 24 Timur 2021-06-09 07:57:04 UTC
Repro 7.2+ for original DOC and it's DOCX. Checking dupes.
Here are both DOC and DOCX, although just one may be fixed, so only after a new bug should be opened for remaining samples.
Comment 25 Timur 2021-07-16 09:45:37 UTC
Another possible example is 3 page MSO 15 created DOCX attachment 131068 [details]  originally from bug 80392.
Comment 26 Telesto 2022-02-09 11:02:41 UTC
Repro
Version: 7.4.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: ca657b98e49eb2282775f7919827062a7a0b4bfe
CPU threads: 4; OS: Windows 6.3 Build 9600; UI render: Skia/Raster; VCL: win
Locale: nl-NL (nl_NL); UI: en-US
Calc: CL
Comment 27 Xisco Faulí 2022-03-09 11:21:31 UTC
*** Bug 147866 has been marked as a duplicate of this bug. ***
Comment 28 Xisco Faulí 2022-03-10 09:21:07 UTC
*** Bug 100678 has been marked as a duplicate of this bug. ***
Comment 29 Justin L 2023-05-31 11:21:35 UTC
repro 7.6+
Comment 30 Justin L 2024-11-06 19:10:18 UTC
repro 25.2+ with 135765_mergedNumberedCell.odt (attachment 166180 [details]) from comment 21.
Comment 31 Mike Kaganski 2024-12-15 09:56:28 UTC
Created attachment 198117 [details]
Minimal ODF reproducer
Comment 32 Justin L 2026-04-08 00:36:58 UTC
This is a tricky document. An inline shape is 100% wide, which is too big to fit onto any page because the header has text-wrapping over the entire bodyframe limiting the available space to less than 100%.

Don't get bogged down in the fact that it is a percentage based size. If you set it to the non-percentage size the same error will happen. LO doesn't support percentage-sizes, so it converts it to a static size anyway.

Generally we get it right.

The inline shape SHOULD move down until it finds a place to fit on the page (at least for compat15).

It SHOULD move to the next page if it didn't fit on that page.

We just don't have a bail-out for when it can never, ever fit. 


IIUC, we keep adding Dummy line portions down the entire page until we run out of space, and then do it all over again on the following page. And that basically appears to be correct.

P.S. There is some compatibilityMode working here. In compat15, this document in MS Word acts a little bit more like LO does.
How do I know that?
-set the percentage to 99% (in MS Word) so that LO can open the file
-roundtrip the file in LO (to convert the horizontal-line to a normal shape)
-open in MS Word and increase the size of the line.
-save-as in MS Word to remove compatibility.
  => the line is now all by itself on the second page.
but I don't see any compat flags or anything else to indicate a different layout is expected.
Comment 33 Justin L 2026-04-08 00:40:47 UTC
Created attachment 206574 [details]
tdf38575-3_sized_compat15.docx: same problem. Now is 4 pages in MS Word 2024
Comment 34 Justin L 2026-04-08 00:43:53 UTC
Created attachment 206575 [details]
tdf38575-3_sized_compat14.docx: Identical to compat15 except hand-changed to 14.  Still 2 pages in MS Word 2024
Comment 35 Commit Notification 2026-04-16 16:19:40 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/0025f2b2608cf347a81380b1f44a6658e94bc2cd

tdf#38575 sw layout: at 2 empty pages, stop trying to create more

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