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

runInContext breaks node process #13464

Closed
hsiliev opened this issue Jun 5, 2017 · 7 comments
Closed

runInContext breaks node process #13464

hsiliev opened this issue Jun 5, 2017 · 7 comments
Labels
vm Issues and PRs related to the vm subsystem.

Comments

@hsiliev
Copy link

hsiliev commented Jun 5, 2017

  • Version:
    • 6.10.3
    • 7.10.0
  • Platform:
    • Darwin SOFM33780462A 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64
    • Linux ip-10-0-0-11 3.13.0-74-generic Is it io.js, IO.js, or something else? #118-Ubuntu SMP Thu Dec 17 22:52:10 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem: vm

When the following code is executed:

"use strict";

const vm = require('vm');

let i = 0;

while(true) {

  try {
    const context = {};
    vm.createContext(context);
    vm.runInContext(
      '"use strict"; ( 1 + 1 )',
      context,
      { timeout: 1 }
    );
  } catch (e) {
    console.log('Exception: %j', e);
  }

  console.log('Attempt: %d', ++i);
}

Node 6 & node 7 on both Mac & Linux, it bails out with exit code 0 , instead of looping endlessly. We get 2 to max 80 iterations without any exception logged.

Interesting is also the fact that under high load in containerized environment (Cloud Foundry's Garden) the context execution blocks. Even with 1000 ms timeout it never returns or throws exception. We observed a call hanging for > 48 hours.

With node 8 the code works correctly and we get the expected endless loop with occasional exceptions due to the extremely low timeout.

@vsemozhetbyt vsemozhetbyt added the vm Issues and PRs related to the vm subsystem. label Jun 5, 2017
@bnoordhuis
Copy link
Member

@addaleax I think this was fixed by #13074?

@addaleax addaleax added the v6.x label Jun 5, 2017
@addaleax
Copy link
Member

addaleax commented Jun 5, 2017

I think this was fixed by #13074?

Yes, seems a lot like it.

@hsiliev We have a rule that patches have to live in a Current release line (i.e. 8.x) for 2 weeks before backporting to the LTS release lines, so you might need to wait a bit until the patch is out, or use 8.x until then.

@georgi-lozev
Copy link

Any updates on this one, is it already backported to the LTS?

@gibfahn
Copy link
Member

gibfahn commented Jun 22, 2017

Any updates on this one, is it already backported to the LTS?

There's a good chance it'll go into 6.11.1.

@hsiliev
Copy link
Author

hsiliev commented Jul 29, 2017

The problem reproduces with 6.11.1 and 7.10.1

The code above works fine with 8.2.1

@fhinkel
Copy link
Member

fhinkel commented Aug 3, 2017

The fix was applied to 6.11.2 two weeks ago, see #14373. I just checked and it seemed to work fine (endless loop). I'm closing this. Let me know if I misunderstood and this should remain open. Thanks for reporting!

@fhinkel fhinkel closed this as completed Aug 3, 2017
@hsiliev
Copy link
Author

hsiliev commented Aug 9, 2017

Works like charm. Thanks for the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vm Issues and PRs related to the vm subsystem.
Projects
None yet
Development

No branches or pull requests

7 participants