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

memoryLimit not being applied to isolate #460

Open
davidjb opened this issue Mar 8, 2024 · 0 comments
Open

memoryLimit not being applied to isolate #460

davidjb opened this issue Mar 8, 2024 · 0 comments

Comments

@davidjb
Copy link
Contributor

davidjb commented Mar 8, 2024

Using the test code from https://github.com/laverdet/isolated-vm/blob/main/tests/catastrophic-error.js#L14, I'm testing as to the behaviour of OOM conditions. However, when running the following (e.g. just with node example.mjs), the memorySize limit isn't applied and the node process continues using 100% CPU and consuming memory until manually killed.

import ivm from 'isolated-vm';

for (const run of [
  context => context.eval('ivm.lib.testOOM()'),
]) {
  const isolate = new ivm.Isolate({
    memoryLimit: 128,
    onCatastrophicError: message => {
      console.log(message);
    },
  });
  const context = isolate.createContextSync();
  context.global.setSync('ivm', ivm);
  run(context);
}
Screenshot 2024-03-08 at 16 22 24

By comparison, running the example from https://github.com/laverdet/isolated-vm/?tab=readme-ov-file#examples behaves as the example shows, with the process ending with RangeError. Decreasing the memorySize in the example works - dropping the limit to 8MB sees the script end after 10MB.

Versions

  • isolated-vm v4.7.2
  • Node.js v21.6.2
  • gcc --version:
    Apple clang version 15.0.0 (clang-1500.1.0.2.5)
    Target: arm64-apple-darwin23.3.0
    Thread model: posix
    InstalledDir: /Library/Developer/CommandLineTools/usr/bin
    
  • macOS 14.3.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant