You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for building and maintaining quickjs-emscripten. I'm interested in using it to safely run user-defined logic on my server. I've come across a case where one user can make the vm take a very long time to run out of memory, and yet the interrupt callback never runs:
import{getQuickJS,Scope}from"quickjs-emscripten"constqjs=awaitgetQuickJS()constscope=newScope()construntime=scope.manage(qjs.newRuntime())constvm=scope.manage(runtime.newContext())runtime.setInterruptHandler(()=>true)// Always interruptruntime.setMemoryLimit(1024*640)runtime.setMaxStackSize(1024*320)// "Warm up" the vm - this DOES get interrupted, but only during the first runtry{vm.unwrapResult(vm.evalCode("{}")).dispose()}catch{}// Do something slowtry{// Make a large array and convert it to a string// The array is huge so this could take 10-30svm.unwrapResult(vm.evalCode("new Array(1_000_000_000) + ''\nundefined")).consume(vm.dump)// <--}catch(e){// Eventually I get InternalError: out of memory, but not soon enough!console.error(`${e}`)}scope.dispose()
This is a big issue because one user can affect the availability of the server for other users. I'd like to get the interrupt callback to run during my evalCode call, and would happily sacrifice performance to do so. Is this possible?
I've seen multiple places state that the interrupt handler runs every 1000 or so "instructions" or "cycles", is this 20s long operation really a single cycle?
The text was updated successfully, but these errors were encountered:
Thanks for building and maintaining quickjs-emscripten. I'm interested in using it to safely run user-defined logic on my server. I've come across a case where one user can make the vm take a very long time to run out of memory, and yet the interrupt callback never runs:
This is a big issue because one user can affect the availability of the server for other users. I'd like to get the interrupt callback to run during my evalCode call, and would happily sacrifice performance to do so. Is this possible?
I've seen multiple places state that the interrupt handler runs every 1000 or so "instructions" or "cycles", is this 20s long operation really a single cycle?
The text was updated successfully, but these errors were encountered: