镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Proxy passed as vm context hides built-in properties. #6158

Description

@psrok1

Proxy object is not correctly contextified by vm.createContext routine.

I've tried to create vm with traps on global context, so I made one based on Proxy object.
Unfortunately, code executed inside vm doesn't have any access to built-ins.

> vm.runInNewContext("String", {})
[Function: String]
> vm.runInNewContext("String", new Proxy({},{}))
undefined

Passing required built-ins this way:

ctx = new Proxy({String:String}, {})
vm.runInNewContext("String", ctx)

seems to be (a bit dirty) workaround, but it doesn't resolve a problem at all...

vm.runInNewContext("String.prototype.f = function(){}; ''.f()", ctx)
... because passed String differs from used built-in by string literal, so this code raises an exception (''.f is undefined)

Tested on builds from branches node-vee-eight-4.9/5.0
Proxies doesn't work with older V8s and VMs, because of "not an object" bug.

Activity

  1. added
    vmIssues and PRs related to the vm subsystem.
    on Apr 11, 2016
  2. Fishrock123 commented on Apr 13, 2016

    @Fishrock123
    Contributor

    cc ... @domenic maybe? @ofrobots any idea?

  3. ofrobots commented on Apr 18, 2016

    @ofrobots
    Contributor

    I think the issue is because v8::Object::GetRealNamedProperty in node_contextify.cc ends up behaving differently for Proxy objects. I'm not sure this behaviour is intended. I have opened an issue upstream: https://bugs.chromium.org/p/v8/issues/detail?id=4932.

  4. ofrobots commented on May 6, 2016

    @ofrobots
    Contributor

    This should be fixed upstream in V8 5.2: https://codereview.chromium.org/1929853002. I will request a merge back to V8 5.0 in upstream.

  5. added a commit that references this issue on May 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    vmIssues and PRs related to the vm subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions