Skip to content

vm: recent contextify changes cause segmentation fault in node v5.9 #5768

@raymondfeng

Description

@raymondfeng

A recent change made to node_contextify.cc that was released in node 5.9.0 causes node to segfault.

The offending commit is this: bfff07b

The problem can be reproduced using the following test script:

var vm = require('vm');

function f() {
  var sandbox = {};
  vm.createContext(sandbox);

  return function(script, ctx) {
    var s = new vm.Script(script);
    for(var p in ctx) { sandbox[p] = ctx[p]; };
    var result = s.runInContext(sandbox);
    console.log(result, sandbox);
    for(var p in sandbox) { delete sandbox[p]; };
  }
}

for(var i=0; i<10000; i++) {
  f()('x = 3', {x : 1});
  f()('x = 4', {x : 2});
}
$ node -v
v5.9.0
$ uname -a
Darwin raymond-117.local 15.3.0 Darwin Kernel Version 15.3.0: Thu Dec 10 18:40:58 PST 2015; root:xnu-3248.30.4~1/RELEASE_X86_64 x86_64

cc @ofrobots and @bnoordhuis

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.vmIssues and PRs related to the vm subsystem.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions