Repository: godot
Issue: Editor crash when saving. Related to export Array / tool mode node instantiation
Labels: bug,topic:editor,crash

**Godot** version: 3.3
**OS:** LinuxMint 20.1

Editor crashes when saving scene. This is related to nodes having an exported Array. Initially posted as a 'question' here: https://godotengine.org/qa/102990/tool-mode-script-instancing-nodes-crashes-export-array-issue

Steps to recreate:
- Create new project, add a Node2D
- Add a Sprite to the Node2d and attach the below script to it. Save the sprite node as "MySprite.tscn"
- Click the 'createNewTool' checkbox in the editor to create a new instance (this works fine)
- Now select the newly created MySprite in the editor and click the 'createNewTool' checkbox on that.
- Try to save (ctrl+s) and the editor will crash.

Script:
```
tool
extends Sprite

export var relatedList = [] #No crash if the array isn't exposed
export (bool) var createNewTool = false setget create_new #editor 'button' to create new instance

var sceneResource = load("res://MySprite.tscn")

func create_new(value):
    if Engine.is_editor_hint():
        #create new instance and add to scene/tree
        var newSprite = sceneResource.instance()
        get_parent().add_child(newSprite)
        newSprite.set_owner(get_tree().get_edited_scene_root())

        #update list of related nodes
        relatedList.push_back(newSprite)
        newSprite.relatedList.push_back(self)

        #update exported array values
        property_list_changed_notify()
        newSprite.property_list_changed_notify()
```

Valgrind log thanks to Lopy, ran with `valgrind ./Editor --editor --path ./debug`:
```
==62415== Stack overflow in thread #1: can't grow stack to 0x1ffe801000
==62415== Stack overflow in thread #1: can't grow stack to 0x1ffe801000
==62415== Can't extend stack to 0x1ffe801078 during signal delivery for thread 1:
==62415==   no stack segment
==62415== 
==62415== Process terminating with default action of signal 11 (SIGSEGV)
==62415==  Access not within mapped region at address 0x1FFE801078
==62415== Stack overflow in thread #1: can't grow stack to 0x1ffe801000
==62415==    at 0x77F1AF7: __printf_fp_l (printf_fp.c:933)
==62415==  If you believe this happened as a result of a stack
==62415==  overflow in your program's main thread (unlikely but
==62415==  possible), you can try to increase the size of the
==62415==  main thread stack using the --main-stacksize= flag.
==62415==  The main thread stack size used in this run was 8388608.
==62415== Stack overflow in thread #1: can't grow stack to 0x1ffe801000
==62415== 
==62415== Process terminating with default action of signal 11 (SIGSEGV)
==62415==  Access not within mapped region at address 0x1FFE801F40
==62415== Stack overflow in thread #1: can't grow stack to 0x1ffe801000
==62415==    at 0x71C2134: _vgnU_freeres (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_core-amd64-linux.so)
==62415==  If you believe this happened as a result of a stack
==62415==  overflow in your program's main thread (unlikely but
==62415==  possible), you can try to increase the size of the
==62415==  main thread stack using the --main-stacksize= flag.
==62415==  The main thread stack size used in this run was 8388608.
```