Ask Your Question
0

Seg fault in basic Libre Office SDK 5.2 C++ Ubuntu 14.04 Server [closed]

asked 2016-09-01 18:13:11 +0200

hamish gravatar image

updated 2020-07-08 21:50:39 +0200

Alex Kemp gravatar image

Sample application similar to some found on the web fails at the the very end with a segmentation violation with backtrace:

 #0  0x00007ffff489b723 in cpp_vtable_call ()
    from /opt/libreoffice5.2/program/libgcc3_uno.so
 #1  0x00007ffff48a26ea in privateSnippetExecutor ()
    from /opt/libreoffice5.2/program/libgcc3_uno.so
 #2  0x0000000000401ea9 in main ()

Example was built using Libreoffice 5.2 SDK. Code and makefile below.

The same code, embedded in a larger application, fails at the XComponentLoader call - with the same backtrace.

A somewhat similar example fails on the xComponentLoader->loadComponentFromURL call (backtrace terminating on that line; the file and directory parameters passed into that method look good on inspection; flag is 0, property sequence is void).

We have tried this on Libreoffice 4 (as per ubuntu trusty repo) and with Openoffice SDK 4.1.2, with identical results.

Despite the fact that the simple example code runs to the end before crashing, we suspect (based on the other evidence) an issue with XComponentLoader.

What are potential pitfalls with this feature?

Any ideas appreciated.

Code (ooexample.cxx):

 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>

 #include <cppuhelper/bootstrap.hxx>
 #include <com/sun/star/bridge/XUnoUrlResolver.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/frame/Desktop.hpp>
 #include <com/sun/star/uno/XInterface.hpp>
 #include <com/sun/star/frame/XComponentLoader.hpp>
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/document/XTypeDetection.hpp>

 using namespace com::sun::star::uno;
 using namespace com::sun::star::lang;
 using namespace com::sun::star::bridge;
 using namespace com::sun::star::beans;
 using namespace com::sun::star::frame;
 using namespace com::sun::star::container;
 using namespace com::sun::star::document;
 using namespace rtl;
 using namespace cppu;

 #define DIAG(s) printf("%s\n",s)
 #define OOCHECKREF(x) if (!x.is()){printf("Error: "#x"\n");return 1;}

 int main (int argc, char *argv[]) {
   try {
     DIAG("mComponentContext");
     Reference< XComponentContext > mComponentContext
       = defaultBootstrap_InitialComponentContext();

     DIAG("mServiceManager");
     Reference< XMultiComponentFactory > mServiceManager
       = mComponentContext->getServiceManager();

     DIAG("rResolverInstance");
     Reference< XInterface > rResolverInstance
       = mServiceManager->createInstanceWithContext (
         OUString::createFromAscii("com.sun.star.bridge.UnoUrlResolver") ,
         mComponentContext);

     DIAG("rResolver");
     Reference< XUnoUrlResolver > rResolver (rResolverInstance, UNO_QUERY);
     OOCHECKREF(rResolver)

     DIAG("rOfficeInstance");    Reference< XInterface > rOfficeInstance
       = rResolver->resolve (
         OUString::createFromAscii ("uno:socket,host=localhost,port=8199;urp;StarOffice.ServiceManager")) ;
     OOCHECKREF(rOfficeInstance)

     DIAG("rOfficeServiceManager");
     Reference< XMultiServiceFactory > rOfficeServiceManager (
       rOfficeInstance, UNO_QUERY);
     OOCHECKREF(rOfficeServiceManager)

     DIAG("xPropSet");
     Reference< XPropertySet > xPropSet (rOfficeInstance, UNO_QUERY) ;
       xPropSet->getPropertyValue (OUString::createFromAscii("DefaultContext"))  >>= mComponentContext;

     DIAG("xMultiComponentFactoryServer");
     Reference< XMultiComponentFactory > xMultiComponentFactoryServer(
       mComponentContext->getServiceManager());

     DIAG("rDesktop");
     Reference<XInterface> rDesktop = rOfficeServiceManager->createInstance(
       OUString::createFromAscii("com.sun.star.frame.Desktop"));
     OOCHECKREF(rDesktop)

     DIAG("mComponentLoader");
     Reference< XComponentLoader > mComponentLoader (rDesktop, UNO_QUERY);
     OOCHECKREF(mComponentLoader)

     DIAG("rFiltersInt");
     Reference< XInterface > rFiltersInt = rOfficeServiceManager->createInstance(
         OUString::createFromAscii("com.sun.star.document.FilterFactory"));
     OOCHECKREF(rFiltersInt)

     DIAG("mFilterFactory");
     Reference<XNameAccess> mFilterFactory = Reference< XNameAccess >(rFiltersInt, UNO_QUERY);
     OOCHECKREF(mFilterFactory)

     DIAG("rTypeDetectInt");
     Reference< XInterface > rTypeDetectInt = rOfficeServiceManager->createInstance(
         OUString::createFromAscii("com.sun.star.document.TypeDetection"));
     OOCHECKREF(rTypeDetectInt)

     DIAG("mTypeDetect");
     Reference< XTypeDetection > mTypeDetect = Reference< XTypeDetection >(rTypeDetectInt, UNO_QUERY);
     OOCHECKREF(mTypeDetect)

     DIAG ("Connected successfully to the office - press enter to exit ...
(more)
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Alex Kemp
close date 2020-07-08 21:51:17.345734

1 Answer

Sort by » oldest newest most voted
0

answered 2016-09-01 18:21:28 +0200

floris v gravatar image

You will have to file a bug report at bugzilla. See Inappropriate questions.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-09-01 18:13:11 +0200

Seen: 153 times

Last updated: Sep 01 '16