Set qjs stack limit to 7MB (#26489)

* Set qjs stack limit to 7MB

* Update distribution/changelog.txt

Co-authored-by: Michał Janiszewski <janisozaur@users.noreply.github.com>

---------

Co-authored-by: Michał Janiszewski <janisozaur@users.noreply.github.com>
This commit is contained in:
mrmbernardiandMichał Janiszewski authored and GitHub committed 2026-05-16 17:26:29 +02:00
1 parent 169e7345f7
commit e4ba212574
4 files changed
+15 -15

No files matched your search

+1
View File
@@ -14,6 +14,7 @@
- Fix: [#26352] The label for path additions is using the wrong text colour in the tile inspector.
- Fix: [#26360] Inverted Lay-down Roller Coaster helices are invisible when loading old saves.
- Fix: [#26410] Tiles with water can draw incorrectly when there is something underwater and nothing above water.
- Fix: [#26418] Game crashes when a stack overflow occurs in plugin code.
- Fix: [#26419] Drop count & negative g’s stat requirements for Flying Roller Coaster don’t get nullified by having an inversion.
- Fix: [#26421] Wrong scenery tab highlighted when more than 64 scenery groups are selected.
- Fix: [#26425] Benches don’t reduce watching spots from 4 to 2 while other path additions do (should be reversed).
+6 -13
View File
@@ -546,14 +546,18 @@ namespace OpenRCT2
// TODO: preload the title scene in another (parallel) job.
preloaderScene->AddJob([this]() { InitialiseRepositories(); });
preloaderScene->AddJob([this]() { InitialiseScriptEngine(); });
}
else
{
InitialiseRepositories();
InitialiseScriptEngine();
}
#ifdef ENABLE_SCRIPTING
// quickjs script engine is single-threaded and must be set up on the main thread
_scriptEngine.Initialise();
_uiContext->InitialiseScriptExtensions();
#endif
return true;
}
@@ -618,17 +622,6 @@ namespace OpenRCT2
OpenProgress(STR_LOADING_GENERIC);
}
void InitialiseScriptEngine()
{
#ifdef ENABLE_SCRIPTING
OpenProgress(STR_LOADING_PLUGIN_ENGINE);
_scriptEngine.Initialise();
_uiContext->InitialiseScriptExtensions();
OpenProgress(STR_LOADING_GENERIC);
#endif
}
public:
void InitialiseDrawingEngine() final override
{
+1 -2
View File
@@ -490,8 +490,7 @@ void ScriptEngine::Initialise()
#endif
}
// Disable maximum stack size limit for the JS engine.
JS_SetMaxStackSize(_runtime, 0);
JS_SetMaxStackSize(_runtime, kJsStackSize);
_replContext = JS_NewContext(_runtime);
if (!_replContext)
+7
View File
@@ -51,6 +51,13 @@ namespace OpenRCT2::Scripting
static constexpr int32_t kApiVersionCustomActionArgs = 68;
static constexpr int32_t kApiVersionNetworkIDs = 77;
// This stack limit is not precise as quickjs-ng just sets a hard boundary offset from the stack frame
// where the limit is updated. The actual limit available to quickjs will be more or less depending on
// how big the native stack is relative to its size when the limit was first set.
// Calculating a precise limit is possible but requires platform specifc code for all possible platforms
// to get the end of the reserved stack space.
static constexpr size_t kJsStackSize = 1024 * 1024 * 7;
#ifndef DISABLE_NETWORK
struct SocketDataBase;
#endif