Destructuring assignment isn't threadsafe

RESOLVED FIXED

Status

--
major
RESOLVED FIXED
11 years ago
11 years ago

People

(Reporter: mozilla.bugs, Unassigned)

Tracking

Details

Attachments

(1 attachment)

(Reporter)

Description

11 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11
Build Identifier: CVS HEAD

I have a function with destructured parameters
(eg function(a, [b]) {...}).

This function is called from several threads and the b (in this example) appears to be shared :-(
If I rewrite my functions without destructured parameters (eg function(a, ab) { const b = ab[0]; ... } it solves the problem.

Compiled & interpreted mode.

Reproducible: Always

Steps to Reproduce:
function f(a, [b]) { 
    java.lang.Thread.sleep(2000);
    print(a + ";" + b);
}
spawn(f, [1, [2]]);
spawn(f, [3, [4]]);
Actual Results:  
3;4
1;4

Expected Results:  
3;4
1;2
(Reporter)

Comment 1

11 years ago
Additional information: b is set in the top level scope.
(Reporter)

Comment 2

11 years ago
Created attachment 292241 [details] [diff] [review]
proposed patch

This patche makes the destructuring assignment to set properties in the current scope.

Comment 3

11 years ago
Thanks for the patch. Committed:

Checking in Parser.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/Parser.java,v  <--  Parser.java
new revision: 1.123; previous revision: 1.122
done
Status: UNCONFIRMED → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.