mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +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:
parent
a05670c617
commit
34f0a2ca46
3 changed files with 35 additions and 1 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue