Godot version:
Godot 3.1 stable
OS/device including version:
Windows 10 x64
Issue description:
Could be related to #21545
I've opened a project that I've been working on since 3.0.6 in 3.1, and wanted to try out the Tileset editor. Once I opened the editor, I tried to edit the Tileset, and it crashed. It worked for a polygon collision, but when editing a tile with rectangle polygon collision, it crashed.
Steps to reproduce:
For the minimal reproduction project:
Sprites with rectangular collision crash, but polygons seem to work.
Minimal reproduction project:
Backtrace:
ERROR: get: FATAL: Index p_index=0 out of size (size()=0)
At: ./core/cowdata.h:151.
handle_crash: Program crashed with signal 4
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x3ef20) [0x7ff7702c0f20] (??:0)
[2] CowData<Vector2>::get(int) const (/home/rafal/Pulpit/godot/./core/cowdata.h:151 (discriminator 7))
[3] Vector<Vector2>::operator[](int) const (/home/rafal/Pulpit/godot/./core/vector.h:85)
[4] TileSetEditor::draw_polygon_shapes() (/home/rafal/Pulpit/godot/editor/plugins/tile_set_editor_plugin.cpp:2429)
[5] TileSetEditor::_on_workspace_draw() (/home/rafal/Pulpit/godot/editor/plugins/tile_set_editor_plugin.cpp:881)
[6] MethodBind0::call(Object*, Variant const**, int, Variant::CallError&) (/home/rafal/Pulpit/godot/./core/method_bind.gen.inc:56 (discriminator 4))
[7] Object::call(StringName const&, Variant const**, int, Variant::CallError&) (/home/rafal/Pulpit/godot/core/object.cpp:942 (discriminator 1))
[8] Object::emit_signal(StringName const&, Variant const**, int) (/home/rafal/Pulpit/godot/core/object.cpp:1228 (discriminator 1))
[9] Object::emit_signal(StringName const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&) (/home/rafal/Pulpit/godot/core/object.cpp:1285)
[10] CanvasItem::_update_callback() (/home/rafal/Pulpit/godot/scene/2d/canvas_item.cpp:455)
[11] MethodBind0::call(Object*, Variant const**, int, Variant::CallError&) (/home/rafal/Pulpit/godot/./core/method_bind.gen.inc:56 (discriminator 4))
[12] Object::call(StringName const&, Variant const**, int, Variant::CallError&) (/home/rafal/Pulpit/godot/core/object.cpp:942 (discriminator 1))
[13] MessageQueue::_call_function(Object*, StringName const&, Variant const*, int, bool) (/home/rafal/Pulpit/godot/core/message_queue.cpp:256)
[14] MessageQueue::flush() (/home/rafal/Pulpit/godot/core/message_queue.cpp:305)
[15] SceneTree::iteration(float) (/home/rafal/Pulpit/godot/scene/main/scene_tree.cpp:477 (discriminator 2))
[16] Main::iteration() (/home/rafal/Pulpit/godot/main/main.cpp:1862)
[17] OS_X11::run() (/home/rafal/Pulpit/godot/platform/x11/os_x11.cpp:3006)
[18] /usr/bin/godot(main+0xdc) [0x116b5f3] (/home/rafal/Pulpit/godot/platform/x11/godot_x11.cpp:56)
[19] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7) [0x7ff7702a3b97] (??:0)
[20] /usr/bin/godot(_start+0x2a) [0x116b45a] (??:?)
I'm very new to Godot but loving it, I wanted to help out so here is a quick GIF replicating the issue.

Crash happens here, and it caused because polygon.size() is equal to 0.
As workaround(I don't see a side effects) you can compile godot after adding at the top of this line:
https://github.com/godotengine/godot/blob/775e74e0d41daa9cf3679c2e215f4ef46eee9cbc/editor/plugins/tile_set_editor_plugin.cpp#L2420-L2422
this code:
if (polygon.size() == 0)
continue;
There is no 3.2 yet?
Most helpful comment
https://github.com/godotengine/godot/blob/775e74e0d41daa9cf3679c2e215f4ef46eee9cbc/editor/plugins/tile_set_editor_plugin.cpp#L2425-L2430
Crash happens here, and it caused because polygon.size() is equal to 0.
As workaround(I don't see a side effects) you can compile godot after adding at the top of this line:
https://github.com/godotengine/godot/blob/775e74e0d41daa9cf3679c2e215f4ef46eee9cbc/editor/plugins/tile_set_editor_plugin.cpp#L2420-L2422
this code: