Bug 155010 - LibreOffice writer crashes when opening malformed docx file
Summary: LibreOffice writer crashes when opening malformed docx file
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.3.7.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected, haveBacktrace, regression
Depends on:
Blocks: DOCX-Limitations Crash
  Show dependency treegraph
 
Reported: 2023-04-25 14:44 UTC by Jan Just Keijser
Modified: 2024-02-16 21:25 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
Test docx that causes the stack overflow (16.15 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2023-04-25 14:44 UTC, Jan Just Keijser
Details
bt with debug symbols (9.31 KB, text/plain)
2023-04-26 09:09 UTC, Julien Nabet
Details
BT with symbols macOS (1.62 MB, text/plain)
2023-04-26 20:34 UTC, Telesto
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Just Keijser 2023-04-25 14:44:37 UTC
Created attachment 186918 [details]
Test docx that causes the stack overflow

LibreOffice 7.3.7.2 (Fedora 36) as well as v7.5 on Windows crash when trying to open a docx file that is autogenerated by an audio transcription service. 

Attached is a very simple file that causes the segfault. It seems related to the multiple word/_rels in the docx file. If I do

`zip -d test-file.docx word/_rels/header?.xml.rels word/_rels/footer?.xml.rels`

then LibreOffice correctly opens the file.
Valgrind seems to suggest a stack overflow somewhere - if I can increase the stack size, it does take a bit longer to crash, but it still segfaults.

Reproducability: 100%
Comment 1 Telesto 2023-04-25 21:01:31 UTC
Confirm
Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 066b23115c2a360507e306a88da572554daefab7
CPU threads: 8; OS: Mac OS X 12.6.3; UI render: Skia/Raster; VCL: osx
Locale: nl-NL (nl_NL.UTF-8); UI: en-US
Calc: threaded
Comment 2 Julien Nabet 2023-04-26 09:09:18 UTC
Created attachment 186931 [details]
bt with debug symbols

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

OOXMLDocumentImpl::resolveEmbeddingsStream is present a lot of times.
Comment 3 Telesto 2023-04-26 20:34:27 UTC
Created attachment 186945 [details]
BT with symbols macOS

My BT is slightly different. Adding, just in case
Comment 4 Roman Kuznetsov 2023-05-03 20:18:03 UTC
Version: 4.2.8.2
Build ID: 48d50dbfc06349262c9d50868e5c1f630a573ebd

opens the file

but

Version: 4.3.7.2
Build ID: 8a35821d8636a03b8bf4e15b48f59794652c68ba

doesn't open the file and hangs (I just killed the soffice process after some time)

So it looks like an old regression
Comment 5 raal 2023-05-04 16:09:22 UTC
This seems to have begun at the below commit in bibisect repository/OS bibisect-43max/Linux.
Adding Cc: to sushil_shinde ; Could you possibly take a look at this one?
Thanks
 901d4d3b18ebe50022f95017287ac564fc16410d is the first bad commit
commit 901d4d3b18ebe50022f95017287ac564fc16410d
Author: Matthew Francis <mjay.francis@gmail.com>
Date:   Thu May 28 20:29:30 2015 +0800

    source-hash-23b65a84fd827555dfb84c7e2f78879c479c2f78
    
    commit 23b65a84fd827555dfb84c7e2f78879c479c2f78
    Author:     sushil_shinde <sushil.shinde@synerzip.com>
    AuthorDate: Wed Mar 19 18:34:45 2014 +0530
    Commit:     Miklos Vajna <vmiklos@collabora.co.uk>
    CommitDate: Sun Mar 23 11:02:16 2014 +0100
    
        fdo#76356 : Docx file contianing chart in footer/header gets corrupted.
    
            -  Docx file with chart in footer/header or .bin file referred in chart
               was getting corrupted.
            -  Embedded file for footer.xml was not grabbaged.
            -  .bin embedded files were not grab baged.
            -  Added grab bag support for both case.
            -  Added UT to check .bin files are grab baged properly.
    
        Reviewed on:
            https://gerrit.libreoffice.org/8674
Comment 6 Roman Kuznetsov 2023-05-05 05:19:29 UTC
Miklos, may be you will interesting with this one too while you are working around DOCX crash area...
Comment 7 Miklos Vajna 2023-05-05 06:57:39 UTC
Somehow OOXMLDocumentImpl::resolveEmbeddingsStream() decides to call itself again and again, but I don't have more details at hand.
Comment 8 Tex2002ans 2024-02-16 21:25:56 UTC
CRASH:

- https://crashreport.libreoffice.org/stats/crash_details/945cf4ad-f3c4-4a1d-91b2-a7ff6b402665

All I did was open the attachment in comment 0 using:

Version: 24.2.0.3 (X86_64) / LibreOffice Community
Build ID: da48488a73ddd66ea24cf16bbc4f7b9c08e9bea1
CPU threads: 8; OS: Windows 10.0 Build 22631; UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL threaded