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

VM module doesn't handle undefined/NaN/null correctly #14660

Description

@TimothyGu
  • Version: v8.2.1
  • Platform: Linux 4.9.0-3-amd64 SMP Debian 4.9.30-2+deb9u2 (2017-06-26) x86_64 GNU/Linux
  • Subsystem: vm
> vm.runInNewContext('undefined', { undefined: 123 })
123
> vm.runInNewContext('this.undefined', { undefined: 123 })
123
> // Compare:
> this.undefined = 123
> undefined
undefined
> this.undefined
undefined

undefined (and NaN and Infinity) is defined as unwritable, unconfigurable, unenumerable properties on the global object, and thus IMO should not be overridable through the VM module.

It is unclear if #13265 fixes this, probably not though as this issue concerns getting the value.

Activity

  1. added
    vmIssues and PRs related to the vm subsystem.
    on Aug 7, 2017
  2. TimothyGu commented on Aug 7, 2017

    @TimothyGu
    MemberAuthor

    (I discovered it when debugging jsdom/jsdom#1932, which turns out to be primarily a bug on jsdom's side. I'm okay with closing this, but still keeping this open to see what anyone else thinks.)

  3. bnoordhuis commented on Aug 7, 2017

    @bnoordhuis
    Member

    I suspect this is a V8 bug that has since been fixed because I can't reproduce with today's master; I can with the v8.x branch.

  4. added
    v8 engineIssues and PRs related to the V8 dependency.
    on Aug 7, 2017
  5. TimothyGu commented on Aug 8, 2017

    @TimothyGu
    MemberAuthor

    @bnoordhuis In master the first case returns undefined but the second still evaluates to 123…

  6. bnoordhuis commented on Aug 8, 2017

    @bnoordhuis
    Member

    Sorry yes, I was referring to the first case. The second one is a bug in the vm module, not V8.

    (Or bug... it makes perfect sense in the proxy-to-another-object model, but it's different from a native context.)

  7. maclover7 commented on Oct 23, 2017

    @maclover7
    Contributor

    As of f1d6b04, it looks like this behavior has changed a little bit:

    > vm.runInNewContext('undefined', { undefined: 123 })
    undefined
    > vm.runInNewContext('this.undefined', { undefined: 123 })
    123
    > this.undefined = 123
    123
    > this.undefined
    undefined
    
  8. TimothyGu commented on Aug 18, 2018

    @TimothyGu
    MemberAuthor

    I'm going to call this one of the things that one has to take care of when trying to use the vm module "correctly". It's not within our power to fix as it originates in V8, and it's pretty difficult to fix even on the V8 end.

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

    v8 engineIssues and PRs related to the V8 dependency.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