sw/source/uibase/uno/unotxdoc.cxx |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 196ac5f5435dfba5bb93e1728c38eb7fa847876d
Author:     Julien Nabet <serval2...@yahoo.fr>
AuthorDate: Wed Nov 10 22:56:53 2021 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Nov 11 16:45:13 2021 +0100

    tdf#145584: fix crash on exporting as PDF with Selection rRange
    
    Regression from 20ddabc88b6b45ea3efcc44ede5244ea526b09c4
    tdf#144989 sw: disable idle jobs during printing or PDF export
    The problem is that (with the kde5 and WNT vclplugs) the idle jobs
    update fields and un-hides every section, which destroys the layout
    that SwXTextDocument::getRendererCount() finalised with great effort
    
    bt:
    0  0x00007f773af65dfa in SwXTextDocument::render(int, 
com::sun::star::uno::Any const&, 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) 
(this=0x66e4980, nRenderer=0, rSelection=
      uno::Any("com.sun.star.uno.XInterface": {_vptr$XInterface = 0x9579020}), 
rxOptions=uno::Sequence of length 8 = {...}) at 
sw/source/uibase/uno/unotxdoc.cxx:3012
    1  0x00007f76ff5f2832 in PDFExport::ExportSelection(vcl::PDFWriter&, 
com::sun::star::uno::Reference<com::sun::star::view::XRenderable> const&, 
com::sun::star::uno::Any const&, StringRangeEnumerator const&, 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>&, int) 
(this=0x7ffc7ee0e990, rPDFWriter=..., rRenderable=uno::Reference to 
(SwXTextDocument *) 0x66e4c38, rSelection=
      uno::Any("com.sun.star.uno.XInterface": {_vptr$XInterface = 0x9579020}), 
rRangeEnum=..., rRenderOptions=uno::Sequence of length 8 = {...}, nPageCount=1) 
at filter/source/pdf/pdfexport.cxx:218
    2  0x00007f76ff5f787e in PDFExport::Export(rtl::OUString const&, 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&)
        (this=0x7ffc7ee0e990, rFile="file:///tmp/lu4uimg.tmp/lu4uimk.tmp", 
rFilterData=uno::Sequence of length 54 = {...}) at 
filter/source/pdf/pdfexport.cxx:949
    3  0x00007f76ff60a4a8 in 
PDFFilter::implExport(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>
 const&) (this=0x71798a0, rDescriptor=uno::Sequence of length 14 = {...})
        at filter/source/pdf/pdffilter.cxx:161
    4  0x00007f76ff60a7fe in 
PDFFilter::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>
 const&) (this=0x71798a0, rDescriptor=uno::Sequence of length 14 = {...})
        at filter/source/pdf/pdffilter.cxx:224
    5  0x00007f7755e60218 in SfxObjectShell::ExportTo(SfxMedium&) 
(this=0x66d2a30, rMedium=...) at sfx2/source/doc/objstor.cxx:2468
    (full bt here:
    https://bugs.documentfoundation.org/attachment.cgi?id=176170)
    
    Valgrind:
    ==619070== Invalid read of size 8
    ==619070==    at 0x19227A60: SwXTextDocument::render(int, 
com::sun::star::uno::Any const&, 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) 
(unotxdoc.cxx:3012)
    ==619070==    by 0x7403: ???
    ==619070==    by 0x1C4A8B57: ???
    ==619070==    by 0x1C4A8BFF: ???
    ==619070==  Address 0x1ed27e08 is 328 bytes inside a block of size 880 
free'd
    ==619070==    at 0x483C71B: operator delete(void*) (vg_replace_malloc.c:923)
    ==619070==    by 0x188EC5CC: SwDoc::release() (doc.cxx:118)
    ==619070==    by 0x1902B92C: clear (ref.hxx:196)
    ==619070==    by 0x1902B92C: SwDocShell::RemoveLink() (docshini.cxx:444)
    ==619070==    by 0x1902B622: SwDocShell::~SwDocShell() (docshini.cxx:372)
    ==619070==    by 0x1902BC07: ~SwDocShell (docshini.cxx:362)
    ==619070==    by 0x1902BC07: ~SwDocShell (docshini.cxx:362)
    ==619070==    by 0x1902BC07: virtual thunk to SwDocShell::~SwDocShell() 
(docshini.cxx:0)
    ==619070==    by 0x18EFA411: ~SfxObjectShellLock (objsh.hxx:863)
    ==619070==    by 0x18EFA411: SwRenderData::~SwRenderData() 
(printdata.cxx:48)
    ==619070==    by 0x19227A2B: operator() (unique_ptr.h:85)
    ==619070==    by 0x19227A2B: reset (unique_ptr.h:182)
    ==619070==    by 0x19227A2B: reset (unique_ptr.h:456)
    ==619070==    by 0x19227A2B: SwXTextDocument::render(int, 
com::sun::star::uno::Any const&, 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) 
(unotxdoc.cxx:3009)
    ==619070==    by 0x21566DB5: PDFExport::ExportSelection(vcl::PDFWriter&, 
com::sun::star::uno::Reference<com::sun::star::view::XRenderable> const&, 
com::sun::star::uno::Any const&, StringRangeEnumerator const&, 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>&, int) 
(pdfexport.cxx:218)
    ==619070==    by 0x2156BB83: PDFExport::Export(rtl::OUString const&, 
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) 
(pdfexport.cxx:949)
    ==619070==    by 0x21572A05: 
PDFFilter::implExport(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>
 const&) (pdffilter.cxx:161)
    ==619070==    by 0x21572F65: 
PDFFilter::filter(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>
 const&) (pdffilter.cxx:224)
    (full Valgrind trace here:
    https://bugs.documentfoundation.org/attachment.cgi?id=176173)
    
    Change-Id: I03a7ec45a62be2729273111a37c1daaaa3bdf664
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125014
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/source/uibase/uno/unotxdoc.cxx 
b/sw/source/uibase/uno/unotxdoc.cxx
index 65ab57970304..698e31cccdd0 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3006,10 +3006,10 @@ void SAL_CALL SwXTextDocument::render(
     }
     if( bLastPage )
     {
-        m_pRenderData.reset();
-        m_pPrintUIOptions.reset();
         // tdf#144989 enable DoIdleJobs() again after last page
         pDoc->getIDocumentTimerAccess().UnblockIdling();
+        m_pRenderData.reset();
+        m_pPrintUIOptions.reset();
     }
 }
 

Reply via email to