Bug 84804 - Closure in try {} with catch captures all locals from the enclosing function
Summary: Closure in try {} with catch captures all locals from the enclosing function
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Michael Saboff
Depends on:
Reported: 2012-04-24 17:02 PDT by Michael Saboff
Modified: 2012-04-25 09:12 PDT (History)
1 user (show)

See Also:

Proposed Patch (4.88 KB, patch)
2012-04-24 17:34 PDT, Michael Saboff
oliver: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Saboff 2012-04-24 17:02:16 PDT
Consider the function:

function addActivationWithTry()
    try {
    var someArgs = 'firstArg|secondArg|third',
        args = someArgs.split('|'),
        varNotUsedInClosure = 'This is some string',
        anotherNonClosureVar = [ 'A', 'B', 'C', 'D' ],
        lastNonClosureVar = {
            prop1: 22,
            prop2: 'Yo',
            prop3: someArgs + '|fourth'

    pushFunction(function() {
         makeCall(args[0], args[1], args[2]);
    } catch (err) {

When the activation for the closure used as an argument for "pushFunction()" is created and torn off, all of the locals from "addActivationWithTry()" will be captured even though only the array "args" needs to be captured.
Comment 1 Michael Saboff 2012-04-24 17:34:59 PDT
Created attachment 138701 [details]
Proposed Patch
Comment 2 WebKit Review Bot 2012-04-24 17:36:17 PDT
Attachment 138701 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/JavaScriptCore/ChangeLog', u'Source..." exit_code: 1
Source/JavaScriptCore/runtime/JSActivation.h:95:  Please declare integral type bitfields with either signed or unsigned.  [runtime/bitfields] [5]
Total errors found: 1 in 4 files

If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Michael Saboff 2012-04-25 09:12:04 PDT
Committed r115217: <http://trac.webkit.org/changeset/115217>