1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

GDScript: Add limit to call depth

The hard limit is set at 2048 depth which seems sensible between
legitimate recursive calls while still avoiding a crash because of a
stack overflow in most of the cases.

Note that it is still possible to reach the stack limit and get an
overflow before reaching a call depth. This is intended as a half-way
measure to stop crashing in most cases, since there's no reliable nor
portable way to check the amount of stack memory left.
This commit is contained in:
George Marques
2023-02-07 17:09:40 -03:00
parent a05670c617
commit 34f0a2ca46
3 changed files with 35 additions and 1 deletions

View File

@@ -544,6 +544,8 @@ private:
#endif
public:
static constexpr int MAX_CALL_DEPTH = 2048; // Limit to try to avoid crash because of a stack overflow.
struct CallState {
GDScript *script = nullptr;
GDScriptInstance *instance = nullptr;