Issue 109658 - oo crashes i macro is called from startcenter twice
Summary: oo crashes i macro is called from startcenter twice
Status: CONFIRMED
Alias: None
Product: General
Classification: Code
Component: code (show other issues)
Version: OOO320m12
Hardware: All All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-27 14:27 UTC by Oliver Brinzing
Modified: 2017-05-20 11:35 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
example extension - ready to install (7.07 KB, application/x-compressed)
2010-02-27 14:28 UTC, Oliver Brinzing
no flags Details
source code - eclipse project (21.80 KB, application/x-compressed)
2010-02-27 14:29 UTC, Oliver Brinzing
no flags Details
error report oo300m72 (416.01 KB, text/xml)
2010-02-27 14:57 UTC, Oliver Brinzing
no flags Details
gdb backtrace (5.19 KB, text/plain)
2010-10-09 20:48 UTC, Ariel Constenla-Haile
no flags Details
sample component not crashing the office (40.51 KB, application/x-gzip)
2010-10-10 06:35 UTC, Ariel Constenla-Haile
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description Oliver Brinzing 2010-02-27 14:27:56 UTC
oo crashes if one starts a basic macro the *second* time from a
menu entry directly from oo startcenter.

the extension demo uses a java protocol handler:

[...]
final XScript xScript = xScriptProvider.getScript(script);
final Object ret = xScript.invoke(aArgs, null, null);

please have a look at the attachment's.

steps to reproduce:

- install "myprotocolhandler.zip" extension
- create the test macro in "My Macros - Standard - Module1":

  Sub Test
     MsgBox "Hello World!"
  End Sub

- close and restart oo

- select "Makro Test" from menu "Test Dispatch" from Calc/Writer
  -> first time: Hello World
  -> second time: Hello World
  -> ...
  -> no problems at all

- now select "Test Dispatch - Makro Test" directly from OO StartCenter 
  -> first time: Hello World
  -> second time: 
     ---------------------------
     Microsoft Visual C++ Runtime Library
     ---------------------------
     Runtime Error!
     Program: C:\Program Files\OpenOffice.org\program\soffice.bin    
     This application has requested the Runtime to terminate it in an unusual 
     way.  Please contact the application's support team for more information.

btw: no problems if one select the "Java Test" from StartCenter
Comment 1 Oliver Brinzing 2010-02-27 14:28:48 UTC
Created attachment 68049 [details]
example extension - ready to install
Comment 2 Oliver Brinzing 2010-02-27 14:29:27 UTC
Created attachment 68050 [details]
source code - eclipse project
Comment 3 Oliver Brinzing 2010-02-27 14:57:18 UTC
Created attachment 68051 [details]
error report oo300m72
Comment 4 Oliver Brinzing 2010-02-27 14:58:15 UTC
can confirm with DEV300m72 on Win Xp - see attached "c35c_appcompat.xml"
Comment 5 Ariel Constenla-Haile 2010-10-09 18:33:40 UTC
can confirm
Comment 6 Ariel Constenla-Haile 2010-10-09 18:34:48 UTC
.
Comment 7 Ariel Constenla-Haile 2010-10-09 19:22:44 UTC
.
Comment 8 Ariel Constenla-Haile 2010-10-09 20:48:02 UTC
Created attachment 72006 [details]
gdb backtrace
Comment 9 Ariel Constenla-Haile 2010-10-09 20:53:23 UTC
the uncaught RuntimeException tells:

unsatisfied query for interface of type
com.sun.star.script.provider.XScriptProvider!
java stack trace:
        at com.sun.star.bridges.jni_uno.JNI_proxy.dispatch_call(Native Method)
        at com.sun.star.bridges.jni_uno.JNI_proxy.invoke(JNI_proxy.java:175)
        at $Proxy16.createScriptProvider(Unknown Source)
        at
org.test.ExecuteBasicScript.executeScript(ExecuteBasicScript.java:38)
        at org.test.OOProtocolHandler.dispatch(OOProtocolHandler.java:100)

        at com.sun.star.bridges.jni_uno.JNI_proxy.dispatch_call(Native Method)
        at com.sun.star.bridges.jni_uno.JNI_proxy.invoke(JNI_proxy.java:175)
        at $Proxy16.createScriptProvider(Unknown Source)
        at
org.test.ExecuteBasicScript.executeScript(ExecuteBasicScript.java:38)
        at org.test.OOProtocolHandler.dispatch(OOProtocolHandler.java:100)


in ExecuteBasicScript.executeScript()


final XScriptProvider xScriptProvider =
xScriptProviderFactory.createScriptProvider(getModel());


the StartModule has no model!

I wander how it even works the first time and crashes the second one?

 
Comment 10 Ariel Constenla-Haile 2010-10-10 06:35:03 UTC
Created attachment 72008 [details]
sample component not crashing the office
Comment 11 Ariel Constenla-Haile 2010-10-10 06:43:49 UTC
arielch->brinzing: try the sample component (a NB Project in
ProtocolHandlerExample.tar.gz).

You can simply avoid the crash by catching the exception thrown in the bridge.

    public Object executeScript(final String script, final Object[] aArgs) {

        try {
            //...

        } catch (final IllegalArgumentException e) {
            System.err.println(e.getMessage());
        } catch (final ScriptFrameworkErrorException e) {
            System.err.println(e.getMessage());
        } catch (final InvocationTargetException e) {
            System.err.println(e.getMessage());
        } catch (final NullPointerException e) {
            System.err.println(e.getMessage());
        } catch (final com.sun.star.uno.Exception e) {
            System.err.println(e.getMessage());
        } catch (final java.lang.Exception e) {
            System.err.println(e.getMessage());
        }
        return null;
    }


I still do not see why it works the first time and crashes the second... may be
because you use getCurrentComponent() which is always a bad idea. Your
ProtocolHandler gets an XFrame, pass it to your working class.
On the other side, the StartModule has no model, and its controller does not
implement XScriptInvocationContext.
Comment 12 Oliver Brinzing 2010-10-10 09:53:18 UTC
i tried with your example, and can confirm: oo does not crash anymore.
but the basic script will be executed only the first time. 
so i think we still have a bug...
Comment 13 Oliver Brinzing 2010-10-10 14:30:37 UTC
now changed source code from:
  xScriptProviderFactory.createScriptProvider(xModel);
to
  xScriptProviderFactory.createScriptProvider("");
  (see http://www.oooforum.org/forum/viewtopic.phtml?t=23310 for example)

and it works ...

but code snippet tells to use "document" as parameter:
http://codesnippets.services.openoffice.org/Office/Office.HowToCallJavaProgramUsingScriptingFramework.snip
Comment 14 Ariel Constenla-Haile 2010-10-11 00:14:02 UTC
Yes, it is not clear what is expected under that Any.

Looking at the com.sun.star.script.provider.MasterScriptProviderFactory
implementation:

http://svn.services.openoffice.org/opengrok/xref/DEV300_m88/scripting/source/provider/MasterScriptProviderFactory.cxx#63

it calls ActiveMSPList::getMSPFromAnyContext()
http://svn.services.openoffice.org/opengrok/xref/DEV300_m88/scripting/source/provider/ActiveMSPList.cxx#82

There you see that it can be a string, or an XModel, or something else
implementing XScriptInvocationContext.

Not sure where the empty string "" ends up... but the impl. seems to expect a
"vnd.sun.star.tdoc", see
http://svn.services.openoffice.org/opengrok/xref/DEV300_m88/scripting/source/provider/ActiveMSPList.cxx#161


Anyway, yes, there is an issue, in the fact that the office should not crash if
you do not catch an exception thrown in the bridge.
Comment 15 Marcus 2017-05-20 11:35:06 UTC
Reset assigne to the default "issues@openoffice.apache.org".