Skip to content

Function redefinition in vm.runInContext #548

Description

@kyriosli

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

  1. Fishrock123 commented on Jan 22, 2015

    @Fishrock123
    Contributor

    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
    Author

    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
    Contributor

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

  4. domenic commented on Jan 22, 2015

    @domenic
    Contributor

    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
    Contributor

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

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

    @domenic
    Contributor

    @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
    Contributor
  9. 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
    Member

    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
    Contributor

    @domenic is this fixed in next?

  12. domenic commented on Jun 5, 2015

    @domenic
    Contributor

    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
    Contributor

    Behavior still occurs in 3.0, marking as a bug!

  14. Trott commented on Oct 13, 2015

    @Trott
    Member

    Still returns 0 in v4.2.0.

  15. 72 remaining items

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

Metadata

Metadata

Assignees

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