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 }}
This repository was archived by the owner on Oct 15, 2020. It is now read-only.
Repository navigation
This repository was archived by the owner on Oct 15, 2020. It is now read-only.
Inconsistent behaviour with vm context of Object.create(null) #508
$ node -v
v8.10.0
$ node
> vm.runInNewContext('0 & this', Object.create(null))
evalmachine.<anonymous>:1
0 & this
^
TypeError: Number expected
at Global code (evalmachine.<anonymous>:1:1)
at Script.prototype.runInContext (vm.js:59:5)
at Script.prototype.runInNewContext (vm.js:65:3)
at runInNewContext (vm.js:135:3)
at Global code (repl:1:1)
at Script.prototype.runInThisContext (vm.js:50:5)
at defaultEval (repl.js:240:13)
at bound (domain.js:301:5)
at runBound (domain.js:314:5)
at onLine (repl.js:468:5)
Ok, just had a look and a bare 0 & Object.create(null) in node-v8 gives an equivalent error, but in the vm context it does not. I think that this is because in the v8 case the global object keeps its prototype and so there is a valueOf, while in the node-chakracore case we replace the prototype with the sandbox and so it no longer has a valueOf.
I somewhat feel like this might be one of those edge-cases that may not be fully intended in node upstream? I know I asked about what happens in some strange cases when properties conflict between the sandbox and the global, and there wasn't a good answer to what was expected. I would somewhat expect that if you say "Use this sandbox object, and I've removed everything from it" that you wouldn't want it to have things like the prototype properties; just a bare minimal global object.
I want to be absolutely sure to avoid any Object.prototype properties leaking into the sandbox context, which is why it is coded this way.
Having said that, I do understand your reason for the current behaviour in node-chakracore - but then as a user I just want to be able to switch between the platforms with as few quirks as possible.
We definitely want to have minimal platform differences. The problem here is trying to understand what the underlying expected behavior is, given that this vm context stuff isn't strongly specced out, and "what node-v8 does" isn't necessarily right in all cases either since there are some questions about whether they do the right thing in some circumstances.
Reverted the workaround in uglify-js to confirm the difference in behaviour between node and node-chakracore still persists as of 11.0.0-nightly20180522db93156017
Activity
MSLaguana commentedon Apr 24, 2018
I don't believe that this is to do with the
vmmodule actually; just running0 & Object.create(null)inch(bare chakracore) gives the same error.MSLaguana commentedon Apr 24, 2018
Unless you expect that, but you expect that using that as the global should have different behavior?
alexlamsl commentedon Apr 24, 2018
0 & Object.create(null)behaves consistently betweennodeandnode-chakracore(both at8.11.1)whereas the top example works for
nodebut cause exception to be throw innode-chakracoreMSLaguana commentedon Apr 24, 2018
Ok, just had a look and a bare
0 & Object.create(null)in node-v8 gives an equivalent error, but in the vm context it does not. I think that this is because in the v8 case the global object keeps its prototype and so there is avalueOf, while in the node-chakracore case we replace the prototype with the sandbox and so it no longer has avalueOf.MSLaguana commentedon Apr 24, 2018
I somewhat feel like this might be one of those edge-cases that may not be fully intended in node upstream? I know I asked about what happens in some strange cases when properties conflict between the sandbox and the global, and there wasn't a good answer to what was expected. I would somewhat expect that if you say "Use this sandbox object, and I've removed everything from it" that you wouldn't want it to have things like the prototype properties; just a bare minimal global object.
alexlamsl commentedon Apr 24, 2018
I want to be absolutely sure to avoid any
Object.prototypeproperties leaking into the sandbox context, which is why it is coded this way.Having said that, I do understand your reason for the current behaviour in
node-chakracore- but then as a user I just want to be able to switch between the platforms with as few quirks as possible.MSLaguana commentedon Apr 24, 2018
We definitely want to have minimal platform differences. The problem here is trying to understand what the underlying expected behavior is, given that this vm context stuff isn't strongly specced out, and "what node-v8 does" isn't necessarily right in all cases either since there are some questions about whether they do the right thing in some circumstances.
alexlamsl commentedon Apr 24, 2018
Thanks for the dicussion and clarifications - meanwhile I'll see if I can come up with an alternative test case in
uglify-jswhich avoids this issue.alexlamsl commentedon May 23, 2018
Reverted the workaround in
uglify-jsto confirm the difference in behaviour betweennodeandnode-chakracorestill persists as of11.0.0-nightly20180522db93156017alexlamsl commentedon May 26, 2018
Still an issue as of
v10.1.0alexlamsl commentedon Jul 26, 2018
Reproducible in
v10.6.0