contextify: tie lifetimes of context & sandbox
Pull Request check-list
-
Does make -j8 test
(UNIX) orvcbuild test nosign
(Windows) pass with this change (including linting)? -
Is the commit message formatted according to [CONTRIBUTING.md][0]? -
If this change fixes a bug (or a performance problem), is a regression test (or a benchmark) included?
Affected core subsystem(s)
contextify
Description of change
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 R=@bnoordhuis /cc @evanlucas @cjihrig
Note that this is not trivially back-portable to 5.x. SetPrivate
doesn't exist on 5.x, but I can create a new PR once this lands on master. This does continue to address the memory growth issue reported in #3113 (closed), but we should get this vetted before backporting.