godotengine / godot

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

[4.0 Beta 8] AnimationPlayers not playing animation, editor crashes when opening animation editor. #69848

Open gelvinp opened 1 year ago

gelvinp commented 1 year ago

Godot version

4.0 beta 8 official

System information

Windows 10

Issue description

I noticed when running my game with beta 8, that some (not all) of my animations were not playing. The nodes in question would stay put for the duration of the animation, and then snap to the correct position at the end. Trying to debug this, I opened the animation editor in Godot which immediately crashed.

Behavior in beta 7: https://user-images.githubusercontent.com/61520531/206849470-d94b0933-6662-403a-a06c-a8e6e7407c49.mp4 https://user-images.githubusercontent.com/61520531/206840038-dcbb4db9-7de9-4050-828e-baf56f2343e5.mp4

Behavior in beta 8: https://user-images.githubusercontent.com/61520531/206849475-33d81af5-6534-4bd3-a7b8-3b25f6ebe544.mp4 https://user-images.githubusercontent.com/61520531/206840042-21a9816f-c663-47fc-84f8-f5b86eb0dea0.mp4

The crash happens with no log messages to the console, even in verbose mode. Having seen similar behavior before I then ran the beta 8 editor with ASAN enabled, and got this when clicking on the AnimationPlayer node:

=================================================================
==20608==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x00c0b43fca10 at pc 0x7ff70ff66607 bp 0x00c0b43fbec0 sp 0x00c0b43fbec8
READ of size 8 at 0x00c0b43fca10 thread T0
    #0 0x7ff70ff66606 in Ref<class Texture2D>::ref(class Ref<class Texture2D> const &) C:\Users\thePG\Documents\Godot\Entombed\build\godot\core\object\ref_counted.h:61
    #1 0x7ff711642d6e in Ref<class Texture2D>::Ref<class Texture2D>(class Ref<class Texture2D> const &) C:\Users\thePG\Documents\Godot\Entombed\build\godot\core\object\ref_counted.h:177
    #2 0x7ff7140f6a25 in AnimationTrackEdit::_notification(int) C:\Users\thePG\Documents\Godot\Entombed\build\godot\editor\animation_track_editor.cpp:2161
    #3 0x7ff7141d738f in AnimationTrackEdit::_notificationv(int, bool) C:\Users\thePG\Documents\Godot\Entombed\build\godot\editor\animation_track_editor.h:135
    #4 0x7ff71a317b1f in Object::notification(int, bool) C:\Users\thePG\Documents\Godot\Entombed\build\godot\core\object\object.cpp:790
    #5 0x7ff715ce29c0 in CanvasItem::_redraw_callback(void) C:\Users\thePG\Documents\Godot\Entombed\build\godot\scene\main\canvas_item.cpp:135
    #6 0x7ff713319b81 in call_with_variant_args_helper<class CanvasItem>(class CanvasItem *, void (__cdecl CanvasItem::*)(void), class Variant const **, struct Callable::CallError &, struct IndexSequence<>) C:\Users\thePG\Documents\Godot\Entombed\build\godot\core\variant\binder_common.h:262
    #7 0x7ff713310ab8 in call_with_variant_args<class CanvasItem>(class CanvasItem *, void (__cdecl CanvasItem::*)(void), class Variant const **, int, struct Callable::CallError &) C:\Users\thePG\Documents\Godot\Entombed\build\godot\core\variant\binder_common.h:376
    #8 0x7ff713353bc9 in CallableCustomMethodPointer<class CanvasItem>::call(class Variant const **, int, class Variant &, struct Callable::CallError &) const C:\Users\thePG\Documents\Godot\Entombed\build\godot\core\object\callable_method_pointer.h:104
    #9 0x7ff71a60b7ff in Callable::callp(class Variant const **, int, class Variant &, struct Callable::CallError &) const C:\Users\thePG\Documents\Godot\Entombed\build\godot\core\variant\callable.cpp:50
    #10 0x7ff71a8c9fca in MessageQueue::_call_function(class Callable const &, class Variant const *, int, bool) C:\Users\thePG\Documents\Godot\Entombed\build\godot\core\object\message_queue.cpp:229
    #11 0x7ff71a8cef12 in MessageQueue::flush(void) C:\Users\thePG\Documents\Godot\Entombed\build\godot\core\object\message_queue.cpp:275
    #12 0x7ff7152d3ca6 in SceneTree::physics_process(double) C:\Users\thePG\Documents\Godot\Entombed\build\godot\scene\main\scene_tree.cpp:430
    #13 0x7ff71000a724 in Main::iteration(void) C:\Users\thePG\Documents\Godot\Entombed\build\godot\main\main.cpp:3162
    #14 0x7ff70fedefa7 in OS_Windows::run(void) C:\Users\thePG\Documents\Godot\Entombed\build\godot\platform\windows\os_windows.cpp:1274
    #15 0x7ff70feb84e0 in widechar_main(int, wchar_t **) C:\Users\thePG\Documents\Godot\Entombed\build\godot\platform\windows\godot_windows.cpp:179
    #16 0x7ff70feb87b6 in _main(void) C:\Users\thePG\Documents\Godot\Entombed\build\godot\platform\windows\godot_windows.cpp:203
    #17 0x7ff70feb8831 in main C:\Users\thePG\Documents\Godot\Entombed\build\godot\platform\windows\godot_windows.cpp:217
    #18 0x7ff70feb763c in WinMain C:\Users\thePG\Documents\Godot\Entombed\build\godot\platform\windows\godot_windows.cpp:230
    #19 0x7ff71c215999 in invoke_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:102
    #20 0x7ff71c215999 in __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
    #21 0x7ffe036074b3  (C:\Windows\System32\KERNEL32.DLL+0x1800174b3)
    #22 0x7ffe037826a0  (C:\Windows\SYSTEM32\ntdll.dll+0x1800526a0)

Address 0x00c0b43fca10 is located in stack of thread T0 at offset 2560 in frame
    #0 0x7ff7140f11ef in AnimationTrackEdit::_notification(int) C:\Users\thePG\Documents\Godot\Entombed\build\godot\editor\animation_track_editor.cpp:1982

  This frame has 195 object(s):
    [32, 72) 'interp_icon'
    [48, 56) 'compiler temporary'
    [64, 65) 'compiler temporary'
    [80, 81) 'compiler temporary'
    [96, 104) 'compiler temporary'
    [112, 128) 'compiler temporary'
    [128, 144) 'compiler temporary'
    [144, 152) 'compiler temporary'
    [160, 168) 'compiler temporary'
    [176, 184) 'compiler temporary'
    [192, 200) 'compiler temporary'
    [208, 224) 'compiler temporary'
    [224, 240) 'compiler temporary'
    [240, 248) 'compiler temporary'
    [256, 264) 'compiler temporary'
    [272, 280) 'compiler temporary'
    [288, 296) 'compiler temporary'
    [304, 305) 'compiler temporary'
    [320, 321) 'compiler temporary'
    [336, 352) 'accent'
    [352, 368) 'compiler temporary'
    [368, 376) 'compiler temporary'
    [384, 392) 'compiler temporary'
    [400, 408) 'compiler temporary'
    [416, 424) 'compiler temporary'
    [432, 433) 'compiler temporary'
    [448, 449) 'compiler temporary'
    [464, 472) 'compiler temporary'
    [480, 481) 'compiler temporary'
    [496, 497) 'compiler temporary'
    [512, 520) 'font'
    [528, 529) 'compiler temporary'
    [544, 545) 'compiler temporary'
    [560, 561) 'compiler temporary'
    [576, 577) 'compiler temporary'
    [592, 608) 'color'
    [608, 609) 'compiler temporary'
    [624, 625) 'compiler temporary'
    [640, 656) 'linecolor'
    [656, 657) 'compiler temporary'
    [672, 673) 'compiler temporary'
    [688, 704) 'dc'
    [704, 712) 'check'
    [720, 721) 'compiler temporary'
    [736, 737) 'compiler temporary'
    [752, 760) 'compiler temporary'
    [768, 769) 'compiler temporary'
    [784, 785) 'compiler temporary'
    [800, 808) 'compiler temporary'
    [816, 832) 'compiler temporary'
    [832, 840) 'compiler temporary'
    [848, 856) 'compiler temporary'
    [864, 872) 'compiler temporary'
    [880, 896) 'compiler temporary'
    [896, 904) 'key_type_icon'
    [912, 928) 'compiler temporary'
    [928, 936) 'compiler temporary'
    [944, 952) 'compiler temporary'
    [960, 968) 'anim_path'
    [976, 984) 'text'
    [992, 1008) 'text_color'
    [1008, 1009) 'compiler temporary'
    [1024, 1025) 'compiler temporary'
    [1040, 1056) 'compiler temporary'
    [1056, 1064) 'compiler temporary'
    [1072, 1080) 'compiler temporary'
    [1088, 1096) 'compiler temporary'
    [1104, 1112) 'compiler temporary'
    [1120, 1128) 'compiler temporary'
    [1136, 1144) 'compiler temporary'
    [1152, 1160) 'compiler temporary'
    [1168, 1176) 'compiler temporary'
    [1184, 1192) 'compiler temporary'
    [1200, 1208) 'compiler temporary'
    [1216, 1224) 'compiler temporary'
    [1232, 1240) 'compiler temporary'
    [1248, 1256) 'icon'
    [1264, 1280) 'compiler temporary'
    [1280, 1288) 'compiler temporary'
    [1296, 1304) 'compiler temporary'
    [1312, 1320) 'compiler temporary'
    [1328, 1336) 'compiler temporary'
    [1344, 1352) 'compiler temporary'
    [1360, 1368) 'compiler temporary'
    [1376, 1384) 'compiler temporary'
    [1392, 1400) 'compiler temporary'
    [1408, 1416) 'compiler temporary'
    [1424, 1432) 'compiler temporary'
    [1440, 1448) 'compiler temporary'
    [1456, 1464) 'compiler temporary'
    [1472, 1488) 'compiler temporary'
    [1488, 1496) 'compiler temporary'
    [1504, 1512) 'string_pos'
    [1520, 1528) 'compiler temporary'
    [1536, 1544) 'compiler temporary'
    [1552, 1560) 'compiler temporary'
    [1568, 1576) 'compiler temporary'
    [1584, 1592) 'compiler temporary'
    [1600, 1608) 'compiler temporary'
    [1616, 1624) 'compiler temporary'
    [1632, 1640) 'compiler temporary'
    [1648, 1656) 'compiler temporary'
    [1664, 1665) 'compiler temporary'
    [1680, 1681) 'compiler temporary'
    [1696, 1712) 'wrap_icon'
    [1712, 1713) 'compiler temporary'
    [1728, 1729) 'compiler temporary'
    [1744, 1745) 'compiler temporary'
    [1760, 1761) 'compiler temporary'
    [1776, 1777) 'compiler temporary'
    [1792, 1793) 'compiler temporary'
    [1808, 1809) 'compiler temporary'
    [1824, 1825) 'compiler temporary'
    [1840, 1841) 'compiler temporary'
    [1856, 1857) 'compiler temporary'
    [1872, 1873) 'compiler temporary'
    [1888, 1889) 'compiler temporary'
    [1904, 1905) 'compiler temporary'
    [1920, 1921) 'compiler temporary'
    [1936, 1960) 'cont_icon'
    [1952, 1953) 'compiler temporary'
    [1968, 1969) 'compiler temporary'
    [1984, 1985) 'compiler temporary'
    [2000, 2001) 'compiler temporary'
    [2016, 2024) 'compiler temporary'
    [2032, 2033) 'compiler temporary'
    [2048, 2049) 'compiler temporary'
    [2064, 2072) 'down_icon'
    [2080, 2088) 'compiler temporary'
    [2096, 2104) 'compiler temporary'
    [2112, 2120) 'compiler temporary'
    [2128, 2136) 'update_icon'
    [2144, 2152) 'compiler temporary'
    [2160, 2168) 'compiler temporary'
    [2176, 2192) 'compiler temporary'
    [2192, 2200) 'compiler temporary'
    [2208, 2224) 'compiler temporary'
    [2224, 2232) 'compiler temporary'
    [2240, 2248) 'compiler temporary'
    [2256, 2257) 'compiler temporary'
    [2272, 2273) 'compiler temporary'
    [2288, 2296) 'bezier_icon'
    [2304, 2320) 'compiler temporary'
    [2320, 2336) 'compiler temporary'
    [2336, 2352) 'compiler temporary'
    [2352, 2360) 'compiler temporary'
    [2368, 2376) 'compiler temporary'
    [2384, 2392) 'compiler temporary'
    [2400, 2408) 'icon'
    [2416, 2424) 'compiler temporary'
    [2432, 2440) 'compiler temporary'
    [2448, 2464) 'compiler temporary'
    [2464, 2472) 'compiler temporary'
    [2480, 2496) 'compiler temporary'
    [2496, 2504) 'compiler temporary'
    [2512, 2520) 'compiler temporary'
    [2528, 2544) 'compiler temporary'
    [2544, 2552) 'compiler temporary'
    [2560, 2568) 'compiler temporary' <== Memory access at offset 2560 is inside this variable
    [2576, 2584) 'compiler temporary'
    [2592, 2600) 'icon'
    [2608, 2616) 'compiler temporary'
    [2624, 2632) 'compiler temporary'
    [2640, 2656) 'compiler temporary'
    [2656, 2664) 'compiler temporary'
    [2672, 2688) 'compiler temporary'
    [2688, 2696) 'compiler temporary'
    [2704, 2712) 'compiler temporary'
    [2720, 2736) 'compiler temporary'
    [2736, 2744) 'compiler temporary'
    [2752, 2760) 'compiler temporary'
    [2768, 2776) 'compiler temporary'
    [2784, 2785) 'compiler temporary'
    [2800, 2801) 'compiler temporary'
    [2816, 2817) 'compiler temporary'
    [2832, 2840) 'icon'
    [2848, 2856) 'compiler temporary'
    [2864, 2872) 'compiler temporary'
    [2880, 2888) 'compiler temporary'
    [2896, 2912) 'compiler temporary'
    [2912, 2920) 'compiler temporary'
    [2928, 2936) 'compiler temporary'
    [2944, 2952) 'compiler temporary'
    [2960, 2968) 'compiler temporary'
    [2976, 2984) 'compiler temporary'
    [2992, 3000) 'compiler temporary'
    [3008, 3009) 'compiler temporary'
    [3024, 3025) 'compiler temporary'
    [3040, 3056) 'drop_color'
    [3056, 3064) 'compiler temporary'
    [3072, 3080) 'compiler temporary'
    [3088, 3096) 'compiler temporary'
    [3104, 3112) 'compiler temporary'
    [3120, 3128) 'compiler temporary'
    [3136, 3144) 'compiler temporary'
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
      (longjmp, SEH and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow C:\Users\thePG\Documents\Godot\Entombed\build\godot\core\object\ref_counted.h:61 in Ref<class Texture2D>::ref(class Ref<class Texture2D> const &)
Shadow bytes around the buggy address:
  0x027ed65ff8f0: f2 f8 f2 f8 f2 f8 f2 f8 f2 f8 f2 f8 f2 f8 f8 f2
  0x027ed65ff900: f2 f2 f2 f8 f2 f8 f2 f8 f2 f8 f2 f8 f2 f8 f2 f8
  0x027ed65ff910: f2 f8 f2 f8 f2 f8 f2 f8 f2 f8 f2 f8 f2 00 00 f2
  0x027ed65ff920: f2 f2 f2 f8 f2 f8 f2 f8 f2 f8 f2 f8 f2 f8 f2 f8
  0x027ed65ff930: f2 f8 f2 f8 f2 f8 f2 f8 f2 f8 f2 f8 f2 f8 f2 00
=>0x027ed65ff940: 00 00[f2]f2 f2 f2 f8 f2 f8 f2 f8 f2 f8 f2 f8 f2
  0x027ed65ff950: f8 f2 f8 f2 00 f2 f8 f2 f8 f2 f8 f2 00 f2 00 f2
  0x027ed65ff960: 00 f2 f8 f8 f2 f2 f2 f2 f8 f2 f8 f8 f2 f2 f2 f2
  0x027ed65ff970: f8 f2 f8 f2 f8 f2 f8 f2 f8 f2 f8 f8 f2 f2 f2 f2
  0x027ed65ff980: f8 f8 f2 f2 f2 f2 f8 f8 f2 f2 f2 f2 f8 f2 f8 f2
  0x027ed65ff990: f8 f2 f8 f2 f8 f2 f8 f2 f8 f8 f2 f2 f2 f2 f8 f2
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==20608==ABORTING

I've git bisected between the commits for beta 7 and beta 8, and found 83135aa122dcd1a260830767b119b33984364838 to be the commit that introduced the regression. However, this is based on the animations playing in game, as I was unable to reproduce the crash when building the editor myself. Even building the same commit that the official beta 8 build was based off on only crashed when building with ASAN, whereas the official build (as seen in the video above) does reliably crash every time.

Steps to reproduce

I'm not sure what specifically is causing the crash, I've only noticed this behavior with one of the animation players in my game, thus I am not sure how to reproduce.

Minimal reproduction project

Here's a project that just has a copy of the scene with everything besides the offending AnimationPlayer removed. If you open this project in the official build, open Bridge.tscn, and double click the animation player to edit it, it should crash. AnimationCrash.zip

TokageItLab commented 1 year ago

Beta8 animations and Beta7 animations can be converted (there is no converter yet), but are not directly compatible.

This is a known problem as commented in https://github.com/godotengine/godot/pull/69627#issuecomment-1339108241, caused by animations that use CaptureMode or TriggerMode. If you find an "update_mode" entry in the tscn or tres file, rewrite it as 3->2, 2->1, to solve the problem as temporary workaround.

e.g.

"times": PackedFloat32Array(1),
"transitions": PackedFloat32Array(1),
"update": 3,
"values": [Vector3(0, 1.5708, 0)]

"times": PackedFloat32Array(1),
"transitions": PackedFloat32Array(1),
"update": 2,
"values": [Vector3(0, 1.5708, 0)]
clayjohn commented 1 year ago

I think I can reproduce this in the TPS demo. I got the crash in RC 1 and then I reproduced with debug symbols in 929ee61170ec4d431d6d2cfeddccdec2a59a11b7

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.0.rc.custom_build (929ee61170ec4d431d6d2cfeddccdec2a59a11b7)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7fcb45242520] (??:0)
[2] RefCounted::reference() (/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/atomic_base.h:488)
[3] Ref<Texture2D>::ref(Ref<Texture2D> const&) (/home/clayjohn/dev/godot/./core/object/ref_counted.h:71)
[4] Ref<Texture2D>::Ref(Ref<Texture2D> const&) (/home/clayjohn/dev/godot/./core/object/ref_counted.h:178)
[5] AnimationTrackEdit::_notification(int) (/home/clayjohn/dev/godot/editor/animation_track_editor.cpp:1980)
[6] AnimationTrackEdit::_notificationv(int, bool) (/home/clayjohn/dev/godot/./editor/animation_track_editor.h:206)
[7] Object::notification(int, bool) (/home/clayjohn/dev/godot/core/object/object.cpp:790)
[8] CanvasItem::_redraw_callback() (/home/clayjohn/dev/godot/scene/main/canvas_item.cpp:135)
[9] void call_with_variant_args_helper<CanvasItem>(CanvasItem*, void (CanvasItem::*)(), Variant const**, Callable::CallError&, IndexSequence<>) (/home/clayjohn/dev/godot/./core/variant/binder_common.h:298)
[10] void call_with_variant_args<CanvasItem>(CanvasItem*, void (CanvasItem::*)(), Variant const**, int, Callable::CallError&) (/home/clayjohn/dev/godot/./core/variant/binder_common.h:408)
[11] CallableCustomMethodPointer<CanvasItem>::call(Variant const**, int, Variant&, Callable::CallError&) const (/home/clayjohn/dev/godot/./core/object/callable_method_pointer.h:105)
[12] Callable::callp(Variant const**, int, Variant&, Callable::CallError&) const (/home/clayjohn/dev/godot/core/variant/callable.cpp:51)
[13] MessageQueue::_call_function(Callable const&, Variant const*, int, bool) (/home/clayjohn/dev/godot/core/object/message_queue.cpp:229)
[14] MessageQueue::flush() (/home/clayjohn/dev/godot/core/object/message_queue.cpp:277)
[15] SceneTree::physics_process(double) (/home/clayjohn/dev/godot/scene/main/scene_tree.cpp:430)
[16] Main::iteration() (/home/clayjohn/dev/godot/main/main.cpp:3093)
[17] OS_LinuxBSD::run() (/home/clayjohn/dev/godot/platform/linuxbsd/os_linuxbsd.cpp:880)
[18] /home/clayjohn/dev/godot/bin/godot.linuxbsd.editor.dev.x86_64.llvm(main+0x1fe) [0x557a0187d82e] (/home/clayjohn/dev/godot/platform/linuxbsd/godot_linuxbsd.cpp:73)
[19] /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7fcb45229d90] (??:0)
[20] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7fcb45229e40] (??:0)
[21] /home/clayjohn/dev/godot/bin/godot.linuxbsd.editor.dev.x86_64.llvm(_start+0x25) [0x557a0187d565] (??:?)
-- END OF BACKTRACE --
================================================================
TokageItLab commented 1 year ago

I have no idea how to convert that option since we can't tell the difference between the past enum and the new one. I suppose we could clamp it in a setter, but that would cause problems if another enum is added in the future.

I think it is possible if we get an explicit project version and clamp it, but that should not be done in the setter, we need to add the functionality to the converter. Is there any way to do this (e.g. detecting older than beta.7 -> newer beta.8)?

clayjohn commented 1 year ago

update

I can confirm your workaround in the previous comment works. In this case I reduced "capture" from 3 to 2.

I don't know enough about the converter to know if it can rename enums inside of resources like that.

@qarmin Do you have any ideas? I guess the core of this issue is opening an Animation player containing an Animation track with an "update" mode set to an invalid enum