https://bugs.documentfoundation.org/show_bug.cgi?id=165025

            Bug ID: 165025
           Summary: LibreOfficeKit crashes with SIGSEGV during cleanup in
                    LocaleDataWrapper destructor when destroying a
                    LibreOffice instance.
           Product: LibreOffice
           Version: 24.8.4.2 release
          Hardware: All
                OS: Linux (All)
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: sdk
          Assignee: [email protected]
          Reporter: [email protected]

Description:
LibreOfficeKit crashes with a segmentation fault (SIGSEGV) during the cleanup
process when a LibreOffice instance is destroyed. This occurs specifically
within the destructor of the LocaleDataWrapper class. The crash happens after
all document operations (loading, saving) are completed successfully, but
before the program terminates. This issue affects applications integrating
LibreOfficeKit, particularly those that create and destroy instances
frequently. The problem appears to be related to locale handling during the
shutdown sequence.



Steps to Reproduce:
1.Create a C++ program using LibreOfficeKit that initializes a LibreOffice
instance, loads a document, saves it, and then destroys both the document and
LibreOffice instance. Use the provided code as a template:

#include <LibreOfficeKit/LibreOfficeKit.h>
#include <LibreOfficeKit/LibreOfficeKitInit.h>
#include <iostream>
#include <fstream>

int main() {
    LibreOfficeKit* lok = lok_init("/usr/lib/libreoffice/program");
    if (!lok) {
        return 1;
    }

    // Create and load a test document
    std::ofstream test_doc("test.odt");
    test_doc << "Test document";
    test_doc.close();

    LibreOfficeKitDocument* doc = lok->pClass->documentLoad(lok, "test.odt");
    if (doc) {
        doc->pClass->saveAs(doc, "test_save.odt", "odt", nullptr);
        doc->pClass->destroy(doc);
    }

    lok->pClass->destroy(lok);
    return 0;
}


2.Compile the program using the command:

g++ -std=c++17 test.cpp -o test $(pkg-config --cflags --libs libreofficekit)


3.Run the compiled program:

./test

Actual Results:
The program crashes with a segmentation fault (SIGSEGV) during the cleanup
process after all document operations are completed. The stack trace points to
a crash within the LocaleDataWrapper destructor. The following error message is
seen:

Fatal exception: Signal 11
Stack:
#0 /usr/lib/libreoffice/program/libuno_sal.so.3(_ZN3sal13backtrace_getEj+0x30)
#1 /usr/lib/libreoffice/program/libuno_sal.so.3(+0x41ce5)
#2 /usr/lib/libreoffice/program/libuno_sal.so.3(+0x41f2a)
#3 /lib/x86_64-linux-gnu/libc.so.6(+0x42520)
#4 /usr/lib/libreoffice/program/libuno_sal.so.3(rtl_uString_release+0x4)
#5 /usr/lib/libreoffice/program/libmergedlo.so(_ZN17LocaleDataWrapperD1Ev+0x17)

Expected Results:
The program should terminate cleanly without any crashes after all document
operations are finished.




Reproducible: Always


User Profile Reset: No

Additional Info:
OS: Ubuntu 22.04 LTS (via WSL2)

LibreOffice Version: 24.8.4.2

Build ID: 480(Build:2)

Compiler: GCC

C++ Standard: C++17

This issue was discovered while developing a C++ bridge for LibreOffice
integration

The crash is reproducible with both simple and complex documents

The issue persists across multiple program runs

Workarounds are currently in place (instance pooling, signal catching,
try/catch blocks around destroy), but a proper fix is needed.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to