GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Function redefinition in vm.runInContext · Issue #548 · nodejs/node

Function redefinition in vm.runInContext #548

New issue
Copy link
New issue
Copy link
Closed
Closed
Function redefinition in vm.runInContext#548
Copy link
Assignees
fhinkel
Labels
confirmed-bugIssues and PRs for confirmed bugs.vmIssues and PRs related to the vm subsystem.

Description

@kyriosli
kyriosli
opened on Jan 22, 2015
Issue body actions

Possible bug of iojs or perhaps v8?

    var vm = require('vm'), ctx = vm.createContext({});

    vm.runInContext('function test(){return 0}', ctx);
    vm.runInContext('function test(){return 1}', ctx);

    var result = vm.runInContext('test()', ctx);
    // returns 0 in io.js, but 1 in node.js

Tested under win7 x64 and linux.

Activity

Next
  1. Fishrock123 commented on Jan 22, 2015

    @Fishrock123
    Fishrock123
    on Jan 22, 2015
    Contributor
    More actions

    Confirmed result difference, 0 in iojs and 1 in node (all current versions (0.10.33 & 0.11.15)

  2. kyriosli commented on Jan 22, 2015

    @kyriosli
    kyriosli
    on Jan 22, 2015
    Author
    More actions

    It seems that a Context is a proxy object in node.js, but a plain object in io.js

  3. chrisdickinson commented on Jan 22, 2015

    @chrisdickinson
    chrisdickinson
    on Jan 22, 2015
    Contributor
    More actions

    What version of node? Likely this is due to the switch to contextify internally.

  4. domenic commented on Jan 22, 2015

    @domenic
    domenic
    on Jan 22, 2015
    Contributor
    More actions

    This does seem bad, as the intention here is similar to

    <script>
    function test() { return 0; }
    </script>
    
    <script>
    function test() { return 1; }
    </script>
    
    <script>
    alert(test());
    </script>

    (which alerts 1).

    I wonder if it is due to 3c5ea41

  5. Fishrock123 commented on Jan 22, 2015

    @Fishrock123
    Fishrock123
    on Jan 22, 2015
    Contributor
    More actions

    @domenic not directly / not alone, that commit exists in 0.11.15, which also appears to have the bug.

  6. vkurchatkin
    added
    vmIssues and PRs related to the vm subsystem.
    on Jan 23, 2015
  7. domenic commented on Jan 27, 2015

    @domenic
    domenic
    on Jan 27, 2015
    Contributor
    More actions

    @Fishrock123 right, I am wondering what the behavior was before that commit but after the contextify switch.

  8. piscisaureus commented on Jan 29, 2015

    @piscisaureus
    piscisaureus
    on Jan 29, 2015
    Contributor
    More actions

    Possibly related: nodejs/node-v0.x-archive#9084

  9. isaacs
    changed the title [-]Function redefination in vm.runInContext[/-] [+]Function redefinition in vm.runInContext[/+] on Feb 5, 2015
  10. targos commented on May 24, 2015

    @targos
    targos
    on May 24, 2015
    Member
    More actions

    Still returning 0 on v2.1.0.
    Could be interesting to test on next branch, maybe with #1773 ?

  11. Fishrock123 commented on Jun 5, 2015

    @Fishrock123
    Fishrock123
    on Jun 5, 2015
    Contributor
    More actions

    @domenic is this fixed in next?

  12. domenic commented on Jun 5, 2015

    @domenic
    domenic
    on Jun 5, 2015
    Contributor
    More actions

    Haven't been able to test this with the new patches, but I didn't see any reason why the new patches would necessarily fix it. I still have a list of vm bugs to work on :)

  13. brendanashworth commented on Aug 14, 2015

    @brendanashworth
    brendanashworth
    on Aug 14, 2015
    Contributor
    More actions

    Behavior still occurs in 3.0, marking as a bug!

  14. brendanashworth
    added
    confirmed-bugIssues and PRs for confirmed bugs.
    on Aug 14, 2015
  15. Trott commented on Oct 13, 2015

    @Trott
    Trott
    on Oct 13, 2015
    Member
    More actions

    Still returns 0 in v4.2.0.

  16. 72 remaining items

  17. targos
    closed this as completedin c2c6ae5on Jan 26, 2017
  18. targos
    added 3 commits that reference this issue on Jan 26, 2017

    repl: remove workaround for function redefinition

    007386e
  19. italoacasas
    added 2 commits that reference this issue on Feb 14, 2017

    test: move test-vm-function-redefinition to parallel

    8612a00

    repl: remove workaround for function redefinition

    fe2f058
  20. sjarmak
    added a commit that references this issue on Jul 27, 2026

    test: move test-vm-function-redefinition to parallel

    c2c6ae5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @fhinkel
    fhinkel

Labels

confirmed-bugIssues and PRs for confirmed bugs.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

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.