Bug 152261 - Inserting a TOC in a document using UNO locks Writer
Summary: Inserting a TOC in a document using UNO locks Writer
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.2.0.0.alpha0+
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: haveBacktrace
Depends on:
Blocks: TableofContents-Indexes
  Show dependency treegraph
 
Reported: 2022-11-28 09:31 UTC by Ludovic Dubost
Modified: 2024-06-03 02:08 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Test case to reproduce the issue. (33.69 KB, application/zip)
2022-11-28 09:31 UTC, Ludovic Dubost
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ludovic Dubost 2022-11-28 09:31:03 UTC
Created attachment 183848 [details]
Test case to reproduce the issue.

I have a program which using the java UNO api using Jodconverter with a Filter which does inserts in ODT documents.

Combining the actions "insert another document and load styles from another document" with a insert TOC or update TOC action locks libreoffice on some documents (not all). The cpu of soffice.bin goes 100% and the jodconverter task timesouts. Debugging in java shows jodconverter waiting. 

The issue reproduces on libreoffice 7.2, 7.3, 7.4.3.2 (ubuntu) and 7.5 alpha from Nov 27*. It also reproduces on Debian 11 with similar versions including 7.5 alpha.

While multiple factors need to be there, the problem seems to be close to the TOC. Removing the TOC insert or update makes the code work. Using a smaller files also makes the code work. 

I have a test case to show when the code is working and when the code is failing and multiple gdb stack traces. Which are attached. See below for indication on how to run the test case.

Here is a sample gdb stack trace on 7.5 alpha (some stack traces are slightly different then this one where tweaking the test case).

libreoffice7.5 (Nov 28) runfailing3 
#0  0x00007fd00d0d71c6 in void std::__cxx1998::vector<hb_feature_t, std::allocator<hb_feature_t> >::_M_realloc_insert<hb_feature_t>(__gnu_cxx::__normal_iterator<hb_feature_t*, std::__cxx1998::vector<hb_feature_t, std::allocator<hb_feature_t> > >, hb_feature_t&&) ()
    at /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/vector.tcc:403
warning: Could not find DWO CU /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/build_master/workdir/CxxObject/sw/source/core/text/inftxt.dwo(0x59e643fd3f397c6f) referenced by CU at offset 0x3ab4 [in module /opt/libreoffice7.5/program/../program/libswlo.so]
#1  0x00007fd00d0d5ea4 in hb_feature_t& std::__cxx1998::vector<hb_feature_t, std::allocator<hb_feature_t> >::emplace_back<hb_feature_t>(hb_feature_t&&) ()
    at /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/vector.tcc:105
warning: Could not find DWO CU /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/build_master/workdir/CxxObject/sw/source/core/text/guess.dwo(0x734c75171111c19c) referenced by CU at offset 0x3a80 [in module /opt/libreoffice7.5/program/../program/libswlo.so]
#2  0x00007fd00d0d496c in hb_feature_t& std::__debug::vector<hb_feature_t, std::allocator<hb_feature_t> >::emplace_back<hb_feature_t>(hb_feature_t&&) ()
    at /opt/rh/devtoolset-7/root/usr/include/c++/7/debug/vector:489
#3  0x00007fd00d0d3468 in __gnu_cxx::__enable_if<!std::__are_same<hb_feature_t, bool>::__value, void>::__type std::__debug::vector<hb_feature_t, std::allocator<hb_feature_t> >::push_back<hb_feature_t>(hb_feature_t&&) () at /opt/rh/devtoolset-7/root/usr/include/c++/7/debug/vector:478
#4  0x00007fd00d0cbc8f in GenericSalLayout::LayoutText(vcl::text::ImplLayoutArgs&, SalLayoutGlyphsImpl const*) ()
    at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/vcl/source/gdi/CommonSalLayout.cxx:299
#5  0x00007fd00cdb5e8b in OutputDevice::ImplLayout(rtl::OUString const&, int, int, Point const&, long, o3tl::span<int const>, o3tl::span<unsigned char const>, SalLayoutFlags, vcl::text::TextLayoutCache const*, SalLayoutGlyphs const*) const ()
    at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/vcl/source/outdev/text.cxx:1410
#6  0x00007fd00cf25a12 in SalLayoutGlyphsCache::GetLayoutGlyphs(VclPtr<OutputDevice const>, rtl::OUString const&, int, int, long, vcl::text::TextLayoutCache const*) () at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/vcl/source/gdi/impglyphitem.cxx:422
#7  0x00007fcff126cc94 in GetTextArray(OutputDevice const&, rtl::OUString const&, std::__debug::vector<int, std::allocator<int> >&, int, int, bool, vcl::text::TextLayoutCache const*) () at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/sw/source/core/txtnode/fntcache.cxx:739
#8  0x00007fcff126ceb2 in GetTextArray(OutputDevice const&, SwDrawTextInfo const&, std::__debug::vector<int, std::allocator<int> >&, int, bool) ()
    at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/sw/source/core/txtnode/fntcache.cxx:755
#9  0x00007fcff1271bd1 in SwFntObj::GetTextSize(SwDrawTextInfo&) ()
    at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/sw/source/core/txtnode/fntcache.cxx:1614
#10 0x00007fcff12cf6f4 in SwSubFont::GetTextSize_(SwDrawTextInfo&) ()
    at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/sw/source/core/txtnode/swfont.cxx:1006
#11 0x00007fcff1102d4f in SwFont::GetTextSize_(SwDrawTextInfo&) () at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/sw/source/core/inc/swfont.hxx:311
#12 0x00007fcff111da3a in SwTextSizeInfo::GetTextSize(SwScriptInfo const*, o3tl::strong_int<int, Tag_TextFrameIndex>, o3tl::strong_int<int, Tag_TextFrameIndex>, unsigned short, unsigned short&, unsigned short&, vcl::text::TextLayoutCache const*) const ()
    at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/sw/source/core/text/inftxt.cxx:432
#13 0x00007fcff1119135 in SwTextGuess::Guess(SwTextPortion const&, SwTextFormatInfo&, unsigned short) ()
    at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/sw/source/core/text/guess.cxx:609
#14 0x00007fcff11b0479 in SwTextPortion::Format_(SwTextFormatInfo&) ()
    at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/sw/source/core/text/portxt.cxx:305
#15 0x00007fcff11b122c in SwTextPortion::Format(SwTextFormatInfo&) ()
    at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/sw/source/core/text/portxt.cxx:462
#16 0x00007fcff116afb4 in SwLineLayout::Format(SwTextFormatInfo&) ()
    at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/sw/source/core/text/porlay.cxx:296
#17 0x00007fcff11421bf in SwTextFormatter::BuildPortions(SwTextFormatInfo&) ()
    at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/sw/source/core/text/itrform2.cxx:597
#18 0x00007fcff1148dce in SwTextFormatter::FormatLine(o3tl::strong_int<int, Tag_TextFrameIndex>) ()



To run the test cases:

1/ Download the officepb.zip
2/ Download jodconverter cli 4.4 zip or tar: https://github.com/sbraconnier/jodconverter/releases/tag/v4.4.4 unzip it inside officepb.zip
3/ If you have jdk11 and libreoffice installed, you should be able to run ./runworking.sh or runfailing1.sh to reproduce the issue. Some debug should show where the code is. If there is no lock the program should end in less than 10 seconds. If not it will wait for the jodconverter timeout.

If somebeody tries the test case and has a difficulty, I can help make it work.

The issue looks similar to:
https://bugs.documentfoundation.org/show_bug.cgi?id=152166
https://bugs.documentfoundation.org/show_bug.cgi?id=150138
https://bugs.documentfoundation.org/show_bug.cgi?id=151736
but I was not able to reproduce this in the writer manually.



Some additional stack traces pastebin:
lo74 https://pastebin.com/T19WtyTE
lo74 https://pastebin.com/6aQ52H2S
lo75 https://pastebin.com/f7niY9h0
lo75 https://pastebin.com/nRFHH8T8
lo75 https://pastebin.com/Sv4ur1kR
Comment 1 Buovjaga 2023-03-08 09:04:45 UTC
I reproduce. I even used the latest jodconverter, updating the scripts with

> APP_HOME="./jodconverter-cli-4.4.6"
> CLASSPATH=$APP_HOME/lib/jodconverter-cli-4.4.6.jar:$APP_HOME/lib/jodconverter-local-4.4.6.jar:$APP_HOME/lib/jodconverter-remote-4.4.6.jar:$APP_HOME/lib/jodconverter-core-4.4.6.jar:$APP_HOME/lib/commons-cli-1.5.0.jar:$APP_HOME/lib/commons-io-2.11.0.jar:$APP_HOME/lib/spring-context-5.3.25.jar:$APP_HOME/lib/spring-aop-5.3.25.jar:$APP_HOME/lib/spring-beans-5.3.25.jar:$APP_HOME/lib/spring-expression-5.3.25.jar:$APP_HOME/lib/spring-core-5.3.25.jar:$APP_HOME/lib/spring-jcl-5.3.25.jar:$APP_HOME/lib/httpmime-4.5.14.jar:$APP_HOME/lib/fluent-hc-4.5.14.jar:$APP_HOME/lib/httpclient-4.5.14.jar:$APP_HOME/lib/commons-codec-1.15.jar:$APP_HOME/lib/gson-2.9.1.jar:$APP_HOME/lib/httpcore-4.4.16.jar:$APP_HOME/lib/slf4j-reload4j-1.7.36.jar:$APP_HOME/lib/slf4j-api-1.7.36.jar:$APP_HOME/lib/juh-4.1.2.jar:$APP_HOME/lib/jurt-4.1.2.jar:$APP_HOME/lib/unoil-4.1.2.jar:$APP_HOME/lib/ridl-4.1.2.jar:$APP_HOME/lib/commons-logging-1.2.jar:$APP_HOME/lib/reload4j-1.2.19.jar

./runfailing1.sh ends for me with

Exception in thread "main" org.jodconverter.core.office.OfficeException: Task did not complete within timeout (120000 ms): LocalConversionTask{source=SourceDocumentSpecsFromFile{file=test-big-notok.xhtml, format=html}, loadProperties={ReadOnly=true, Hidden=true, UpdateDocMode=0}, target=TargetDocumentSpecsFromFile{file=result-test5.odt, format=odt}, storeProperties={FilterName=writerweb8_writer}, useStreamAdapters=false}
        at org.jodconverter.core.office.AbstractOfficeManagerPoolEntry.waitTaskCompletion(AbstractOfficeManagerPoolEntry.java:120)
        at org.jodconverter.core.office.AbstractOfficeManagerPoolEntry.execute(AbstractOfficeManagerPoolEntry.java:86)
        at org.jodconverter.core.office.AbstractOfficeManagerPool.execute(AbstractOfficeManagerPool.java:216)
        at org.jodconverter.local.LocalConverter$LocalConversionJob.doExecute(LocalConverter.java:181)
        at org.jodconverter.core.job.AbstractConversionJob.execute(AbstractConversionJob.java:63)
        at Main.main(Main.java:86)
Caused by: java.util.concurrent.TimeoutException
        at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:204)
        at org.jodconverter.core.office.AbstractOfficeManagerPoolEntry.waitTaskCompletion(AbstractOfficeManagerPoolEntry.java:95)
        ... 5 more

However, there are no stack traces inside your attached file. I guess the one you posted inline is enough.

Arch Linux 64-bit, X11
Version: 7.5.1.2 (X86_64) / LibreOffice Community
Build ID: 50(Build:2)
CPU threads: 8; OS: Linux 6.2; UI render: default; VCL: kf5 (cairo+xcb)
Locale: fi-FI (fi_FI.UTF-8); UI: en-US
7.5.1-1
Calc: CL threaded
Comment 2 Stéphane Guillou (stragu) 2024-06-03 02:08:28 UTC
re-tested with jodconverter 4.4.7 and libobasis24.2-sdk 24.2.3.2-2

To update the scripts, I used:

grep -Irl "jodconverter" . | xargs sed -i 's/4.4.4/4.4.7/g'

With runfailing1.sh, I get the same as Buovjaga:

[...]
Starting loadStyles
Exception in thread "main" org.jodconverter.core.office.OfficeException: Task did not complete within timeout (120000 ms): LocalConversionTask{source=SourceDocumentSpecsFromFile{file=test-big-notok.xhtml, format=html}, loadProperties={ReadOnly=true, Hidden=true, UpdateDocMode=0}, target=TargetDocumentSpecsFromFile{file=result-test5.odt, format=odt}, storeProperties={FilterName=writerweb8_writer}, useStreamAdapters=false}
	at org.jodconverter.core.office.AbstractOfficeManagerPoolEntry.waitTaskCompletion(AbstractOfficeManagerPoolEntry.java:120)
	at org.jodconverter.core.office.AbstractOfficeManagerPoolEntry.execute(AbstractOfficeManagerPoolEntry.java:86)
	at org.jodconverter.core.office.AbstractOfficeManagerPool.execute(AbstractOfficeManagerPool.java:216)
	at org.jodconverter.local.LocalConverter$LocalConversionJob.doExecute(LocalConverter.java:188)
	at org.jodconverter.core.job.AbstractConversionJob.execute(AbstractConversionJob.java:63)
	at Main.main(Main.java:86)
Caused by: java.util.concurrent.TimeoutException
	at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:204)
	at org.jodconverter.core.office.AbstractOfficeManagerPoolEntry.waitTaskCompletion(AbstractOfficeManagerPoolEntry.java:95)
	... 5 more

But even runworking.sh fails in the same way, although later in the process.
Is that expected, Ludovic?