Bug 91807 - Writer crashes when saving (OS X) or gives "write error" then saves corrupt file (Win 8)
Summary: Writer crashes when saving (OS X) or gives "write error" then saves corrupt f...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: filters and storage (show other bugs)
Version:
(earliest affected)
4.4.0.3 release
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: odf target:5.3.0 target:5.1.5 target:...
Keywords: dataLoss, regression
Depends on:
Blocks:
 
Reported: 2015-06-02 10:05 UTC by dz
Modified: 2016-10-25 18:54 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments
Some stuff about heat transfer with corrupted formulas (405.00 KB, application/vnd.oasis.opendocument.text)
2015-06-02 10:05 UTC, dz
Details
LO 5.3 master crash log when attempting to save as (1.41 MB, text/plain)
2016-06-22 14:58 UTC, steve -_-
Details
this fixes the hang and brings us back to corrupting the output (637 bytes, patch)
2016-06-23 08:28 UTC, Caolán McNamara
Details

Note You need to log in before you can comment on or make changes to this bug.
Description dz 2015-06-02 10:05:04 UTC
Created attachment 116234 [details]
Some stuff about heat transfer with corrupted formulas

Dear all,
I've got an ODT document with some thermodynamics formulas I have been editing mainly on my OS X 10.10 Mac. 
I don't know if it was a problem with tables or formulas within tables or what else, but at some point Writer started crashing when saving the file. 
In the beginning, after reopening LibreOffice and recovering the document, I would work around the problem by Saving As... and giving the file a new name. 
Now even saving a new file completely crashes LibreOffice. 

If I start LibreOffice from the command line, I open the file, just add a space in order to set a modified state and then save it, I get this:

libc++abi.dylib: terminating with uncaught exception of type com::sun::star::packages::zip::ZipIOException
Abort trap: 6

Now I'm getting the same if I try to save it with a new name without editing. 
At some point (can't remember how I was saving the file) I also got this:

libc++abi.dylib: terminating with uncaught exception of type com::sun::star::io::NotConnectedException
Abort trap: 6

In the meantime, some formulas got corrupted and double clicking on their placeholders outputs a "General OLE Error".
At first I was using 4.4.3. Then I tried upgrading to 4.4.4.1.0, but nothing changed. That is the version I got the errors above with.
I tried deleting my user profile directory. I tried installing version 4.3.7.2, but it is the same. I tried opening the same file on 4.3.5.2 on Windows 8. There, opening the file read only and trying to save it with a new name brings out this:

"Error saving the document ...:
General Error.
General input/output error."

Now, I've got no doubt the document is badly corrupted, but I wonder what I did in order to get it in such a pitiful state. 
I'm going to attach the newest near-to-usable version of the "maudit" document so that you can see for yourself. 

Thank you in advance for any help you might give me. I enjoying using LibreOffice and it is an important part of my workflow, so I hope I can get this solved. Sorry it if is a duplicate of an existing bug.
Comment 1 dz 2015-06-02 10:12:35 UTC
Opening the autorecovered file, eliminating the visibly corrupted formulas (the ones showing "Object ..." instead of the formula itself) and then saving a copy crashes Writer as well.
Comment 2 Carlos Rodriguez 2015-06-09 12:48:08 UTC
Confirmed on:
Comment 3 Carlos Rodriguez 2015-06-09 12:52:58 UTC
(In reply to Carlos Rodriguez from comment #2)
> Confirmed on:

Version: 5.0.0.0.beta2+
Build ID: 233a52af646f73a9ef0d53dd27f2823e8c362728
TinderBox: Linux-rpm_deb-x86_64@46-TDF, Branch:libreoffice-5-0, Time: 2015-06-09_08:19:23
Locale: es-ES (es_ES.UTF-8)

Versión: 4.4.3.2 (Crash)
Id. de compilación: 88805f81e9fe61362df02b9941de8e38a9b5fd16
Configuración regional: es_ES 

Version: 4.4.5.0.0+ (Crash)
Build ID: 7f605eb84c2b647a87b9bd96ca91c3170b3c84e6
TinderBox: Linux-rpm_deb-x86_64@46-TDF, Branch:libreoffice-4-4, Time: 2015-06-08_11:05:57
Locale: es_ES.UTF-8

Versión: 4.3.7.2
Id. de compilación: 8a35821d8636a03b8bf4e15b48f59794652c68ba
Comment 4 Buovjaga 2015-06-10 14:30:37 UTC
Yeah it happened to me, too with yesterday's master build on Win. Setting to NEW.
Comment 5 mikedsauer 2015-07-12 15:37:02 UTC
I am getting the same thing.  I was getting it with 4.3 and now 4.4.4
I do not have formulas but a number of imbedded diagrams.
Error info on save:
Process:               soffice [1690]
Path:                  /Volumes/VOLUME/LibreOffice.app/Contents/MacOS/soffice
Identifier:            org.libreoffice.script
Version:               4.4.4003 (0)
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           soffice [1690]
User ID:               501

Date/Time:             2015-07-12 09:59:41.581 -0400
OS Version:            Mac OS X 10.10.3 (14D136)
Report Version:        11
Anonymous UUID:        C6E9A03A-DD5A-8E29-3EBC-9032C0EFBFC5

Sleep/Wake UUID:       46C53027-43BD-407C-B809-9A6C49D475F8

Time Awake Since Boot: 11000 seconds
Time Since Wake:       3100 seconds

Crashed Thread:        9

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000

Application Specific Information:
abort() called
terminating with uncaught exception of type com::sun::star::packages::zip::ZipIOException
Comment 6 Michael Stahl (CIB) 2016-06-22 14:12:31 UTC
LO 4.4 added an implementation of multi-threaded zip deflate, which sounds like it has a significant risk of causing issues like this.

the uncaught exception crash should be fixed by:

commit 05661623c7e328c536814354bafd8294de0e9ee0
Author:     Caolán McNamara <caolanm@redhat.com>
AuthorDate: Fri Jun 5 11:45:36 2015 +0100

    uncaught exceptions in parallel deflate threads on re-export of HTB23106 odg
s

master commit 05661623c7e328c536814354bafd8294de0e9ee0 for 5.1.0
libreoffice-5-0 commit 56b5b8aac8729a37814f82b83ebba0d16f87e407 for 5.0.0
libreoffice-4-4 commit c6427d1d5fe398967801ae5f5cd5888afa2a8b14 for 4.4.5

there were a few more crashes fixed just last week, see bug 94212 for details

as to the data-loss / embedded object corruption, it looks like
nobody can reproduce this with current versions.
Comment 7 steve -_- 2016-06-22 14:57:46 UTC
@michael Retested this:

1. open attached file in LO master
2. save as
3. LO hangs

Not sure about exact repro steps here. OP talks about opening from CLI. But this seems to be no requirement to trigger the crash.

Force quitting LO results in attached crash log.

Version: 5.3.0.0.alpha0+
Build ID: e6c004dd9f24c32f5e7468182a5e8d42293ec7b6
CPU Threads: 4; OS Version: Mac OS X 10.11.5; UI Render: default; 
TinderBox: MacOSX-x86_64@49-TDF, Branch:master, Time: 2016-06-17_06:40:25
Locale: de-DE (de.UTF-8)
Comment 8 steve -_- 2016-06-22 14:58:05 UTC
Created attachment 125839 [details]
LO 5.3 master crash log when attempting to save as
Comment 9 Michael Stahl (CIB) 2016-06-22 15:06:43 UTC
oh i just saw this from unzip -t and didn't even try to open the file:

 ...
  error:  invalid compressed data to inflate
    testing: Object 91/settings.xml
  error:  invalid compressed data to inflate
    testing: Object 91/content.xml
  error:  invalid compressed data to inflate
    testing: Object 90/Configurations2/accelerator/current.xml
  error:  invalid compressed data to inflate
    testing: Object 90/settings.xml
  error:  invalid compressed data to inflate
    testing: Object 90/content.xml
  error:  invalid compressed data to inflate
 ...
  testing: ObjectReplacements/Object 81   bad CRC cfdb8175  (should be af2a60e0) 

apparently LO current master opens the file without complaint, which is odd.

probably the embedded objects aren't actually read when the document is opened, but only later when they are edited or exported.
Comment 10 Caolán McNamara 2016-06-23 08:28:14 UTC
The hang started with

7e2ea27e5d56f5cf767a6718a0f5edc28e24af14
Comment 11 Caolán McNamara 2016-06-23 08:28:49 UTC
Created attachment 125853 [details]
this fixes the hang and brings us back to corrupting the output
Comment 12 Commit Notification 2016-06-23 09:44:11 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=8d8b9b80b114b94b20b0bf1438d80e925b49e3bf

package: fix exception handling in DeflateThread (related tdf#91807)

It will be available in 5.3.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 13 Buovjaga 2016-06-23 11:35:26 UTC
dz: a corruption issue, bug 94212, was also fixed.
Could you please test with a fresh master build, after this buildbox comes up with one (the date should be newer than June 23 to include the crash fix): http://dev-builds.libreoffice.org/daily/master/MacOSX-x86_64@49-TDF/current/
Comment 14 Michael Stahl (CIB) 2016-06-23 11:38:17 UTC
with the fix from comment #12 we don't get an infinite loop any more and temporary files are cleaned up when exceptions are thrown,
but the error handling is still suboptimal, the SaveAs pops up
a "General I/O error" dialog which is good but then proceeds to write
the corrupted file anyway, which it probably should not.
Comment 15 Commit Notification 2016-06-23 20:43:29 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=9084c11fb472f2024e609770ce922c911227e7a8

sfx2: exception on storage commit is an error (related: tdf#91807)

It will be available in 5.3.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 16 Michael Stahl (CIB) 2016-06-23 20:59:40 UTC
with the fix from comment #15 LO will now pop up an error dialog and not overwrite the file with an invalid one.
Comment 17 Commit Notification 2016-06-24 15:05:09 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-5-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=60f668ba594c08aa935887ecd0e76d6ba016f166&h=libreoffice-5-1

package: fix exception handling in DeflateThread (related tdf#91807)

It will be available in 5.1.5.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 18 Commit Notification 2016-06-24 15:06:35 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-5-2":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=f8a132e58e2fa4328e47b19bd49386641d115221&h=libreoffice-5-2

package: fix exception handling in DeflateThread (related tdf#91807)

It will be available in 5.2.0.2.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 19 Caolán McNamara 2016-06-24 15:17:08 UTC
Now it doesn't crash or write an utterly corrupted document. Granted it won't *let* you write the document now cause it contains busted sub objects, but at least it doesn't destroy what you already have. Fixed, for limited amounts of fixed I guess.