godotengine / godot

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

`OS.open_midi_inputs` crashes with dummy audio #52821

Open qarmin opened 3 years ago

qarmin commented 3 years ago

Godot version

4.0.dev.custom_build. 22b225395cda3b6f27f6017fa860a1b863f09f9f

System information

Ubuntu 21.04 - Nvidia GTX 970, Gnome shell 3.38 X11

Issue description

Running project with

godot4 --audio-driver Dummy 

crashes with this backtrace

[1] godot4s(+0x3203960e) [0x564aa9e8a60e] (??:0)
[2] /lib/x86_64-linux-gnu/libc.so.6(+0x41040) [0x7f7843149040] (??:0)

when using OS.open_midi_inputs()

Steps to reproduce

Above

Minimal reproduction project

No response

akien-mga commented 3 years ago

gdb backtrace:

(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x0000000003b2e457 in MIDIDriverALSAMidi::open (this=0x7fffffffd360) at drivers/alsamidi/midi_driver_alsamidi.cpp:130
#2  0x0000000006021ada in OS::open_midi_inputs (this=0x7fffffffd200) at core/os/os.cpp:471
#3  0x0000000005f990e6 in core_bind::OS::open_midi_inputs (this=0xaada900) at core/core_bind.cpp:179
#4  0x000000000253dc0e in call_with_ptr_args_helper<__UnexistingClass>(__UnexistingClass*, void (__UnexistingClass::*)(), void const**, IndexSequence<>) (p_instance=0xaada900, 
    p_method=&virtual table offset 160, p_args=0x0) at ./core/variant/binder_common.h:243
#5  0x000000000253d0ec in call_with_ptr_args<__UnexistingClass> (p_instance=0xaada900, p_method=&virtual table offset 160, p_args=0x0) at ./core/variant/binder_common.h:491
#6  0x000000000253ae36 in MethodBindT<>::ptrcall(Object*, void const**, void*) (this=0xab77ff0, p_object=0xaada900, p_args=0x0, r_ret=0x0) at ./core/object/method_bind.h:295
#7  0x000000000362a740 in GDScriptFunction::call (this=0xc03e950, p_instance=0xc9a1860, p_args=0x0, p_argcount=0, r_err=..., p_state=0x0) at modules/gdscript/gdscript_vm.cpp:1868
#8  0x000000000352fbe4 in GDScript::_create_instance (this=0xc9a3d60, p_args=0x0, p_argcount=0, p_owner=0xbe61880, p_is_ref_counted=false, r_error=...) at modules/gdscript/gdscript.cpp:154
#9  0x00000000035310d6 in GDScript::instance_create (this=0xc9a3d60, p_this=0xbe61880) at modules/gdscript/gdscript.cpp:371
#10 0x00000000064960bc in Object::set_script (this=0xbe61880, p_script=...) at core/object/object.cpp:892
#11 0x000000000601e146 in MainLoop::initialize (this=0xbe61880) at core/os/main_loop.cpp:61
#12 0x00000000022fa7db in OS_LinuxBSD::run (this=0x7fffffffd200) at platform/linuxbsd/os_linuxbsd.cpp:330
#13 0x00000000022f6f23 in main (argc=5, argv=0x7fffffffd718) at platform/linuxbsd/godot_linuxbsd.cpp:58
akien-mga commented 1 year ago

Still reproducible in 4.0 RC 3.

The crash happens here:

Error MIDIDriverALSAMidi::open() {
    void **hints;

    if (snd_device_name_hint(-1, "rawmidi", &hints) < 0) {
        return ERR_CANT_OPEN;
    }

Apparently this API is not safe to call when using the dummy driver. There should be a way to error out earlier on if no suitable audio driver is configured.

Calinou commented 2 weeks ago

I can still reproduce this on 4.4.dev https://github.com/godotengine/godot/commit/533c616cb86ff7bb940d58ffbbcc1a3eca0aa33d (Linux).

Backtrace

#0  0x0000000000000000 in ?? ()
#1  0x0000000004c52d7d in MIDIDriverALSAMidi::open (this=0x7fffffffc930) at drivers/alsamidi/midi_driver_alsamidi.cpp:79
#2  0x00000000094b92df in OS::open_midi_inputs (this=0x7fffffffc6d0) at ./core/os/os.cpp:568
#3  0x0000000009380640 in core_bind::OS::open_midi_inputs (this=0xa41e970) at ./core/core_bind.cpp:229
#4  0x00000000031310fc in call_with_validated_variant_args_helper<__UnexistingClass>(__UnexistingClass*, void (__UnexistingClass::*)(), Variant const**, IndexSequence<>) (p_instance=0xa41e970, p_method=&virtual table offset 344, p_args=0x7ffffffc2a60) at ./core/variant/binder_common.h:365
#5  0x000000000312c099 in call_with_validated_object_instance_args<__UnexistingClass> (base=0xa41e970, p_method=&virtual table offset 344, p_args=0x7ffffffc2a60)
    at ./core/variant/binder_common.h:652
#6  0x0000000003123856 in MethodBindT<>::validated_call(Object*, Variant const**, Variant*) const (this=0xa6eff90, p_object=0xa41e970, p_args=0x7ffffffc2a60, 
    r_ret=0x0) at ./core/object/method_bind.h:357
#7  0x000000000352ba32 in GDScriptFunction::call (this=0xba51120, p_instance=0xba2f210, p_args=0x7ffffffdf4b8, p_argcount=0, r_err=..., p_state=0x0)
    at ./modules/gdscript/gdscript_vm.cpp:2296
#8  0x00000000032c9231 in GDScriptInstance::callp (this=0xba2f210, p_method=..., p_args=0x7ffffffdf4b8, p_argcount=0, r_error=...)
    at ./modules/gdscript/gdscript.cpp:2046
#9  0x0000000009e12a32 in Object::callp (this=0xba6e440, p_method=..., p_args=0x7ffffffdf4b8, p_argcount=0, r_error=...) at ./core/object/object.cpp:791
#10 0x00000000098df570 in Variant::callp (this=0x7ffffffdf2f0, p_method=..., p_args=0x7ffffffdf4b8, p_argcount=0, r_ret=..., r_error=...)
    at ./core/variant/variant_call.cpp:1227
#11 0x000000000351f6b7 in GDScriptFunction::call (this=0xba53150, p_instance=0xba2f210, p_args=0x0, p_argcount=0, r_err=..., p_state=0x0)
    at ./modules/gdscript/gdscript_vm.cpp:1890
#12 0x00000000032c9231 in GDScriptInstance::callp (this=0xba2f210, p_method=..., p_args=0x0, p_argcount=0, r_error=...) at ./modules/gdscript/gdscript.cpp:2046
#13 0x00000000067ce3e4 in Node::_gdvirtual__ready_call (this=0xba6e440) at ./scene/main/node.h:384
#14 Node::_notification (this=0xba6e440, p_notification=13) at ./scene/main/node.cpp:224
#15 0x00000000030ed6a7 in Node::_notificationv (this=0xba6e440, p_notification=13, p_reversed=false) at ./scene/main/node.h:50
#16 0x0000000003136b6f in CanvasItem::_notificationv (this=0xba6e440, p_notification=13, p_reversed=false) at ./scene/main/canvas_item.h:45
#17 0x0000000003137447 in Control::_notificationv (this=0xba6e440, p_notification=13, p_reversed=false) at ./scene/gui/control.h:47
#18 0x0000000006cc6087 in Panel::_notificationv (this=0xba6e440, p_notification=13, p_reversed=false) at ./scene/gui/panel.h:37
#19 0x0000000009e130b8 in Object::notification (this=0xba6e440, p_notification=13, p_reversed=false) at ./core/object/object.cpp:875
#20 0x00000000067ceba9 in Node::_propagate_ready (this=0xba6e440) at ./scene/main/node.cpp:279
#21 0x00000000067ceb19 in Node::_propagate_ready (this=0xb99aa60) at ./scene/main/node.cpp:270
#22 0x00000000067e7c19 in Node::_set_tree (this=0xb99aa60, p_tree=0xb99a550) at ./scene/main/node.cpp:3245
#23 0x00000000068a0c15 in SceneTree::initialize (this=0xb99a550) at ./scene/main/scene_tree.cpp:480
#24 0x0000000002dbce73 in OS_LinuxBSD::run (this=0x7fffffffc6d0) at platform/linuxbsd/os_linuxbsd.cpp:950
#25 0x0000000002db2371 in main (argc=2, argv=0x7fffffffcd38) at platform/linuxbsd/godot_linuxbsd.cpp:85