Re: NPAPI race conditions due to IPC

[email protected] Wed, 4 Mar 2015 07:35:26 -0800 (PST)
Newsgroups gmane.comp.mozilla.devel.plugins
Message-ID <[email protected]>
On Monday, March 2, 2015 at 12:31:34 PM UTC+2, [email protected] wrote:
> Hi,
> 
>   I have a plugin which can create two types of scriptable objects and I can add one to another using JavaScript and id association in the plugin. I create one in HTML and the other one in JS. Example:
> 
> HTML:
>   <embed id="a" type="application/x-a">
> 
> JS:
>   b = document.createElement("embed");
>   renderer.setAttribute("type", "application/x-b");
> 
>   a = documenet.getElementById("a");
>   a.add(b);
> 
> 
>   The problem which I am having is that NPN_Invoke for object a is called before NPP_New for object b. This is also visible in the invoke function because the _class member of the object which is given in the add function still has the default values.
>   If I call a function of b than the NPP_New function is called before NPN_Invoke.
>   The id association is done by trying to call a function of the object with NPN_Invoke:
> 
> C++:
> 
>   NPIdentifier identifier = NPN_GetStringIdentifier(GETID);
>   if (!NPN_Invoke(npp, object, identifier, 0, 0, &variant)) {
>     return 0;
>   }
>   obj = Manager.get(NPVARIANT_TO_INT32(variant);
> 
>   The problem disappears when dom.ipc.plugins.enabled is set to false.
> 
> 
>   Could this be a problem caused by IPC? Is there a way to flush all the changes from javascript to the C++ code?
> 
> Thanks in advance,
> 
> Cosmin

I've filed a bug and attached a test. https://bugzilla.mozilla.org/show_bug.cgi?id=1139434