Ignore:
Timestamp:
Jan 8, 2015, 4:49:31 PM (11 years ago)
Author:
[email protected]
Message:

Argument object created by "Function dot arguments" should use a clone of the argument values.
<https://webkit.org/b/140093>

Reviewed by Geoffrey Garen.

After the change in <https://webkit.org/b/139827>, the dfg-tear-off-arguments-not-activation.js
test will crash. The relevant code which manifests the issue is as follows:

function bar() {

return foo.arguments;

}

function foo(p) {

var x = 42;
if (p)

return (function() { return x; });

else

return bar();

}

In this case, foo() has no knowledge of bar() needing its LexicalEnvironment and
has dead code eliminated the SetLocal that stores it into its designated local.
In bar(), the factory for the Arguments object (for creating foo.arguments) tries
to read foo's LexicalEnvironment from its designated lexicalEnvironment local,
but instead, finds it to be uninitialized. This results in a null pointer access
which causes a crash.

This can be resolved by having bar() instantiate a clone of the Arguments object
instead, and populate its elements with values fetched directly from foo's frame.
There's no need to reference foo's LexicalEnvironment (whether present or not).

  • interpreter/StackVisitor.cpp:

(JSC::StackVisitor::Frame::createArguments):

  • runtime/Arguments.h:

(JSC::Arguments::finishCreation):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r178143 r178145  
     12015-01-08  Mark Lam  <[email protected]>
     2
     3        Argument object created by "Function dot arguments" should use a clone of the argument values.
     4        <https://webkit.org/b/140093>
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        After the change in <https://webkit.org/b/139827>, the dfg-tear-off-arguments-not-activation.js
     9        test will crash.  The relevant code which manifests the issue is as follows:
     10
     11            function bar() {
     12                return foo.arguments;
     13            }
     14
     15            function foo(p) {
     16                var x = 42;
     17                if (p)
     18                    return (function() { return x; });
     19                else
     20                    return bar();
     21            }
     22
     23        In this case, foo() has no knowledge of bar() needing its LexicalEnvironment and
     24        has dead code eliminated the SetLocal that stores it into its designated local.
     25        In bar(), the factory for the Arguments object (for creating foo.arguments) tries
     26        to read foo's LexicalEnvironment from its designated lexicalEnvironment local,
     27        but instead, finds it to be uninitialized.  This results in a null pointer access
     28        which causes a crash.
     29
     30        This can be resolved by having bar() instantiate a clone of the Arguments object
     31        instead, and populate its elements with values fetched directly from foo's frame.
     32        There's no need to reference foo's LexicalEnvironment (whether present or not).
     33
     34        * interpreter/StackVisitor.cpp:
     35        (JSC::StackVisitor::Frame::createArguments):
     36        * runtime/Arguments.h:
     37        (JSC::Arguments::finishCreation):
     38
    1392015-01-08  Mark Lam  <[email protected]>
    240
Note: See TracChangeset for help on using the changeset viewer.