godotengine / godot

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

Godot crashes when renaming an Audio file #27800

Open jesperkondrup opened 5 years ago

jesperkondrup commented 5 years ago

Godot 3.1 stable, Windows 10.

If you attach an Audio file to an AudioStreamPlayer in a scene and then afterwards try to rename the audio file in the the FileSystem then Godot will crash. It does not matter if the scene is open or closed. In our case the audio file was an ogg file.

We also tried testing this with a sprite node but this works as intended, so it might only be a problem with audio files.

To reproduce simply make:

Edit: I did some more testing and I found out that this does not happen every time but almost every time. It happens both when the scene is open and closed but it seems to be happen more when it's open.

Edit 2: We also tried on Windows 8.1 but we were only able to reproduce the crash one time after a lot of renaming, so it might be worse on Windows 10 (but it's hard to say).

Keetz commented 5 years ago

Godot 3.1-stable Linux Mint 18.3 Sylvia 64-bit

Godot doesn't crash for me, but I get the following error when renaming from within the FileSystem dock:

ERROR: set_path: Another resource is loaded from path: res://Ancient_Society425.ogg (possible cyclic resource inclusion)
   At: core/resource.cpp:79.

Even though I get the error, the resource path on the AudioStreamPlayer still updates to the new renamed file as it should.

If I rename the file in the system explorer it re-imports the file and therefore renaming it, but the AudioStreamPlayer doesn't detect this change and keeps the old path, but no errors are given in this case.

qarmin commented 5 years ago

Backtrace from Ubuntu 18.04.2

[1] /lib/x86_64-linux-gnu/libc.so.6(+0x3ef20) [0x7f99f8db8f20] (??:0)
[2] /usr/lib/x86_64-linux-gnu/libstdc++.so.6(__dynamic_cast+0x20) [0x7f99f97b2360] (??:0)
[3] Node* Object::cast_to<Node>(Object*) (/home/rafal/Pulpit/godot/./core/object.h:588 (discriminator 1))
[4] Variant::operator Node*() const (/home/rafal/Pulpit/godot/core/variant.cpp:1763)
[5] VariantObjectClassChecker<Node*>::check(Variant const&) (/home/rafal/Pulpit/godot/./core/method_bind.h:143)
[6] MethodBind2<Dictionary, Node*>::call(Object*, Variant const**, int, Variant::CallError&) (/home/rafal/Pulpit/godot/./core/method_bind.gen.inc:1425 (discriminator 3))
[7] Object::call(StringName const&, Variant const**, int, Variant::CallError&) (/home/rafal/Pulpit/godot/core/object.cpp:942 (discriminator 1))
[8] MessageQueue::_call_function(Object*, StringName const&, Variant const*, int, bool) (/home/rafal/Pulpit/godot/core/message_queue.cpp:256)
[9] MessageQueue::flush() (/home/rafal/Pulpit/godot/core/message_queue.cpp:305)
[10] SceneTree::iteration(float) (/home/rafal/Pulpit/godot/scene/main/scene_tree.cpp:477 (discriminator 2))
[11] Main::iteration() (/home/rafal/Pulpit/godot/main/main.cpp:1862)
[12] OS_X11::run() (/home/rafal/Pulpit/godot/platform/x11/os_x11.cpp:3006)
[13] /usr/bin/godot(main+0xdc) [0x12f1073] (/home/rafal/Pulpit/godot/platform/x11/godot_x11.cpp:56)
[14] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7) [0x7f99f8d9bb97] (??:0)
[15] /usr/bin/godot(_start+0x2a) [0x12f0eda] (??:?)
KoBeWi commented 4 years ago

Might be related to #26964 but I never managed to get backtrace for that crash, so not sure.

qarmin commented 3 years ago

Still happens with 3.2.4.beta.custom_build. adfc646f8

MRP - FFFF.zip

Looks that main thread removed data used by audio thread:

==61193==ERROR: AddressSanitizer: heap-use-after-free on address 0x7f0db945ec3c at pc 0x000004416210 bp 0x7f0dd8bcb350 sp 0x7f0dd8bcb340
READ of size 1 at 0x7f0db945ec3c thread T10
    #0 0x441620f in get8 thirdparty/misc/stb_vorbis.c:1326
    #1 0x4419b8c in get8_packet_raw thirdparty/misc/stb_vorbis.c:1557
    #2 0x4419ff3 in get_bits thirdparty/misc/stb_vorbis.c:1598
    #3 0x44364e5 in vorbis_decode_initial thirdparty/misc/stb_vorbis.c:3120
    #4 0x4440259 in vorbis_decode_packet thirdparty/misc/stb_vorbis.c:3436
    #5 0x4463352 in stb_vorbis_get_frame_float thirdparty/misc/stb_vorbis.c:5013
    #6 0x446aa4f in stb_vorbis_get_samples_float_interleaved thirdparty/misc/stb_vorbis.c:5426
    #7 0x320b718 in AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame*, int) modules/stb_vorbis/audio_stream_ogg_vorbis.cpp:48
    #8 0xdbfcb90 in AudioStreamPlaybackResampled::mix(AudioFrame*, float, int) servers/audio/audio_stream.cpp:85
    #9 0x7706de0 in EditorAudioStreamPreviewPlugin::generate(Ref<Resource> const&, Vector2 const&) const editor/plugins/editor_preview_plugins.cpp:643
    #10 0x62a12da in EditorResourcePreview::_generate_preview(Ref<ImageTexture>&, Ref<ImageTexture>&, EditorResourcePreview::QueueItem const&, String const&) editor/editor_resource_preview.cpp:165
    #11 0x62a7470 in EditorResourcePreview::_thread() editor/editor_resource_preview.cpp:253
    #12 0x629e751 in EditorResourcePreview::_thread_func(void*) editor/editor_resource_preview.cpp:107
    #13 0x4f0856f in ThreadPosix::thread_callback(void*) drivers/unix/thread_posix.cpp:74
    #14 0x7f0df4406608 in start_thread /build/glibc-ZN95T4/glibc-2.31/nptl/pthread_create.c:477
    #15 0x7f0df366d292 in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x122292)

0x7f0db945ec3c is located 230460 bytes inside of 2349013-byte region [0x7f0db9426800,0x7f0db9663fd5)
freed by thread T0 here:
    #0 0x7f0df4a371b7 in __interceptor_free (/lib/x86_64-linux-gnu/libasan.so.6+0xb01b7)
    #1 0xed69c52 in Memory::free_static(void*, bool) core/os/memory.cpp:178
    #2 0xccbf713 in AudioServer::audio_data_free(void*) servers/audio_server.cpp:1164
    #3 0x3211235 in AudioStreamOGGVorbis::clear_data() modules/stb_vorbis/audio_stream_ogg_vorbis.cpp:161
    #4 0x321264a in AudioStreamOGGVorbis::set_data(PoolVector<unsigned char> const&) modules/stb_vorbis/audio_stream_ogg_vorbis.cpp:213
    #5 0x31220b4 in MethodBind1<PoolVector<unsigned char> const&>::call(Object*, Variant const**, int, Variant::CallError&) core/method_bind.gen.inc:775
    #6 0xe5c389c in ClassDB::set_property(Object*, StringName const&, Variant const&, bool*) core/class_db.cpp:1049
    #7 0xe81f312 in Object::set(StringName const&, Variant const&, bool*) core/object.cpp:423
    #8 0xe93d91d in Resource::reload_from_file() core/resource.cpp:149
    #9 0x5dd428f in EditorNode::_resources_reimported(Vector<String> const&) editor/editor_node.cpp:781
    #10 0x5a695ab in MethodBind1<Vector<String> const&>::call(Object*, Variant const**, int, Variant::CallError&) core/method_bind.gen.inc:775
    #11 0xe82e8b1 in Object::call(StringName const&, Variant const**, int, Variant::CallError&) core/object.cpp:919
    #12 0xe838712 in Object::emit_signal(StringName const&, Variant const**, int) core/object.cpp:1246
    #13 0xe83a748 in Object::emit_signal(StringName const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&) core/object.cpp:1303
    #14 0x5b96a38 in EditorFileSystem::reimport_files(Vector<String> const&) editor/editor_file_system.cpp:2019
    #15 0x5b5254e in EditorFileSystem::_update_scan_actions() editor/editor_file_system.cpp:589
    #16 0x5b6c30f in EditorFileSystem::_notification(int) editor/editor_file_system.cpp:1174
    #17 0x5ba5977 in EditorFileSystem::_notificationv(int, bool) editor/editor_file_system.h:108
    #18 0xe82ed4b in Object::notification(int, bool) core/object.cpp:929
    #19 0x95f99e5 in SceneTree::_notify_group_pause(StringName const&, int) scene/main/scene_tree.cpp:985
    #20 0x95ea2a7 in SceneTree::idle(float) scene/main/scene_tree.cpp:525
    #21 0x15456fa in Main::iteration() main/main.cpp:2108
    #22 0x1437eb0 in OS_X11::run() platform/x11/os_x11.cpp:3608
    #23 0x13a5b56 in main platform/x11/godot_x11.cpp:56
    #24 0x7f0df35720b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)

previously allocated by thread T0 here:
    #0 0x7f0df4a37517 in malloc (/lib/x86_64-linux-gnu/libasan.so.6+0xb0517)
    #1 0xed68d45 in Memory::alloc_static(unsigned long, bool) core/os/memory.cpp:82
    #2 0xccbd111 in AudioServer::audio_data_alloc(unsigned int, unsigned char const*) servers/audio_server.cpp:1139
    #3 0x3212906 in AudioStreamOGGVorbis::set_data(PoolVector<unsigned char> const&) modules/stb_vorbis/audio_stream_ogg_vorbis.cpp:215
    #4 0x31220b4 in MethodBind1<PoolVector<unsigned char> const&>::call(Object*, Variant const**, int, Variant::CallError&) core/method_bind.gen.inc:775
    #5 0xe5c389c in ClassDB::set_property(Object*, StringName const&, Variant const&, bool*) core/class_db.cpp:1049
    #6 0xe81f312 in Object::set(StringName const&, Variant const&, bool*) core/object.cpp:423
    #7 0xf1b85f4 in ResourceInteractiveLoaderBinary::poll() core/io/resource_format_binary.cpp:745
    #8 0xf224ae2 in ResourceFormatLoader::load(String const&, String const&, Error*) core/io/resource_loader.cpp:197
    #9 0xf22a859 in ResourceLoader::_load(String const&, String const&, String const&, bool, Error*) core/io/resource_loader.cpp:270
    #10 0xf20f474 in ResourceFormatImporter::load(String const&, String const&, Error*) core/io/resource_importer.cpp:133
    #11 0xf22a859 in ResourceLoader::_load(String const&, String const&, String const&, bool, Error*) core/io/resource_loader.cpp:270
    #12 0xf22d849 in ResourceLoader::load(String const&, String const&, bool, Error*) core/io/resource_loader.cpp:402
    #13 0xc3cffb3 in ResourceInteractiveLoaderText::poll() scene/resources/resource_format_text.cpp:433
    #14 0xf224ae2 in ResourceFormatLoader::load(String const&, String const&, Error*) core/io/resource_loader.cpp:197
    #15 0xf22a859 in ResourceLoader::_load(String const&, String const&, String const&, bool, Error*) core/io/resource_loader.cpp:270
    #16 0xf22d849 in ResourceLoader::load(String const&, String const&, bool, Error*) core/io/resource_loader.cpp:402
    #17 0x5e635a8 in EditorNode::load_scene(String const&, bool, bool, bool, bool) editor/editor_node.cpp:3481
    #18 0x5ed0e3c in EditorNode::reload_scene(String const&) editor/editor_node.cpp:5362
    #19 0x64e4dfa in FileSystemDock::_update_dependencies_after_move(Map<String, String, Comparator<String>, DefaultAllocator> const&) const editor/filesystem_dock.cpp:1146
    #20 0x64eebce in FileSystemDock::_rename_operation_confirm() editor/filesystem_dock.cpp:1339
    #21 0x1760003 in MethodBind0::call(Object*, Variant const**, int, Variant::CallError&) core/method_bind.gen.inc:59
    #22 0xe82e8b1 in Object::call(StringName const&, Variant const**, int, Variant::CallError&) core/object.cpp:919
    #23 0xe838712 in Object::emit_signal(StringName const&, Variant const**, int) core/object.cpp:1246
    #24 0xe83a748 in Object::emit_signal(StringName const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&) core/object.cpp:1303
    #25 0x9a62fb8 in AcceptDialog::_ok_pressed() scene/gui/dialogs.cpp:410
    #26 0x1760003 in MethodBind0::call(Object*, Variant const**, int, Variant::CallError&) core/method_bind.gen.inc:59
    #27 0xe82e8b1 in Object::call(StringName const&, Variant const**, int, Variant::CallError&) core/object.cpp:919
    #28 0xe838712 in Object::emit_signal(StringName const&, Variant const**, int) core/object.cpp:1246
    #29 0xe83a748 in Object::emit_signal(StringName const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&) core/object.cpp:1303

Thread T10 created by T0 here:
    #0 0x7f0df49dea95 in __interceptor_pthread_create (/lib/x86_64-linux-gnu/libasan.so.6+0x57a95)
    #1 0x4f08a64 in ThreadPosix::create_func_posix(void (*)(void*), void*, Thread::Settings const&) drivers/unix/thread_posix.cpp:90
    #2 0xed7f9ef in Thread::create(void (*)(void*), void*, Thread::Settings const&) core/os/thread.cpp:51
    #3 0x62b2278 in EditorResourcePreview::start() editor/editor_resource_preview.cpp:460
    #4 0x5dd4d3a in EditorNode::_sources_changed(bool) editor/editor_node.cpp:799
    #5 0x1eb4f40 in MethodBind1<bool>::call(Object*, Variant const**, int, Variant::CallError&) core/method_bind.gen.inc:775
    #6 0xe82e8b1 in Object::call(StringName const&, Variant const**, int, Variant::CallError&) core/object.cpp:919
    #7 0xe838712 in Object::emit_signal(StringName const&, Variant const**, int) core/object.cpp:1246
    #8 0xe83a748 in Object::emit_signal(StringName const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&) core/object.cpp:1303
    #9 0x5b6cad7 in EditorFileSystem::_notification(int) editor/editor_file_system.cpp:1176
    #10 0x5ba5977 in EditorFileSystem::_notificationv(int, bool) editor/editor_file_system.h:108
    #11 0xe82ed4b in Object::notification(int, bool) core/object.cpp:929
    #12 0x95f99e5 in SceneTree::_notify_group_pause(StringName const&, int) scene/main/scene_tree.cpp:985
    #13 0x95ea2a7 in SceneTree::idle(float) scene/main/scene_tree.cpp:525
    #14 0x15456fa in Main::iteration() main/main.cpp:2108
    #15 0x1437eb0 in OS_X11::run() platform/x11/os_x11.cpp:3608
    #16 0x13a5b56 in main platform/x11/godot_x11.cpp:56
    #17 0x7f0df35720b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)

SUMMARY: AddressSanitizer: heap-use-after-free thirdparty/misc/stb_vorbis.c:1326 in get8
ellenhp commented 2 years ago

I think this is fixed in 4.0. I can't reproduce it, anyway.

Nartynka commented 2 years ago

When moving audio file attached to AudioStreamPlayer to new folder the same happens Windows 11 v3.4.4.stable.official.419e713a2 .ogg file

Calinou commented 2 years ago

Godot 3.x uses stb_vorbis to import Ogg Vorbis files, which unfortunately causes crashes with poorly formatted Ogg Vorbis files. Re-encoding those files using an external tool may help (at the cost of quality).

Godot 4.0 uses libogg and libvorbis instead, but this is part of compatibility-breaking changes, so it can't be backported to 3.x.