laverdet / isolated-vm

Secure & isolated JS environments for nodejs
ISC License
2.18k stars 154 forks source link

Critical error on isolate.dispose with inspector session #497

Open DPOH-VAR opened 1 month ago

DPOH-VAR commented 1 month ago

this code causes an ctitical error

import IVM from "isolated-vm";
const isolate = new IVM.Isolate({inspector: true});
const inspector = isolate.createInspectorSession();

try {
    console.log("dispose - try");
    isolate.dispose(); // process.exit(-1073740791)
} finally {
    console.log("dispose - finally");
}
> node ./repro.js
dispose - try

> echo %errorlevel% 
-1073740791

I can fix it by dispose the inspector session before isolate:

import IVM from "isolated-vm";
const isolate = new IVM.Isolate({inspector: true});
const inspector = isolate.createInspectorSession();

try {
    console.log("dispose - try");
    inspector.dispose(); // need to dispose ALL sessions before isolate
    isolate.dispose();
} finally {
    console.log("dispose - finally");
}
laverdet commented 1 month ago

Did you try --no-node-snapshot

DPOH-VAR commented 1 month ago

same result

>node --no-node-snapshot ./repro.js  
dispose - try

>echo %errorlevel%
-1073740791
laverdet commented 1 month ago

Yeah it seems that dangling inspector sessions could cause a deadlock. Doesn't seem to be an easy fix but I will keep an eye on this.