Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc, test: document and test vm timeout escapes #23743

Closed
wants to merge 2 commits into from

Conversation

jasnell
Copy link
Member

@jasnell jasnell commented Oct 18, 2018

Finally getting back to this one ;-)

Using process.nextTick(), Promise, or queueMicrotask(), it
is possible to escape the timeout set when running code with
vm.runInContext(), vm.runInThisContext(), and
vm.runInNewContext().

This documents the issue and adds three known_issues tests.

Refs: #3020

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@jasnell
Copy link
Member Author

jasnell commented Oct 18, 2018

@jasnell jasnell added doc Issues and PRs related to the documentations. vm Issues and PRs related to the vm subsystem. known limitation Issues that are identified as known limitations. labels Oct 18, 2018
// it to fail reliably
if ((current - start) / NS_PER_MS >= 50n) {
throw new Error(
`escaped timeout at ${(current - start) / NS_PER_MS} milliseconds!`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: how about caching the result instead of recomputing it?

@vsemozhetbyt
Copy link
Contributor

I've run the example in all supported versions, last nightly and canary and every time I've got:

Error: Script execution timed[ out after 5ms]

and then the node exited and no infinite loops happened. Would it be confusing for a reader that would test the example?

@jasnell
Copy link
Member Author

jasnell commented Oct 19, 2018

@vsemozhetbyt ... I assume you're copying the example to a file then running it? If so, the unhandled error crashes the process. I've removed the second call to loop() in the example, which will prevent that and should show the infinite loop in action.

@vsemozhetbyt
Copy link
Contributor

Yes, I often test examples in file scripts)

Copy link
Member

@TimothyGu TimothyGu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the documentation, I would additionally drive home the fact that the timeout is not a security sandboxing mechanism, and that a more comprehensive solution could be running the untrusted code in a complete separate process. Overall looks good.

@jasnell
Copy link
Member Author

jasnell commented Oct 19, 2018

@TimothyGu ... there is already a warning in there for that, I believe. Doesn't mean it can't be made better but let's save that for a different PR.

@jasnell
Copy link
Member Author

jasnell commented Oct 19, 2018

Please 👍 to fast-track

@jasnell jasnell added the fast-track PRs that do not need to wait for 48 hours to land. label Oct 19, 2018
@vsemozhetbyt vsemozhetbyt added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Oct 19, 2018
@jasnell
Copy link
Member Author

jasnell commented Oct 23, 2018

@jasnell
Copy link
Member Author

jasnell commented Oct 23, 2018

Unfortunately the new tests here are flaky. Will have to investigate

@jasnell jasnell removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Oct 23, 2018
@jasnell jasnell force-pushed the doc-vm-timeout-escape2 branch from ac777ae to 5066c53 Compare October 23, 2018 22:13
@jasnell
Copy link
Member Author

jasnell commented Oct 23, 2018

@addaleax addaleax removed the fast-track PRs that do not need to wait for 48 hours to land. label Oct 24, 2018
Using `process.nextTick()`, `Promise`, or `queueMicrotask()`, it
is possible to escape the `timeout` set when running code with
`vm.runInContext()`, `vm.runInThisContext()`, and
`vm.runInNewContext()`.

This documents the issue and adds three known_issues tests.

Refs: nodejs#3020
These are known issues that can be flaky on certain platforms
because they rely entirely on timing differences.
@jasnell jasnell force-pushed the doc-vm-timeout-escape2 branch from 5066c53 to 47a2cb5 Compare October 24, 2018 15:05
@jasnell
Copy link
Member Author

jasnell commented Oct 24, 2018

Unfortunately, the known_issue tests appear to be inherently flaky due to the reliance on timing differences for them to fail. Marking them flaky in a separate commit. Not sure if there's a way to make them fail more reliably but having the known_issue tests in there, flaky or otherwise, is still generally a good idea.

New CI: https://ci.nodejs.org/job/node-test-pull-request/18117/

jasnell added a commit that referenced this pull request Oct 24, 2018
Using `process.nextTick()`, `Promise`, or `queueMicrotask()`, it
is possible to escape the `timeout` set when running code with
`vm.runInContext()`, `vm.runInThisContext()`, and
`vm.runInNewContext()`.

This documents the issue and adds three known_issues tests.

Refs: #3020
PR-URL: #23743
Refs: #3020
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
jasnell added a commit that referenced this pull request Oct 24, 2018
These are known issues that can be flaky on certain platforms
because they rely entirely on timing differences.

PR-URL: #23743
Refs: #3020
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
@jasnell
Copy link
Member Author

jasnell commented Oct 24, 2018

Landed in 5e5a945 and 095a602

@jasnell jasnell closed this Oct 24, 2018
targos pushed a commit that referenced this pull request Oct 26, 2018
Using `process.nextTick()`, `Promise`, or `queueMicrotask()`, it
is possible to escape the `timeout` set when running code with
`vm.runInContext()`, `vm.runInThisContext()`, and
`vm.runInNewContext()`.

This documents the issue and adds three known_issues tests.

Refs: #3020
PR-URL: #23743
Refs: #3020
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
targos pushed a commit that referenced this pull request Oct 26, 2018
These are known issues that can be flaky on certain platforms
because they rely entirely on timing differences.

PR-URL: #23743
Refs: #3020
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
@Trott
Copy link
Member

Trott commented Nov 6, 2018

Looks like the test may be flaky...https://ci.nodejs.org/job/node-test-commit-smartos/21423/nodes=smartos16-64/console I'll open an issue.

@MylesBorins
Copy link
Contributor

MylesBorins commented Nov 26, 2018

will hold off on landing in LTS until it is clearly not flaky

@Trott
Copy link
Member

Trott commented Nov 27, 2018

Flakiness was addressed (partially at least?) in 8e3c5b5 and a4a2e9f.

@Trott
Copy link
Member

Trott commented Nov 27, 2018

test-vm-timeout-escape-promise is still marked as flaky in the status file. Not sure how often it actually flakes, though.

codebytere pushed a commit that referenced this pull request Dec 13, 2018
Using `process.nextTick()` or `Promise`, it
is possible to escape the `timeout` set when running code with
`vm.runInContext()`, `vm.runInThisContext()`, and
`vm.runInNewContext()`.

This documents the issue and adds two known_issues tests.

Refs: #3020
PR-URL: #23743
Refs: #3020
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
codebytere pushed a commit that referenced this pull request Dec 13, 2018
These are known issues that can be flaky on certain platforms
because they rely entirely on timing differences.

PR-URL: #23743
Refs: #3020
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
MylesBorins pushed a commit that referenced this pull request Dec 26, 2018
Using `process.nextTick()` or `Promise`, it
is possible to escape the `timeout` set when running code with
`vm.runInContext()`, `vm.runInThisContext()`, and
`vm.runInNewContext()`.

This documents the issue and adds two known_issues tests.

Refs: #3020
PR-URL: #23743
Refs: #3020
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
MylesBorins pushed a commit that referenced this pull request Dec 26, 2018
These are known issues that can be flaky on certain platforms
because they rely entirely on timing differences.

PR-URL: #23743
Refs: #3020
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
@codebytere codebytere mentioned this pull request Jan 4, 2019
@sam-github sam-github added flaky-test Issues and PRs related to the tests with unstable failures on the CI. linux Issues and PRs related to the Linux platform. labels Jun 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. flaky-test Issues and PRs related to the tests with unstable failures on the CI. known limitation Issues that are identified as known limitations. linux Issues and PRs related to the Linux platform. vm Issues and PRs related to the vm subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants