You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
VM: weird behaviour in runInContext/runInThisContext #5344
context is also updated as if variable is created with var or let binding ❌
Versions
Tested versions: v5.6.0 & v5.1.1
Platform
Desktop 🙈 ₹ uname -a
Darwin Princes-MacBook-Pro.local 15.3.0 Darwin Kernel Version 15.3.0: Thu Dec 10 18:40:58 PST 2015; root:xnu-3248.30.4~1/RELEASE_X86_64 x86_64
I can confirm the bug but I suspect it's a V8 issue - it calls the global object's named property handlers (specifically the GlobalPropertySetterCallback) when it shouldn't. I'll have to investigate if it still happens with V8 HEAD.
I talked to my colleagues. V8 seems to be working as intended in this case. I assume that there is an interceptor on the global object installed by node. The interceptor probably stores the value onto the global object, but returns false, signalling that it did not intercept. V8 then attempts to store and throws due to strict mode.
So the interceptor should either not store and return false, or throw if v8::PropertyCallbackInfo::ShouldThrowOnError() returns true.
@hashseed Yang, thanks for chiming in. Is there anything we can do with 4.6 and 4.8? They don't have the ShouldThrowOnError() method.
The best I've been able to come up with is to sniff the script for a 'use strict' string and omit the call to v8::PropertyCallback<T>::Set() in the setter for strict mode scripts if there is no corresponding property on the global object. Basically this:
Would this work for you? Whenever the interceptor is going to do a normal store, it does not store and returns false. V8 will then do the store, unless strict mode causes an exception before that.
@bnoordhuis If the property is newly created, neither the sandbox object nor the global object will have the property defined on them when GlobalPropertySetterCallback is called. So, sandbox->Has(property) will fail and the new property will not be added to sandbox, right?
mbroadst@gorgor:~$ uname -a && node -v
Darwin gorgor.local 16.3.0 Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST 2016; root:xnu-3789.31.2~1/RELEASE_X86_64 x86_64
v7.5.0
Activity
bnoordhuis commentedon Feb 21, 2016
I can confirm the bug but I suspect it's a V8 issue - it calls the global object's named property handlers (specifically the
GlobalPropertySetterCallback) when it shouldn't. I'll have to investigate if it still happens with V8 HEAD.bnoordhuis commentedon Feb 21, 2016
Still happens with V8 4.10.253 and 5.0.48. I'll see if I can put a standalone test case together for upstream to take a look at.
hashseed commentedon Mar 1, 2016
I talked to my colleagues. V8 seems to be working as intended in this case. I assume that there is an interceptor on the global object installed by node. The interceptor probably stores the value onto the global object, but returns false, signalling that it did not intercept. V8 then attempts to store and throws due to strict mode.
So the interceptor should either not store and return false, or throw if v8::PropertyCallbackInfo::ShouldThrowOnError() returns true.
bnoordhuis commentedon Mar 1, 2016
@hashseed Yang, thanks for chiming in. Is there anything we can do with 4.6 and 4.8? They don't have the
ShouldThrowOnError()method.The best I've been able to come up with is to sniff the script for a
'use strict'string and omit the call tov8::PropertyCallback<T>::Set()in the setter for strict mode scripts if there is no corresponding property on the global object. Basically this:hashseed commentedon Mar 1, 2016
Would this work for you? Whenever the interceptor is going to do a normal store, it does not store and returns false. V8 will then do the store, unless strict mode causes an exception before that.
thefourtheye commentedon Mar 13, 2016
@bnoordhuis If the property is newly created, neither the sandbox object nor the global object will have the property defined on them when
GlobalPropertySetterCallbackis called. So,sandbox->Has(property)will fail and the new property will not be added to sandbox, right?src: do not copy on failing setProperty()
mmc41 commentedon Dec 13, 2016
The possible bug behind this "#5344" seems to be fixed now.
mbroadst commentedon Feb 21, 2017
I'm still experiencing weirdness with a slightly modified version of this test case:
results in:
ReferenceError: x is not definedmscdex commentedon Apr 9, 2017
This does seem to be happening still, even on current master.
Thoughts @nodejs/v8?
bnoordhuis commentedon Apr 10, 2017
Moved to #12300 so it has its own bug number. It's related but separate.
src: do not copy on failing setProperty()