bugGnash - The GNU Flash player - Bugs: bug #47354, `Function.call(null)` and...

 
 

bug #47354: `Function.call(null)` and `Function.call(undefined)` provided an incorrect `this` instance

Submitted by:  Nutchanon Wetchasit <nachanon>
Submitted on:  Mon 07 Mar 2016 12:21:34 PM UTC  
 
Category: ActionScriptSeverity: 3 - Normal
Release: masterStatus: Fixed
Privacy: PublicAssigned to: Sandro Santilli <strk>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Wed 13 Apr 2016 10:17:53 AM UTC, comment #5:

On current git version of Gnash, all test SWFs in `fncall-nothis-rev2.zip` and
`fnapply-nothis-rev2.zip` are giving `PASSED` result.

I have also tested reverting http://git.savannah.gnu.org/cgit/gnash.git/commit/?id=a794319ac28c02365eddffd571a37c3ec4fb1eea the fix], and found that 14 test failures are
appearing as expected:

This bug could now be marked as fixed.

Gnash: 0.8.11dev (git 484ca4c 29-Mar-2016)
System: Debian GNU/Linux 7.0 Wheezy i386

Nutchanon Wetchasit <nachanon>
Tue 08 Mar 2016 03:20:40 PM UTC, comment #4:

Patch included, see patch #8935.

This is debug output (verbosity 1) of `fncall-nothis-rev2-v7.swf` with patched Gnash:

This is debug output (verbosity 1) of `fnapply-nothis-rev2-v7.swf` with patched Gnash:

You'd see that tests are now giving all-PASSED result. (Other version of test
SWFs in both test case are also giving all PASSED result too)

Gnash: 0.8.11dev (patched against git 8b33692 7-Mar-2016)
System: Debian GNU/Linux 7.0 Wheezy i386

Nutchanon Wetchasit <nachanon>
Tue 08 Mar 2016 03:12:06 PM UTC, comment #3:

I have written an updated version of `fncall-nothis.zip` and
`fnapply-nothis.zip` which include the case where SWF tries to call
`Function.call()` and `Function.apply()` with no argument;
attached as `fncall-nothis-rev2.zip` and `fnapply-nothis-rev2.zip`.

(file #36568, file #36569)

Nutchanon Wetchasit <nachanon>
Tue 08 Mar 2016 12:47:05 PM UTC, comment #2:

This issue could be narrowed down directly to how `Function.call()` and
`Function.apply()` are currently implemented in Gnash.

`Function.apply()` at `libcore/asobj/Function_as.cpp` around line 107:

`Function.call()` at `libcore/asobj/Function_as.cpp` around line 159:

In both methods, `this` inside the called function would be set to an empty object
if `thisObject` argument was not specified, or specified as `null` or `undefined`.

Gnash: 0.8.11dev (git 8b33692 7-Mar-2016)
System: Debian GNU/Linux 7.0 Wheezy i386

Nutchanon Wetchasit <nachanon>
Mon 07 Mar 2016 02:16:36 PM UTC, comment #1:

Gnash's implementation of `Function.apply()` is also affected by the
same problem. I have made a variant of `fncall-nothis.zip` test which uses
`Function.apply()` instead of `Function.call()`; attached as `fnapply-nothis.zip`.

This is a trace output of `fnapply-nothis-v7.swf` under Flash Player:

You'd see that all tests were passed.

This is a debug output (verbosity 1) of `fnapply-nothis-v7.swf` under Gnash:

You'd see that tests were failed in the same way as `Function.call()`.

Gnash: 0.8.11dev (git 8b33692 7-Mar-2016)
Flash Player: 11.2 r202 (11.2.202.491) Standalone
System: Debian GNU/Linux 7.0 Wheezy i386

(file #36566)

Nutchanon Wetchasit <nachanon>
Mon 07 Mar 2016 12:21:34 PM UTC, original submission:

This is a spin-off from bug #37223 (ExternalInterface issue).

While I was testing on Gnash's ExternalInterface callback behavior when SWF
registered a callback with accompanied `this` object set to `null`
or `undefined`, I found that `this` object inside the callback is supposed
to be the same as one inside function called with `Function.call(null)` or
`Function.call(undefined)`.

On Flash Player, `this` object is actually the ActionScript's `_global` object.
On Gnash, a plain object with no prototype was returned instead, which is incorrect.

I have made test SWF files (using libming's makeswf) which checks following
properties of `this` inside a function called via `Function.call(null)`
and `Function.call(undefined)`:

  • `typeof(this)` should return "object".
  • `this` should be equal to `null` and `undefined`.
  • `this` should not be strictly equal to `null` and `undefined`.
  • When appending `this` to an empty string, it must give "undefined" (Flash 7+) or empty string (Flash 6).
  • `this` should be strictly equal to `_global`.
  • Properties set to `this` must be retrievable later via `_global` object, outside the function.

(The test is similar to `js2flash-nothis-v2.zip` provided in bug #37223)

This is a trace output of `fncall-nothis-v7.swf` under Flash Player:

You'd see that all tests were passed.

This is a debug output (verbosity 1) of `fncall-nothis-v7.swf` under Gnash:

You'd see that tests of properties highlighted above in bold were failed.

Test SWF files (Flash 6-8), full debug logs, and source code are attached
as `fncall-nothis.zip`.

Gnash: 0.8.11dev (git 8b33692 7-Mar-2016)
Flash Player: 11.2 r202 (11.2.202.491) Standalone
System: Debian GNU/Linux 7.0 Wheezy i386

P.S. Gnash's testsute doesn't seem to have automated test on this issue.

Nutchanon Wetchasit <nachanon>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #36568:  fncall-nothis-rev2.zip added by nachanon (12KiB - application/zip - `Function.call()`/`Function.apply()` test SWF files (with no-parameter case), source code, and debug logs)
file #36569:  fnapply-nothis-rev2.zip added by nachanon (12KiB - application/zip - `Function.call()`/`Function.apply()` test SWF files (with no-parameter case), source code, and debug logs)
file #36566:  fnapply-nothis.zip added by nachanon (11KiB - application/zip - `Function.apply()` test SWF files, source code, and debug logs)
file #36565:  fncall-nothis.zip added by nachanon (11KiB - application/zip - `Function.call()` test SWF files, source code, and debug logs)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by strk (Updated the item)
  • -unavailable- added by nachanon (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 7 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 27 Apr 2016 07:58:42 AM UTCstrkStatusNone=>Fixed
      Assigned toNone=>strk
      Open/ClosedOpen=>Closed
    Tue 08 Mar 2016 03:12:06 PM UTCnachanonAttached File-=>Added fncall-nothis-rev2.zip, #36568
      Attached File-=>Added fnapply-nothis-rev2.zip, #36569
    Mon 07 Mar 2016 02:16:36 PM UTCnachanonAttached File-=>Added fnapply-nothis.zip, #36566
    Mon 07 Mar 2016 12:21:34 PM UTCnachanonAttached File-=>Added fncall-nothis.zip, #36565

    Back to the top


    Powered by Savane 3.1-cleanup1