<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>85417</bug_id>
          
          <creation_ts>2012-05-02 14:01:40 -0700</creation_ts>
          <short_desc>NPN_InvokeDefault fails due to invalid rootObject</short_desc>
          <delta_ts>2022-06-28 09:25:36 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>New Bugs</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Todd Malsbary">tmalsbar</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>andersca</cc>
    
    <cc>ap</cc>
    
    <cc>mrobinson</cc>
    
    <cc>svillar</cc>
    
    <cc>tmalsbar</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>614641</commentid>
    <comment_count>0</comment_count>
    <who name="Todd Malsbary">tmalsbar</who>
    <bug_when>2012-05-02 14:01:40 -0700</bug_when>
    <thetext>Calling NPN_InvokeDefault from a plugin fails sometimes using the latest (git-svn-id: http://svn.webkit.org/repository/webkit/trunk@115246 268f45cc-cd09-0410-ab3c-d52691b4dbfc) built for gtk (using JavaScriptCore).  The failure occurs because the
    if (!rootObject || !rootObject-&gt;isValid())
check fails in NP_jsobject.cpp at _NPN_InvokeDefault.

The repro steps run some unit tests for the plugin being developed, which behaves roughly as follows for each test:
    1. create &lt;object&gt;
    2. run test code
    3. remove &lt;object&gt;
The test code passes in a JS function to the plugin that is later called via NPN_InvokeDefault.

Digging through the code a bit shows me that a new rootObject is created for each instance of the plugin.  When the JS function value is converted to an NPVariant before calling the plugin it calls findRootObject to assign a rootObject.  At that point there are multiple rootObjects in the root object set:
    globalObject=0x7fa1438bc150
    rootObject=0x24d35f0 rootObject-&gt;globalObject=0x7fa1438bc150
    rootObject=0x23e4b50 rootObject-&gt;globalObject=0x7fa1438bc150
    rootObject=0x250d890 rootObject-&gt;globalObject=0x7fa1438bc150
    rootObject=0x2576d30 rootObject-&gt;globalObject=0x7fa1438bc150
    rootObject=0x2593830 rootObject-&gt;globalObject=0x7fa1438bc150
findRootObject picks the first one, which does not belong to the instance of the plugin that is being called.  The first rootObject is invalidated before the plugin calls NPN_InvokeDefault.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>621684</commentid>
    <comment_count>1</comment_count>
    <who name="Sergio Villar Senin">svillar</who>
    <bug_when>2012-05-11 09:12:25 -0700</bug_when>
    <thetext>it&apos;d be awesome if you could provide a simplified version of the plugin or at least a test case. I was unable to reproduce it actually.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1878722</commentid>
    <comment_count>2</comment_count>
    <who name="Martin Robinson">mrobinson</who>
    <bug_when>2022-06-28 03:40:14 -0700</bug_when>
    <thetext>Support for plugins was removed in https://trac.webkit.org/changeset/265753/webkit.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1878726</commentid>
    <comment_count>3</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-06-28 03:41:15 -0700</bug_when>
    <thetext>&lt;rdar://problem/96050372&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>