Page 1 of 1

Second Bootstrap Crashes OO

PostPosted: Wed May 02, 2012 4:23 am
by mavatar
I have written a DLL in C++ that uses the UNO API to convert a Word document into HTML. I have run into an issue in which if I execute the program twice the second call crashes the already open OO process. I have tracked the crash down to the following bootstrap line of code.

Reference<XComponentContext> xComponentContext = ::cppu::bootstrap();

So on the first execution OO is not running, and the bootstrap launches an OO instance. After the conversion program terminates the OO process is still running. Upon the second execution the call to bootstrap appears to launch a second OO instance, and then I see both OO processes terminate.

I was under the impression that a second call to bootstrap would simply open a connection to the existing OO process. Is there something type of cleanup that should be executed when the program terminates, so that subsequent bootstraps don't cause OO to crash?

Re: Second Bootstrap Crashes OO

PostPosted: Wed May 02, 2012 4:42 am
by mavatar
Some addtional information... If a add the following lines of code to my program, which essentially terminates the OO process, the second call to bootstrap works as expected, a new OO instance is launched.

Reference<XDesktop> xDesktop(xServiceManager->createInstanceWithContext(

Also if I leave the first program that creates the OO instance sitting at a break point before it disposes the service manager, opening another instance of the program is able to successfully connect to the OO instance via bootstrap. However, as soon as the first process disposes the service manager. The second call to bootstrap causes the OO process to crash (or terminate).

Re: Second Bootstrap Crashes OO

PostPosted: Wed May 02, 2012 4:56 am
by mavatar
I've also found that if my program simply calls the cppu::bootstrap function and nothing else, the second program execution is successful. However, if I add the following lines of code to my program, the second bootstrap is problematic.

Reference<XMultiComponentFactory> xServiceManager(xComponentContext->getServiceManager());

So it seems to have something to do with getting a reference to the service manager, and then disposing of it, that causes the subsequent bootstrap to crash the OO instance.