isolated-vm icon indicating copy to clipboard operation
isolated-vm copied to clipboard

Isolated VM Occassionally Crashing Node

Open apcqa opened this issue 4 months ago • 2 comments

I am evaluating user code on a docker node-20.19.4-slim image

Sometimes the whole app crashes. I have managed to collect the trace below.

What confuses me is that 'Uncaught SyntaxError: Invalid or unexpected token' suggests the user input is invalid, fine, but his should'nt crash the whole app, just throw a js error.

2025-08-07T14:07:56.7792481Z Uncaught SyntaxError: Invalid or unexpected token
2025-08-07T14:07:56.7793005Z
2025-08-07T14:07:56.7793035Z FROM
2025-08-07T14:07:56.8010037Z
2025-08-07T14:07:56.8010353Z Thread 26 "node" received signal SIGTRAP, Trace/breakpoint trap.
2025-08-07T14:07:56.8010413Z [Switching to Thread 0x7ffd0d8ff700 (LWP 43)]
2025-08-07T14:07:56.8010431Z 0x00000000021a5482 in v8::base::OS::Abort() ()
2025-08-07T14:07:56.8022077Z #0  0x00000000021a5482 in v8::base::OS::Abort() ()
2025-08-07T14:07:56.8024941Z #1  0x000000000108d187 in v8::internal::Isolate::CreateMessageOrAbort(v8::internal::Handle<v8::internal::Object>, v8::internal::MessageLocation*) ()
2025-08-07T14:07:56.8030994Z #2  0x000000000108d4d6 in v8::internal::Isolate::ThrowInternal(v8::internal::Object, v8::internal::MessageLocation*) ()
2025-08-07T14:07:56.8038705Z #3  0x00000000014798d5 in v8::internal::PendingCompilationErrorHandler::ReportErrors(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Script>) const ()
2025-08-07T14:07:56.8044485Z #4  0x0000000000fcf110 in v8::internal::(anonymous namespace)::CompileToplevel(v8::internal::ParseInfo*, v8::internal::Handle<v8::internal::Script>, v8::internal::MaybeHandle<v8::internal::ScopeInfo>, v8::internal::Isolate*, v8::internal::IsCompiledScope*) ()
2025-08-07T14:07:56.8049789Z #5  0x0000000000fcf238 in v8::internal::(anonymous namespace)::CompileScriptOnMainThread(v8::internal::UnoptimizedCompileFlags, v8::internal::Handle<v8::internal::String>, v8::internal::ScriptDetails const&, v8::internal::NativesFlag, v8::Extension*, v8::internal::Isolate*, v8::internal::MaybeHandle<v8::internal::Script>, v8::internal::IsCompiledScope*) ()
2025-08-07T14:07:56.8056893Z #6  0x0000000000fcf533 in v8::internal::(anonymous namespace)::GetSharedFunctionInfoForScriptImpl(v8::internal::Isolate*, v8::internal::Handle<v8::internal::String>, v8::internal::ScriptDetails const&, v8::Extension*, v8::internal::AlignedCachedData*, v8::internal::BackgroundDeserializeTask*, bool (*)(int, void*), void*, v8::ScriptCompiler::CompileOptions, v8::ScriptCompiler::NoCacheReason, v8::internal::NativesFlag) [clone .constprop.0] ()
2025-08-07T14:07:56.8062466Z #7  0x0000000000fd063a in v8::internal::Compiler::GetSharedFunctionInfoForScript(v8::internal::Isolate*, v8::internal::Handle<v8::internal::String>, v8::internal::ScriptDetails const&, v8::ScriptCompiler::CompileOptions, v8::ScriptCompiler::NoCacheReason, v8::internal::NativesFlag) ()
2025-08-07T14:07:56.8068682Z #8  0x0000000000f30043 in v8::ScriptCompiler::CompileUnboundInternal(v8::Isolate*, v8::ScriptCompiler::Source*, v8::ScriptCompiler::CompileOptions, v8::ScriptCompiler::NoCacheReason) [clone .part.0] ()
2025-08-07T14:07:56.8074233Z #9  0x0000000000f30698 in v8::ScriptCompiler::Compile(v8::Local<v8::Context>, v8::ScriptCompiler::Source*, v8::ScriptCompiler::CompileOptions, v8::ScriptCompiler::NoCacheReason) ()
2025-08-07T14:07:56.8103120Z #10 0x00007fffd2f6b210 in auto ivm::RunWithAnnotatedErrors<ivm::EvalRunner::Phase2()::{lambda()#1}>(ivm::EvalRunner::Phase2()::{lambda()#1}) () from /usr/local/app/my-api/node_modules/isolated-vm/out/isolated_vm.node
2025-08-07T14:07:56.8108973Z #11 0x00007fffd2f6f4a1 in ivm::EvalRunner::Phase2() () from /usr/local/app/my-api/node_modules/isolated-vm/out/isolated_vm.node
2025-08-07T14:07:56.8114922Z #12 0x00007fffd2f5a639 in ?? () from /usr/local/app/my-api/node_modules/isolated-vm/out/isolated_vm.node
2025-08-07T14:07:56.8120550Z #13 0x00007fffd2f5a8cc in ivm::ThreePhaseTask::Phase2Runner::Run() () from /usr/local/app/my-api/node_modules/isolated-vm/out/isolated_vm.node
2025-08-07T14:07:56.8127397Z #14 0x00007fffd2f49925 in ivm::IsolateEnvironment::AsyncEntry() () from /usr/local/app/my-api/node_modules/isolated-vm/out/isolated_vm.node
2025-08-07T14:07:56.8133275Z #15 0x00007fffd2f567d2 in ?? () from /usr/local/app/my-api/node_modules/isolated-vm/out/isolated_vm.node
2025-08-07T14:07:56.8139039Z #16 0x00007fffd2f5c5ab in ?? () from /usr/local/app/my-api/node_modules/isolated-vm/out/isolated_vm.node
2025-08-07T14:07:56.8144987Z #17 0x00007ffff7ebded0 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
2025-08-07T14:07:56.8184368Z #18 0x00007ffff7c76ea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
2025-08-07T14:07:56.8185718Z #19 0x00007ffff7b96adf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
2025-08-07T14:07:56.8832535Z Container has finished running with exit code: 0.
2025-08-07T14:07:56.8834238Z Container is terminating. Grace period: 5 seconds.``

apcqa avatar Aug 07 '25 14:08 apcqa

I think I've seen this issue before but I don't remember the cause. The older version of nodejs makes me think it was something that got fixed later. Could you try on nodejs v24 and isolated-vm v6?

laverdet avatar Aug 08 '25 00:08 laverdet

Apollogies, i think the IVM crash was a result of having the node option --abort-on-uncaught-exception. I've been trying for days to identify the souce of an intermittent crash and anything with binaries is a suspect.

apcqa avatar Aug 08 '25 10:08 apcqa