Closed Bug 522123 Opened 15 years ago Closed 15 years ago

Indirect eval befuddles scopeChain

Categories

(Core :: JavaScript Engine, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jimb, Assigned: jimb)

Details

(Keywords: testcase, Whiteboard: fixed-in-tracemonkey)

Attachments

(2 files)

obj_eval doesn't succeed in using the global object for indirect eval calls: $ obj~/js js> evil=eval function eval() {[native code]} js> let (x=1) { print (evil("x")); } 1 js> The underlying problem is that, while the 'if indirectCall' code does swap out the frame's scopeChain, if there are lexical blocks on caller->blockChain, the subsequent call to js_GetScopeChain re-clones them, uses them for the compile and execute, and then drops them when it restores the frame's original scopeChain. These double clones never get their variables copied out of their stack frames when the frames are popped, so you can get functions that have closed over blocks pointing to popped frames: $ cat ~/mc/b/strict/eval-scope-2.js evil=eval; var f, g; let (x=1) { evil("f=function () { return x; };"); x++; }; print(f()); $ obj~/js ~/mc/b/strict/eval-scope-2.js function print() { [native code] } $ I think I have a patch for this.
(In reply to comment #0) > caller->blockChain fp->blockChain, that should be.
Flags: wanted1.9.2?
I may not have made it clear from the description, but you can end up with references to freed memory using this bug, or pointers into the stack.
Group: core-security
Attachment #406488 - Flags: review?(mrbkap)
Comment on attachment 406301 [details] [diff] [review] Don't reify lazy scope chain blocks twice in 'eval'. Thanks for catching this.
Attachment #406301 - Flags: review?(mrbkap) → review+
Attachment #406488 - Flags: review?(mrbkap) → review+
Whiteboard: fixed-in-tracemonkey
(In reply to comment #6) > http://hg.mozilla.org/tracemonkey/rev/64094cb2f8b2 This seems to have fixed the assertions in bug 521163 and bug 521279. There are testcases in these 2 bugs.
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Flags: wanted1.9.2?
Group: core-security
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: