aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAli Ijaz Sheikh <ofrobots@google.com>2016-03-18 08:32:33 -0700
committerAli Ijaz Sheikh <ofrobots@google.com>2016-03-19 07:45:38 -0700
commita53b2ac4b1dcde5579d9cba814ca0c4b78e59a9f (patch)
tree6a931b142c4cdf50b318c5d2cad652669ad98898 /test
parentbe97db92af7654ff9681eb98d8152a0fcb81ad20 (diff)
downloadandroid-node-v8-a53b2ac4b1dcde5579d9cba814ca0c4b78e59a9f.tar.gz
android-node-v8-a53b2ac4b1dcde5579d9cba814ca0c4b78e59a9f.tar.bz2
android-node-v8-a53b2ac4b1dcde5579d9cba814ca0c4b78e59a9f.zip
contextify: tie lifetimes of context & sandbox
When the previous set of changes (bfff07b4) it was possible to have the context get garbage collected while sandbox was still live. We need to tie the lifetime of the context to the lifetime of the sandbox. Fixes: https://github.com/nodejs/node/issues/5768 PR-URL: https://github.com/nodejs/node/pull/5786 Reviewed-By: jasnell - James M Snell <jasnell@gmail.com> Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com> Reviewed-By: trevnorris - Trevor Norris <trev.norris@gmail.com> Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-vm-create-and-run-in-context.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/parallel/test-vm-create-and-run-in-context.js b/test/parallel/test-vm-create-and-run-in-context.js
index 94527598ca..15efc8f527 100644
--- a/test/parallel/test-vm-create-and-run-in-context.js
+++ b/test/parallel/test-vm-create-and-run-in-context.js
@@ -1,4 +1,5 @@
'use strict';
+// Flags: --expose-gc
require('../common');
var assert = require('assert');
@@ -18,3 +19,11 @@ console.error('test updating context');
result = vm.runInContext('var foo = 3;', context);
assert.equal(3, context.foo);
assert.equal('lala', context.thing);
+
+// https://github.com/nodejs/node/issues/5768
+console.error('run in contextified sandbox without referencing the context');
+var sandbox = {x: 1};
+vm.createContext(sandbox);
+gc();
+vm.runInContext('x = 2', sandbox);
+// Should not crash.