godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.98k stars 21.16k forks source link

Several physics related crashes when running test project #47440

Open qarmin opened 3 years ago

qarmin commented 3 years ago

Godot version: 3.3.rc.custom_build. ed1f5c29b

OS Ubuntu 20.04 - Ubuntu 3.36 X11

Issue description: Running my new physics test project crashes Godot with very different backtraces. Some of crashes was reported in e.g. #47438, but since I have seen a lot of different backtraces, I'm not sure if they are releated and it is very hard to create minimal project, so I'm posting here full project.

If needed, I will create 4.0 version of this project

Example asan report with backtrace:

ERROR: get: FATAL: Index p_index = 0 is out of bounds (size() = 0).
   At: ./core/cowdata.h:156.
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] godots() [0x1736270] (/mnt/Miecz/godot3.2/platform/x11/crash_handler_x11.cpp:54)
[2] /lib/x86_64-linux-gnu/libc.so.6(+0x46210) [0x7fa1844a9210] (??:0)
[3] CowData<ConcavePolygonShape2DSW::Segment>::get(int) const (/mnt/Miecz/godot3.2/./core/cowdata.h:156 (discriminator 7))
[4] Vector<ConcavePolygonShape2DSW::Segment>::operator[](int) const (/mnt/Miecz/godot3.2/./core/vector.h:85)
[5] ConcavePolygonShape2DSW::intersect_segment(Vector2 const&, Vector2 const&, Vector2&, Vector2&) const (/mnt/Miecz/godot3.2/servers/physics_2d/shape_2d_sw.cpp:770 (discriminator 2))
[6] CollisionSolver2DSW::solve_raycast(Shape2DSW const*, Vector2 const&, Transform2D const&, Shape2DSW const*, Transform2D const&, void (*)(Vector2 const&, Vector2 const&, void*), void*, bool, Vector2*) (/mnt/Miecz/godot3.2/servers/physics_2d/collision_solver_2d_sw.cpp:95)
[7] CollisionSolver2DSW::solve(Shape2DSW const*, Transform2D const&, Vector2 const&, Shape2DSW const*, Transform2D const&, Vector2 const&, void (*)(Vector2 const&, Vector2 const&, void*), void*, Vector2*, float, float) (/mnt/Miecz/godot3.2/servers/physics_2d/collision_solver_2d_sw.cpp:233)
[8] Space2DSW::test_body_motion(Body2DSW*, Transform2D const&, Vector2 const&, bool, float, Physics2DServer::MotionResult*, bool) (/mnt/Miecz/godot3.2/servers/physics_2d/space_2d_sw.cpp:830 (discriminator 1))
[9] Physics2DServerSW::body_test_motion(RID, Transform2D const&, Vector2 const&, bool, float, Physics2DServer::MotionResult*, bool) (/mnt/Miecz/godot3.2/servers/physics_2d/physics_2d_server_sw.cpp:1051)
[10] Physics2DServerWrapMT::body_test_motion(RID, Transform2D const&, Vector2 const&, bool, float, Physics2DServer::MotionResult*, bool) (/mnt/Miecz/godot3.2/servers/physics_2d/physics_2d_server_wrap_mt.h:262)
[11] KinematicBody2D::move_and_collide(Vector2 const&, bool, KinematicBody2D::Collision&, bool, bool) (/mnt/Miecz/godot3.2/scene/2d/physics_body_2d.cpp:1189 (discriminator 1))
[12] KinematicBody2D::move_and_slide(Vector2 const&, Vector2 const&, bool, int, float, bool) (/mnt/Miecz/godot3.2/scene/2d/physics_body_2d.cpp:1249)
[13] MethodBind6R<Vector2, Vector2 const&, Vector2 const&, bool, int, float, bool>::call(Object*, Variant const**, int, Variant::CallError&) (/mnt/Miecz/godot3.2/./core/method_bind_ext.gen.inc:309 (discriminator 28))
[14] Object::call(StringName const&, Variant const**, int, Variant::CallError&) (/mnt/Miecz/godot3.2/core/object.cpp:919 (discriminator 1))
[15] Object::callv(StringName const&, Array const&) (/mnt/Miecz/godot3.2/core/object.cpp:826 (discriminator 1))
[16] MethodBind2R<Variant, StringName const&, Array const&>::call(Object*, Variant const**, int, Variant::CallError&) (/mnt/Miecz/godot3.2/./core/method_bind.gen.inc:1717 (discriminator 12))
[17] Object::call(StringName const&, Variant const**, int, Variant::CallError&) (/mnt/Miecz/godot3.2/core/object.cpp:919 (discriminator 1))
[18] Variant::call_ptr(StringName const&, Variant const**, int, Variant*, Variant::CallError&) (/mnt/Miecz/godot3.2/core/variant_call.cpp:1149 (discriminator 1))
[19] GDScriptFunction::call(GDScriptInstance*, Variant const**, int, Variant::CallError&, GDScriptFunction::CallState*) (/mnt/Miecz/godot3.2/modules/gdscript/gdscript_function.cpp:1089)
[20] GDScriptInstance::call(StringName const&, Variant const**, int, Variant::CallError&) (/mnt/Miecz/godot3.2/modules/gdscript/gdscript.cpp:1208)
[21] Object::call(StringName const&, Variant const**, int, Variant::CallError&) (/mnt/Miecz/godot3.2/core/object.cpp:898 (discriminator 1))
[22] Variant::call_ptr(StringName const&, Variant const**, int, Variant*, Variant::CallError&) (/mnt/Miecz/godot3.2/core/variant_call.cpp:1149 (discriminator 1))
[23] GDScriptFunction::call(GDScriptInstance*, Variant const**, int, Variant::CallError&, GDScriptFunction::CallState*) (/mnt/Miecz/godot3.2/modules/gdscript/gdscript_function.cpp:1089)
[24] GDScriptInstance::call(StringName const&, Variant const**, int, Variant::CallError&) (/mnt/Miecz/godot3.2/modules/gdscript/gdscript.cpp:1208)
[25] Object::call(StringName const&, Variant const**, int, Variant::CallError&) (/mnt/Miecz/godot3.2/core/object.cpp:898 (discriminator 1))
[26] Variant::call_ptr(StringName const&, Variant const**, int, Variant*, Variant::CallError&) (/mnt/Miecz/godot3.2/core/variant_call.cpp:1149 (discriminator 1))
[27] GDScriptFunction::call(GDScriptInstance*, Variant const**, int, Variant::CallError&, GDScriptFunction::CallState*) (/mnt/Miecz/godot3.2/modules/gdscript/gdscript_function.cpp:1089)
[28] GDScriptInstance::call_multilevel(StringName const&, Variant const**, int) (/mnt/Miecz/godot3.2/modules/gdscript/gdscript.cpp:1224)
[29] Node::_notification(int) (/mnt/Miecz/godot3.2/scene/main/node.cpp:67)
[30] Node::_notificationv(int, bool) (/mnt/Miecz/godot3.2/./scene/main/node.h:46 (discriminator 14))
[31] Object::notification(int, bool) (/mnt/Miecz/godot3.2/core/object.cpp:931)
[32] SceneTree::_notify_group_pause(StringName const&, int) (/mnt/Miecz/godot3.2/scene/main/scene_tree.cpp:993)
[33] SceneTree::iteration(float) (/mnt/Miecz/godot3.2/scene/main/scene_tree.cpp:486 (discriminator 2))
[34] Main::iteration() (/mnt/Miecz/godot3.2/main/main.cpp:2100)
[35] OS_X11::run() (/mnt/Miecz/godot3.2/platform/x11/os_x11.cpp:3641)
[36] godots(main+0x326) [0x172cefc] (/mnt/Miecz/godot3.2/platform/x11/godot_x11.cpp:57)
[37] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7fa18448a0b3] (??:0)
[38] godots(_start+0x2e) [0x172cb1e] (??:?)

Steps to reproduce:

  1. Run minimal project

Minimal reproduction project: Physics.zip

qarmin commented 3 years ago

4.0 version of project - 4.0.zip

qarmin commented 3 years ago

Sometimes project freeze or works really slow so it is better to set used_nodes to 10 to speed up calculations and comment line random_functions() inside process_node()

qarmin commented 3 years ago

Also sometimes project freeze showing

ERROR: get_supports: Condition "idx == -1" is true.
   At: servers/physics_2d/shape_2d_sw.cpp:737.

inside

#0  0x000000000438721b in BroadPhase2DHashGrid::PosKey::hash (this=0x7fffffffa3a8) at servers/physics_2d/broad_phase_2d_hash_grid.h:139
#1  0x0000000004388059 in BroadPhase2DHashGrid::_cull<true, false> (this=0x7c49090, p_cell=..., p_aabb=..., p_from=..., p_to=..., p_results=0x7ca2548, p_max_results=2048, 
    p_result_indices=0x7ca6548, index=@0x7fffffffa43c: 0) at servers/physics_2d/broad_phase_2d_hash_grid.cpp:419
#2  0x0000000004386625 in BroadPhase2DHashGrid::cull_aabb (this=0x7c49090, p_aabb=..., p_results=0x7ca2548, p_max_results=2048, p_result_indices=0x7ca6548)
    at servers/physics_2d/broad_phase_2d_hash_grid.cpp:587
#3  0x0000000004226f34 in Space2DSW::_cull_aabb_for_body (this=0x7ca2470, p_body=0x7f98710, p_aabb=...) at servers/physics_2d/space_2d_sw.cpp:480
#4  0x00000000042281a2 in Space2DSW::test_body_motion (this=0x7ca2470, p_body=0x7f98710, p_from=..., p_motion=..., p_infinite_inertia=true, p_margin=0.0799999982, r_result=0x7fffffffae50, 
    p_exclude_raycast_shapes=true) at servers/physics_2d/space_2d_sw.cpp:774
#5  0x00000000041f31e0 in Physics2DServerSW::body_test_motion (this=0x7ad67d0, p_body=..., p_from=..., p_motion=..., p_infinite_inertia=true, p_margin=0.0799999982, r_result=0x7fffffffae50, 
    p_exclude_raycast_shapes=true) at servers/physics_2d/physics_2d_server_sw.cpp:1051
#6  0x0000000004202950 in Physics2DServerWrapMT::body_test_motion (this=0x7bd6940, p_body=..., p_from=..., p_motion=..., p_infinite_inertia=true, p_margin=0.0799999982, r_result=0x7fffffffae50, 
    p_exclude_raycast_shapes=true) at servers/physics_2d/physics_2d_server_wrap_mt.h:262
#7  0x0000000003b896f1 in KinematicBody2D::move_and_collide (this=0x7e1b4b0, p_motion=..., p_infinite_inertia=true, r_collision=..., p_exclude_raycast_shapes=true, p_test_only=false)
    at scene/2d/physics_body_2d.cpp:1189
#8  0x0000000003b89b54 in KinematicBody2D::move_and_slide (this=0x7e1b4b0, p_linear_velocity=..., p_up_direction=..., p_stop_on_slope=false, p_max_slides=-2618, p_floor_max_angle=1, 
    p_infinite_inertia=true) at scene/2d/physics_body_2d.cpp:1249
#9  0x0000000003b9e061 in MethodBind6R<Vector2, Vector2 const&, Vector2 const&, bool, int, float, bool>::call (this=0x7893870, p_object=0x7e1b4b0, p_args=0x7fffffffb488, p_arg_count=5, r_error=...)
    at ./core/method_bind_ext.gen.inc:309
#10 0x000000000451fa6a in Object::call (this=0x7e1b4b0, p_method=..., p_args=0x7fffffffb488, p_argcount=5, r_error=...) at core/object.cpp:919
#11 0x00000000045bbf7f in Variant::call_ptr (this=0x7fffffffb3e0, p_method=..., p_args=0x7fffffffb488, p_argcount=5, r_ret=0x0, r_error=...) at core/variant_call.cpp:1149
#12 0x0000000001841d80 in GDScriptFunction::call (this=0x7f232b0, p_instance=0x7f1fc70, p_args=0x7fffffffbe70, p_argcount=0, r_err=..., p_state=0x0) at modules/gdscript/gdscript_function.cpp:1086
#13 0x00000000017e2ed1 in GDScriptInstance::call (this=0x7f1fc70, p_method=..., p_args=0x7fffffffbe70, p_argcount=0, r_error=...) at modules/gdscript/gdscript.cpp:1208
#14 0x000000000451f94f in Object::call (this=0x7e39440, p_method=..., p_args=0x7fffffffbe70, p_argcount=0, r_error=...) at core/object.cpp:898
#15 0x00000000045bbf7f in Variant::call_ptr (this=0x7fffffffc570, p_method=..., p_args=0x7fffffffbe70, p_argcount=0, r_ret=0x0, r_error=...) at core/variant_call.cpp:1149
#16 0x0000000001841d80 in GDScriptFunction::call (this=0x7e90910, p_instance=0x7f1fc70, p_args=0x0, p_argcount=0, r_err=..., p_state=0x0) at modules/gdscript/gdscript_function.cpp:1086
#17 0x00000000017e2ed1 in GDScriptInstance::call (this=0x7f1fc70, p_method=..., p_args=0x0, p_argcount=0, r_error=...) at modules/gdscript/gdscript.cpp:1208
#18 0x000000000451f94f in Object::call (this=0x7e39440, p_method=..., p_args=0x0, p_argcount=0, r_error=...) at core/object.cpp:898
#19 0x00000000045bbf7f in Variant::call_ptr (this=0x7fffffffcf30, p_method=..., p_args=0x0, p_argcount=0, r_ret=0x0, r_error=...) at core/variant_call.cpp:1149
#20 0x0000000001841d80 in GDScriptFunction::call (this=0x7e74090, p_instance=0x7f1fc70, p_args=0x7fffffffd088, p_argcount=1, r_err=..., p_state=0x0) at modules/gdscript/gdscript_function.cpp:1086
#21 0x00000000017e2fb8 in GDScriptInstance::call_multilevel (this=0x7f1fc70, p_method=..., p_args=0x7fffffffd088, p_argcount=1) at modules/gdscript/gdscript.cpp:1224
#22 0x00000000035b04a0 in Node::_notification (this=0x7e39440, p_notification=16) at scene/main/node.cpp:69
#23 0x00000000017a0d78 in Node::_notificationv (this=0x7e39440, p_notification=16, p_reversed=false) at ./scene/main/node.h:46
#24 0x000000000451fbad in Object::notification (this=0x7e39440, p_notification=16, p_reversed=false) at core/object.cpp:929
#25 0x00000000035e83f9 in SceneTree::_notify_group_pause (this=0x7c9dae0, p_group=..., p_notification=16) at scene/main/scene_tree.cpp:993
#26 0x00000000035e5838 in SceneTree::iteration (this=0x7c9dae0, p_time=0.0166666675) at scene/main/scene_tree.cpp:486
#27 0x0000000001747161 in Main::iteration () at main/main.cpp:2100
#28 0x000000000170c920 in OS_X11::run (this=0x7fffffffd3c0) at platform/x11/os_x11.cpp:3641
#29 0x00000000016f9a5b in main (argc=1, argv=0x7fffffffdcb8) at platform/x11/godot_x11.cpp:56