Bug 159844 - double free in __cxa_finalize
Summary: double free in __cxa_finalize
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
24.2.0.3 release
Hardware: All OpenBSD
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-02-22 14:12 UTC by Robert Nagy
Modified: 2024-02-25 03:14 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Nagy 2024-02-22 14:12:59 UTC
Description:
$ scalc --headless --convert-to xlsx:"Calc MS Excel 2007 XML" /tmp/.LQ4drKfGZ7
convert /tmp/.LQ4drKfGZ7 as a Calc document -> /tmp/.LQ4drKfGZ7.xlsx using filter : Calc MS Excel 2007 XML
soffice.bin(77538) in free(): double free 0xe6cca755480


#1  0xfe9f6561c7f1a82f in ?? ()
No symbol table info available.
#2  0x00000e6cec1b1862 in _libc_abort () at /usr/src/lib/libc/stdlib/abort.c:51
        sa = {__sigaction_u = {__sa_handler = 0x3000000010, __sa_sigaction = 0x3000000010}, sa_mask = 1038392016, sa_flags = 28582}
        mask = 4294967263
#3  0x00000e6cec1d09be in wrterror (d=0xe6d2bf1c708, msg=0xe6cec11e41c "double free %p") at /usr/src/lib/libc/stdlib/malloc.c:378
        ap = {{gp_offset = 24, fp_offset = 48, overflow_arg_area = 0x6fa63de49bd0, reg_save_area = 0x6fa63de49ad0}}
        saved_errno = 2
#4  0x00000e6cec1d5fa8 in find_chunknum (d=0x0, info=<optimized out>, ptr=<optimized out>, check=-333786965) at /usr/src/lib/libc/stdlib/malloc.c:1279
        chunknum = <optimized out>
#5  0x00000e6cec1d1d8e in ofree (argpool=0x6fa63de49c70, p=0xe6cca755480, clear=<optimized out>, check=0, argsz=<optimized out>) at /usr/src/lib/libc/stdlib/malloc.c:1677
        info = 0x6
        i = <optimized out>
        tmp = <optimized out>
        pool = 0xe6d2bf1c708
        saved_function = 0xf8d9860b3fbc21f0 <error: Cannot access memory at address 0xf8d9860b3fbc21f0>
        r = 0x9504bb5b29626bf3
        sz = 48
#6  0x00000e6cec1d1a93 in _libc_free (ptr=0xe6cca755480) at /usr/src/lib/libc/stdlib/malloc.c:1747
        saved_errno = 2
        d = 0xe6d2bf1c708
#7  0x00000e6ce873697b in operator delete (ptr=0x0) at /usr/src/gnu/lib/libcxx/../../../gnu/llvm/libcxx/src/new.cpp:133
No locals.
#8  0x00000e6cec17e275 in _libc___cxa_finalize (dso=0x0) at /usr/src/lib/libc/stdlib/atexit.c:177
        call_depth = 1
        pgsize = 4096
        p = 0xe6c8715e000
        n = 41
        fn = {fn_ptr = 0xe6ce86d0390 <std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::~basic_string()>, 
          fn_arg = 0xe6ca3f800a8 <libetonyek::IWORKPropertyInfo<libetonyek::property::SFTTableNameStylePropertyParagraphStyle>::id>, fn_dso = <synthetic pointer>}
        q = <optimized out>
#9  0x00000e6cec140925 in _libc_exit (status=0) at /usr/src/lib/libc/stdlib/exit.c:54
No locals.


Actual Results:
Conversion works, just leaves a coredump and it is a double free somewhere :)

Expected Results:
No double free.


Reproducible: Always


User Profile Reset: No

Additional Info:
None.
Comment 1 Xisco Faulí 2024-02-22 14:56:49 UTC
Thank you for reporting the bug. Please attach a sample document, as this makes it easier for us to verify the bug. 
I have set the bug's status to 'NEEDINFO'. Please change it back to 'UNCONFIRMED' once the requested document is provided.
(Please note that the attachment will be public, remove any sensitive information before attaching it. 
See https://wiki.documentfoundation.org/QA/FAQ#How_can_I_eliminate_confidential_data_from_a_sample_document.3F for help on how to do so.)
Comment 2 Julien Nabet 2024-02-23 17:07:40 UTC
What's "/tmp/.LQ4drKfGZ7" ? I mean it's just a temp of file without extension and possibly without specific format.
Comment 3 Robert Nagy 2024-02-24 07:08:19 UTC
Yes that's a temporary file that includes csv formatted data, but that is actually
irrelevant in this case.
You can create an empty file as well.

$ touch /tmp/tmp.92SyOf6UmZ
$ scalc --headless --convert-to ods /tmp/tmp.92SyOf6UmZ 
convert /tmp/tmp.92SyOf6UmZ as a Calc document -> /home/robert/tmp.ods using filter : calc8
soffice.bin(19854) in free(): double free 0x6f76d02f930

However if you create a file with file extension the double free does not
happen.

$ touch /tmp/tmp.92SyOf6UmZ.csv
$ scalc --headless --convert-to ods /tmp/tmp.92SyOf6UmZ.csv                                              
convert /tmp/tmp.92SyOf6UmZ.csv as a Calc document -> /home/robert/tmp.92SyOf6UmZ.ods using filter : calc8

I assume that the code tries to rely on the file extension and then goes
through the filters to see what format it is.

The output filename is also buggy as if you have a dot in the filename
it will automatically assume that as the extension and the output filepath
is going to be wrong, see the first invocation.
This might be okay behavior on Windows, where the file extension actually matters.
Comment 4 Julien Nabet 2024-02-24 10:47:34 UTC
I gave a try following your last comment:
touch /tmp/tmp.92SyOf6UmZ

soffice --calc --headless --convert-to ods /tmp/tmp.92SyOf6UmZ 
convert /tmp/tmp.92SyOf6UmZ as a Calc document -> /home/julien/lo/libreoffice/instdir/program/tmp.ods using filter : calc8
Overwriting: /home/julien/lo/libreoffice/instdir/program/tmp.ods

I also tried with master sources updated today (with debug):


/soffice --calc --headless --convert-to ods /tmp/tmp.92SyOf6UmZ 
WPSDocument::isFileFormatSupported()
libwps::readU8: can not read data
WPSDocument::isFileFormatSupported()
WPSDocument::isFileFormatSupported()
WPSDocument::isFileFormatSupported()
WPSDocument::isFileFormatSupported()
WPSDocument::isFileFormatSupported()
WPSDocument::isFileFormatSupported()
AbiDocument::isFileFormatSupported
Found xml parser severity error Extra content at the end of the document

WPSDocument::isFileFormatSupported()
VisioDocument: version 0
Found xml parser severity error Extra content at the end of the document

Throwing EndOfStreamException
Throwing EndOfStreamException
warn:legacy.tools:552566:552566:sfx2/source/appl/appuno.cxx:454: invalid type for Stream
convert /tmp/tmp.92SyOf6UmZ as a Calc document -> /home/julien/lo/libreoffice/instdir/program/tmp.ods using filter : calc8
warn:xmloff:552566:552566:xmloff/source/text/XMLTextListAutoStylePool.cxx:164: getStyleFamilies() from XModel failed for export!
warn:xmloff:552566:552566:xmloff/source/style/impastpl.cxx:368: Adding duplicate family table-column with mismatching mapper ! P25SvXMLExportPropertyMapper 25SvXMLExportPropertyMapper
warn:xmloff:552566:552566:xmloff/source/style/impastpl.cxx:368: Adding duplicate family table-row with mismatching mapper ! P25SvXMLExportPropertyMapper 25SvXMLExportPropertyMapper
warn:xmloff:552566:552566:xmloff/source/style/impastpl.cxx:368: Adding duplicate family table-cell with mismatching mapper ! P25SvXMLExportPropertyMapper 28XMLShapeExportPropertyMapper
warn:xmloff:552566:552566:xmloff/source/text/XMLTextListAutoStylePool.cxx:164: getStyleFamilies() from XModel failed for export!
warn:xmloff:552566:552566:xmloff/source/style/impastpl.cxx:368: Adding duplicate family table-column with mismatching mapper ! P25SvXMLExportPropertyMapper 25SvXMLExportPropertyMapper
warn:xmloff:552566:552566:xmloff/source/style/impastpl.cxx:368: Adding duplicate family table-row with mismatching mapper ! P25SvXMLExportPropertyMapper 25SvXMLExportPropertyMapper
warn:xmloff:552566:552566:xmloff/source/style/impastpl.cxx:368: Adding duplicate family table-cell with mismatching mapper ! P25SvXMLExportPropertyMapper 28XMLShapeExportPropertyMapper
warn:xmloff:552566:552566:xmloff/source/text/XMLTextListAutoStylePool.cxx:164: getStyleFamilies() from XModel failed for export!
warn:xmloff:552566:552566:xmloff/source/style/impastpl.cxx:368: Adding duplicate family table-column with mismatching mapper ! P25SvXMLExportPropertyMapper 25SvXMLExportPropertyMapper
warn:xmloff:552566:552566:xmloff/source/style/impastpl.cxx:368: Adding duplicate family table-row with mismatching mapper ! P25SvXMLExportPropertyMapper 25SvXMLExportPropertyMapper
warn:xmloff:552566:552566:xmloff/source/style/impastpl.cxx:368: Adding duplicate family table-cell with mismatching mapper ! P25SvXMLExportPropertyMapper 28XMLShapeExportPropertyMapper
warn:legacy.osl:552566:552566:sc/source/core/data/document.cxx:5525: Wrong index in AttrArray
warn:xmloff:552566:552566:xmloff/source/text/XMLTextListAutoStylePool.cxx:164: getStyleFamilies() from XModel failed for export!
warn:xmloff:552566:552566:xmloff/source/style/impastpl.cxx:368: Adding duplicate family table-column with mismatching mapper ! P25SvXMLExportPropertyMapper 25SvXMLExportPropertyMapper
warn:xmloff:552566:552566:xmloff/source/style/impastpl.cxx:368: Adding duplicate family table-row with mismatching mapper ! P25SvXMLExportPropertyMapper 25SvXMLExportPropertyMapper
warn:xmloff:552566:552566:xmloff/source/style/impastpl.cxx:368: Adding duplicate family table-cell with mismatching mapper ! P25SvXMLExportPropertyMapper 28XMLShapeExportPropertyMapper
warn:legacy.osl:552566:552566:xmloff/source/core/SettingsExportHelper.cxx:177: this type is not implemented now
warn:vcl.schedule.deinit:552566:552566:vcl/source/app/scheduler.cxx:176: DeInit task: Timer a: 1 p: 1 graphic::Manager maSwapOutTimer 10000ms (0x7f3b6ae5b600)
warn:vcl.schedule.deinit:552566:552566:vcl/source/app/scheduler.cxx:197: DeInit active tasks: 1 (ignored: 0)

So no double free here.

I can't help here=>uncc myself.
Comment 5 Robert Nagy 2024-02-24 14:24:43 UTC
Are you using an external or internal libetonyek?
Comment 6 Robert Nagy 2024-02-24 21:48:17 UTC
(In reply to Julien Nabet from comment #4)
> I gave a try following your last comment:
> touch /tmp/tmp.92SyOf6UmZ
> 
> soffice --calc --headless --convert-to ods /tmp/tmp.92SyOf6UmZ 
> convert /tmp/tmp.92SyOf6UmZ as a Calc document ->
> /home/julien/lo/libreoffice/instdir/program/tmp.ods using filter : calc8
> Overwriting: /home/julien/lo/libreoffice/instdir/program/tmp.ods
> 
> I also tried with master sources updated today (with debug):
> 
> 
> /soffice --calc --headless --convert-to ods /tmp/tmp.92SyOf6UmZ 
> WPSDocument::isFileFormatSupported()
> libwps::readU8: can not read data
> WPSDocument::isFileFormatSupported()
> WPSDocument::isFileFormatSupported()
> WPSDocument::isFileFormatSupported()
> WPSDocument::isFileFormatSupported()
> WPSDocument::isFileFormatSupported()
> WPSDocument::isFileFormatSupported()
> AbiDocument::isFileFormatSupported
> Found xml parser severity error Extra content at the end of the document
> 
> WPSDocument::isFileFormatSupported()
> VisioDocument: version 0
> Found xml parser severity error Extra content at the end of the document
> 
> Throwing EndOfStreamException
> Throwing EndOfStreamException
> warn:legacy.tools:552566:552566:sfx2/source/appl/appuno.cxx:454: invalid
> type for Stream
> convert /tmp/tmp.92SyOf6UmZ as a Calc document ->
> /home/julien/lo/libreoffice/instdir/program/tmp.ods using filter : calc8
> warn:xmloff:552566:552566:xmloff/source/text/XMLTextListAutoStylePool.cxx:
> 164: getStyleFamilies() from XModel failed for export!
> warn:xmloff:552566:552566:xmloff/source/style/impastpl.cxx:368: Adding
> duplicate family table-column with mismatching mapper !
> P25SvXMLExportPropertyMapper 25SvXMLExportPropertyMapper
> warn:xmloff:552566:552566:xmloff/source/style/impastpl.cxx:368: Adding
> duplicate family table-row with mismatching mapper !
> P25SvXMLExportPropertyMapper 25SvXMLExportPropertyMapper
> warn:xmloff:552566:552566:xmloff/source/style/impastpl.cxx:368: Adding
> duplicate family table-cell with mismatching mapper !
> P25SvXMLExportPropertyMapper 28XMLShapeExportPropertyMapper
> warn:xmloff:552566:552566:xmloff/source/text/XMLTextListAutoStylePool.cxx:
> 164: getStyleFamilies() from XModel failed for export!
> warn:xmloff:552566:552566:xmloff/source/style/impastpl.cxx:368: Adding
> duplicate family table-column with mismatching mapper !
> P25SvXMLExportPropertyMapper 25SvXMLExportPropertyMapper
> warn:xmloff:552566:552566:xmloff/source/style/impastpl.cxx:368: Adding
> duplicate family table-row with mismatching mapper !
> P25SvXMLExportPropertyMapper 25SvXMLExportPropertyMapper
> warn:xmloff:552566:552566:xmloff/source/style/impastpl.cxx:368: Adding
> duplicate family table-cell with mismatching mapper !
> P25SvXMLExportPropertyMapper 28XMLShapeExportPropertyMapper
> warn:xmloff:552566:552566:xmloff/source/text/XMLTextListAutoStylePool.cxx:
> 164: getStyleFamilies() from XModel failed for export!
> warn:xmloff:552566:552566:xmloff/source/style/impastpl.cxx:368: Adding
> duplicate family table-column with mismatching mapper !
> P25SvXMLExportPropertyMapper 25SvXMLExportPropertyMapper
> warn:xmloff:552566:552566:xmloff/source/style/impastpl.cxx:368: Adding
> duplicate family table-row with mismatching mapper !
> P25SvXMLExportPropertyMapper 25SvXMLExportPropertyMapper
> warn:xmloff:552566:552566:xmloff/source/style/impastpl.cxx:368: Adding
> duplicate family table-cell with mismatching mapper !
> P25SvXMLExportPropertyMapper 28XMLShapeExportPropertyMapper
> warn:legacy.osl:552566:552566:sc/source/core/data/document.cxx:5525: Wrong
> index in AttrArray
> warn:xmloff:552566:552566:xmloff/source/text/XMLTextListAutoStylePool.cxx:
> 164: getStyleFamilies() from XModel failed for export!
> warn:xmloff:552566:552566:xmloff/source/style/impastpl.cxx:368: Adding
> duplicate family table-column with mismatching mapper !
> P25SvXMLExportPropertyMapper 25SvXMLExportPropertyMapper
> warn:xmloff:552566:552566:xmloff/source/style/impastpl.cxx:368: Adding
> duplicate family table-row with mismatching mapper !
> P25SvXMLExportPropertyMapper 25SvXMLExportPropertyMapper
> warn:xmloff:552566:552566:xmloff/source/style/impastpl.cxx:368: Adding
> duplicate family table-cell with mismatching mapper !
> P25SvXMLExportPropertyMapper 28XMLShapeExportPropertyMapper
> warn:legacy.osl:552566:552566:xmloff/source/core/SettingsExportHelper.cxx:
> 177: this type is not implemented now
> warn:vcl.schedule.deinit:552566:552566:vcl/source/app/scheduler.cxx:176:
> DeInit task: Timer a: 1 p: 1 graphic::Manager maSwapOutTimer 10000ms
> (0x7f3b6ae5b600)
> warn:vcl.schedule.deinit:552566:552566:vcl/source/app/scheduler.cxx:197:
> DeInit active tasks: 1 (ignored: 0)
> 
> So no double free here.
> 
> I can't help here=>uncc myself.


The problem seems to be that all wpft{calc,impress,draw...} libraries link
to libetonyek and in the case of an unknown file extension the modules are loaded one after the other and on teardown cxa_finalize will get called multiple times.
Comment 7 QA Administrators 2024-02-25 03:14:42 UTC Comment hidden (obsolete)