Bug Hunting Session
Bug 108402 - Avoid crash if filter doesn't match (soffice --convert-to "html:XHTML Writer File UTF8" file.ods)
Summary: Avoid crash if filter doesn't match (soffice --convert-to "html:XHTML Writer ...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
4.1 all versions
Hardware: All All
: medium major
Assignee: Not Assigned
URL:
Whiteboard: target:6.2.0 target:6.1.3
Keywords: haveBacktrace
Depends on:
Blocks: Save-Text
  Show dependency treegraph
 
Reported: 2017-06-07 22:21 UTC by Mikhail
Modified: 2018-11-13 07:49 UTC (History)
5 users (show)

See Also:
Crash report or crash signature: ["SwXMLExport::getDoc()"]


Attachments
bt with debug symbols (10.88 KB, text/plain)
2017-06-13 21:00 UTC, Julien Nabet
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mikhail 2017-06-07 22:21:14 UTC
No html or txt file is created in UTF8 after convert:

soffice --invisible --convert-to "html:XHTML Writer File:UTF8" --outdir "C:\Users\User\Desktop" "C:\Users\User\Desktop\test_calc.xls"

soffice --invisible --convert-to "txt:Text (encoded):UTF8" --outdir "C:\Users\User\Desktop" "C:\Users\User\Desktop\test_calc.ods"


=====
crashreport.libreoffice.org/stats/crash_details/7fe9e694-9d71-419e-8124-99a5ca496906
Comment 1 Maxim Monastirsky 2017-06-08 08:20:24 UTC
(In reply to Mikhail from comment #0)
> No html or txt file is created in UTF8 after convert:
> 
> soffice --invisible --convert-to "html:XHTML Writer File:UTF8" --outdir
> "C:\Users\User\Desktop" "C:\Users\User\Desktop\test_calc.xls"
> 
> soffice --invisible --convert-to "txt:Text (encoded):UTF8" --outdir
> "C:\Users\User\Desktop" "C:\Users\User\Desktop\test_calc.ods"
That's expected, as the used filter names are wrong. The correct names are "XHTML Calc File" and "Text - txt - csv (StarCalc)".

> crashreport.libreoffice.org/stats/crash_details/7fe9e694-9d71-419e-8124-
> 99a5ca496906
Well, if there is indeed a crash (didn't check) then it should be dealt with. But let's move to UNCONFIRMED, to let QA handle this bug first.
Comment 2 Buovjaga 2017-06-11 11:28:28 UTC
No crash for me with Version: 5.5.0.0.alpha0+
Build ID: b08217989558addbcaded122a4e7211ae24bbcff
CPU threads: 4; OS: Windows 6.19; UI render: default; 
TinderBox: Win-x86@42, Branch:master, Time: 2017-05-31_06:31:36
Locale: fi-FI (fi_FI); Calc: group

But the dump exists for Mikhail, so let's leave it open..
Comment 3 Julien Nabet 2017-06-13 21:00:43 UTC
Created attachment 134006 [details]
bt with debug symbols

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

I just created a brand new xls file with a cell containing "test"
Comment 4 QA Administrators 2018-06-18 02:42:53 UTC Comment hidden (obsolete)
Comment 5 Xisco Faulí 2018-06-18 15:47:04 UTC
In

Version: 6.2.0.0.alpha0+
Build ID: d60d695fcc5064e1f16842387fdce23456a64694
CPU threads: 4; OS: Linux 4.13; UI render: default; VCL: gtk3; 
Locale: ca-ES (ca_ES.UTF-8); Calc: group threaded

i get this message

func=xmlSecCheckVersionExt:file=xmlsec.c:line=188:obj=unknown:subj=unknown:error=19:invalid version:mode=abi compatible;expected minor version=2;real minor version=2;expected subminor version=25;real subminor version=26
convert /home/xisco/Baixades/test.ods -> /home/xisco/Escriptori//test.html using filter : XHTML Writer File:UTF8
Application Error

while in previous version, I get

convert /home/xisco/Baixades/test.ods -> /home/xisco/Escriptori//test.html using filter : XHTML Writer File:UTF8
Error: Please verify input parameters... (SfxBaseModel::impl_store <file:///home/xisco/Escriptori//test.html> failed: 0x11b)

back to 

Version 4.1.0.0.alpha0+ (Build ID: efca6f15609322f62a35619619a6d5fe5c9bd5a)
Comment 6 Xisco Faulí 2018-06-18 15:47:34 UTC
@Miklos, I thought you might be interested in this issue...
Comment 7 Julien Nabet 2018-07-23 15:15:54 UTC
On pc Debian x86-64 with master sources updated some days ago, I could still reproduce this.

The pb is here:
    513 SwDoc* SwXMLExport::getDoc()
    514 {
    515     if( m_pDoc != nullptr )
    516         return m_pDoc;
    517     Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
xTextDoc is emptyRef here because GetModel() retrieves mxModel which is "uno::Reference to (ScModelObj *)" (expected since we got a Calc file)

With this patch:
diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx
index 8a7da0693df1..420e5974011e 100644
--- a/sw/source/filter/xml/xmlexp.cxx
+++ b/sw/source/filter/xml/xmlexp.cxx
@@ -515,6 +515,9 @@ SwDoc* SwXMLExport::getDoc()
     if( m_pDoc != nullptr )
         return m_pDoc;
     Reference < XTextDocument > xTextDoc( GetModel(), UNO_QUERY );
+    if (!xTextDoc)
+        throw css::uno::RuntimeException("Problem of mismatching filter for export.");
+
     Reference < XText > xText = xTextDoc->getText();
     Reference<XUnoTunnel> xTextTunnel( xText, UNO_QUERY);
     assert( xTextTunnel.is());

I got:
warn:xmloff:19932:19932:xmloff/source/core/xmlerror.cxx:170: An error or a warning has occurred during XML import/export!
Error-Id: 0x60040004
    Flags: 6 ERROR SEVERE
    Class: 4 API
    Number: 4
Parameters:
Exception-Message: com.sun.star.uno.RuntimeException: "Problem of mismatching filter for export."

Would it be ok?
Comment 8 Franz 2018-09-05 22:03:44 UTC
problem keeps popping up with various releases and I think based on the code in
https://github.com/lsh123/xmlsec/blob/master/src/xmlsec.c
that generates the message that this is an installation problem.

Nertheless it has grave consequences for the user and it should be handled during start time as libreoffice will close upon any attempt to write a file (reading will work) and it closes without any message for those that did not start libreoffice via a shell or a command window in Windows.

Those starting libreoffice in a terminal get the above message, which is pointer in the right direction but does not really help solving the problem.
If the libxml library is required for saving anything, the presence of the right library should be checked during startup and a remedy should be suggested.

The simple remedy is to reinstall libreoffice including all depending packages, but that usually breaks some other installation (software) that introduced the problem. If the library is that important it should be included in the installation at least as a fall back (if checking the library in the path will lead to the error message explained, the program should try to recover and use the one in the installation directory and if everything fails it should print out a comprehensive error message).

kind regards
Franz Gotsis
Comment 9 Miklos Vajna 2018-09-06 07:10:33 UTC
I expect this has nothing to do with xmlsec. xmlsec changed the API on how you register IO callbacks, so we check for the version, and somewhat annoyingly you get an error line when the version check returns false, but that's all fine, we handle both positive and negative outcome of the version check.
Comment 10 Julien Nabet 2018-09-12 19:40:00 UTC
Let's try this to avoid the crash at least:
https://gerrit.libreoffice.org/#/c/60413/
Comment 11 Commit Notification 2018-09-20 06:33:33 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=475ea37809b5bec369d02a5ab500fac46ab40f0a

tdf#108402: avoid crash if filter doesn't match

It will be available in 6.2.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 12 Commit Notification 2018-09-20 12:12:07 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-6-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=7d703f00ed94b0d6ea44132896f1926fb68c1c04&h=libreoffice-6-1

tdf#108402: avoid crash if filter doesn't match

It will be available in 6.1.3.

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 Mark Hedges 2018-11-13 06:48:35 UTC
I have a problem in 6.1.3.2 on Windows 10, or something like it.  It has cost me a lot of time due to data loss.  (I work on some file X, then I open file Y that causes the crash, and I lose my work in X.)  I am pulling my hair out.  This is incredibly annoying.  I don't know how to build this on Windows so I don't know how to debug.  I can open the file fine in Ubuntu Linux Subsystem using 6.0.6.2.  I don't know what's going on.  I am at my wit's end here.

The only thing similar to this bug and 118373 is:

func=xmlSecCheckVersionExt:file=xmlsec.c:line=188:obj=unknown:subj=unknown:error=19:invalid version:mode=abi compatible;expected minor version=2;real minor version=2;expected subminor version=25;real subminor version=26

Am I seeing a different bug?  What do I do to diagnose?
Comment 14 Julien Nabet 2018-11-13 07:49:33 UTC
(In reply to Mark Hedges from comment #13)
> ...
> Am I seeing a different bug?  What do I do to diagnose?

Please submit a new bug.
Yours is unrelated to this one which is fixed.