Reduce V8 stack size to 256K. Otherwise the interface can be crashed with a stack overflow in a script.

This commit is contained in:
Dale Glass 2022-10-16 11:43:23 +02:00 committed by ksuprynowicz
parent e1c22b5c7c
commit 640cee0360

View file

@ -377,8 +377,15 @@ ScriptEngineV8::ScriptEngineV8(ScriptManager* scriptManager) :
_v8InitMutex.lock();
std::call_once ( _v8InitOnceFlag, [ ]{
v8::V8::InitializeExternalStartupData("");
//V8TODO might cause crashes if it's too much
v8::V8::SetFlagsFromString("--stack-size=900000");
// Experimentally determined that the maximum size that works on Linux with a stack size of 8192K is 8182.
// That would seem to be the overhead of our code and V8.
//
// Windows stacks are 1MB.
//
// Based on that, going with 256K for stacks for now. That seems like a reasonable value.
// We'll probably need a more complex system on the longer term, with configurable limits.
v8::V8::SetFlagsFromString("--stack-size=256");
v8::Platform* platform = getV8Platform();
v8::V8::InitializePlatform(platform);
v8::V8::Initialize(); qCDebug(scriptengine) << "V8 platform initialized";