Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Executing AudioStreamPlayer.set_stream function leaks memory in Godot #84398

Closed
qarmin opened this issue Nov 3, 2023 · 1 comment
Closed
Labels

Comments

@qarmin
Copy link
Contributor

qarmin commented Nov 3, 2023

Godot version

4.2.beta.custom_build. b733901

System information

Ubuntu 22.04 CI

Issue description

When executing (this code was automatically minimized, so it is possible, that an even more "minimal" project can be created)

extends Node
func _process(delta):
	var temp_variable60676 = AudioStreamPlayer.new()
	add_child(temp_variable60676)
	temp_variable60676.set_stream(AudioStreamMicrophone.new())
	temp_variable60676.seek(-76.8111363053322)
	temp_variable60676.play(-26.7877578735352)
	temp_variable60676.set_bus(StringName(""))
	temp_variable60676.queue_free()

Godot leaks memory:

Godot Engine v4.2.beta.custom_build.b733901e9 - https://godotengine.org
Vulkan API 1.2.0 - Forward+ - Using Vulkan Device #0: Unknown - SwiftShader Device (LLVM 10.0.0)
modules/gdscript/gdscript_vm.cpp:698:13: runtime error: store to misaligned address 0x616000362224 for type '<unknown> *', which requires 8 byte alignment
0x616000362224: note: pointer points here
  01 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  0a 00 00 00 02 00 00 00  09 00 00 00 17 00 00 00
              ^ 
modules/gdscript/gdscript_vm.cpp:705:42: runtime error: load of misaligned address 0x616000362224 for type '<unknown> *', which requires 8 byte alignment
0x616000362224: note: pointer points here
  01 00 00 00 fc ce b7 bb  f9 55 00 00 00 00 00 00  0a 00 00 00 02 00 00 00  09 00 00 00 17 00 00 00
              ^ 
######################## Ending test ########################
WARNING: You must enable the project setting "audio/driver/enable_input" to use audio capture.
     at: start (servers/audio/audio_stream.cpp:364)
=================================================================
==10751==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 168 byte(s) in 1 object(s) allocated from:
    #0 0x7fdd91eb61e7 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:99
    #1 0x7fdd7fc670d6  (<unknown module>)
Direct leak of 72 byte(s) in 1 object(s) allocated from:
    #0 0x7fdd91eb4887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x55f9ba531821 in Memory::alloc_static(unsigned long, bool) core/os/memory.cpp:75
    #2 0x55f9a606f05d in DefaultAllocator::alloc(unsigned long) (/home/runner/work/Qarminer/Qarminer/godot.linuxbsd.editor.dev.x86_64.san+0x2f4a405d)
    #3 0x55f9ba531755 in operator new(unsigned long, void* (*)(unsigned long)) core/os/memory.cpp:44
    #4 0x55f9b5bc2ed8 in SafeList<AudioServer::AudioStreamPlaybackBusDetails*, DefaultAllocator>::insert(AudioServer::AudioStreamPlaybackBusDetails*) core/templates/safe_list.h:126
    #5 0x55f9b5b934af in AudioServer::update() servers/audio_server.cpp:1459
    #6 0x55f9a6373223 in Main::iteration() main/main.cpp:3643
    #7 0x55f9a608e211 in OS_LinuxBSD::run() platform/linuxbsd/os_linuxbsd.cpp:933
    #8 0x55f9a606cae7 in main platform/linuxbsd/godot_linuxbsd.cpp:74
    #9 0x7fdd91229d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
Indirect leak of 248 byte(s) in 1 object(s) allocated from:
    #0 0x7fdd91eb61e7 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:99
    #1 0x55f9b5b8827f in AudioServer::start_playback_stream(Ref<AudioStreamPlayback>, HashMap<StringName, Vector<AudioFrame>, HashMapHasherDefault, HashMapComparatorDefault<StringName>, DefaultTypedAllocator<HashMapElement<StringName, Vector<AudioFrame> > > >, float, float, float, float) servers/audio_server.cpp:1137
    #2 0x55f9b5b87c6d in AudioServer::start_playback_stream(Ref<AudioStreamPlayback>, StringName, Vector<AudioFrame>, float, float) servers/audio_server.cpp:1127
    #3 0x55f9b390c31d in AudioStreamPlayer::play(float) scene/audio/audio_stream_player.cpp:147
    #4 0x55f9aecb8ebe in void call_with_variant_args_helper<__UnexistingClass, float, 0ul>(__UnexistingClass*, void (__UnexistingClass::*)(float), Variant const**, Callable::CallError&, IndexSequence<0ul>) core/variant/binder_common.h:303
    #5 0x55f9aecb6c81 in void call_with_variant_args_dv<__UnexistingClass, float>(__UnexistingClass*, void (__UnexistingClass::*)(float), Variant const**, int, Callable::CallError&, Vector<Variant> const&) core/variant/binder_common.h:450
    #6 0x55f9aecb27f4 in MethodBindT<float>::call(Object*, Variant const**, int, Callable::CallError&) const core/object/method_bind.h:335
    #7 0x55f9bbeb022e in Object::callp(StringName const&, Variant const**, int, Callable::CallError&) core/object/object.cpp:774
    #8 0x55f9bb260fce in Variant::callp(StringName const&, Variant const**, int, Variant&, Callable::CallError&) core/variant/variant_call.cpp:1168
    #9 0x55f9a6d41761 in GDScriptFunction::call(GDScriptInstance*, Variant const**, int, Callable::CallError&, GDScriptFunction::CallState*) modules/gdscript/gdscript_vm.cpp:1704
    #10 0x55f9a662e82e in GDScriptInstance::callp(StringName const&, Variant const**, int, Callable::CallError&) modules/gdscript/gdscript.cpp:1896
    #11 0x55f9afe41000 in bool Node::_gdvirtual__process_call<false>(double) scene/main/node.h:318
    #12 0x55f9afd7f494 in Node::_notification(int) scene/main/node.cpp:57
    #13 0x55f9a7e47777 in Node::_notificationv(int, bool) scene/main/node.h:49
    #14 0x55f9bbeb1db8 in Object::notification(int, bool) core/object/object.cpp:836
    #15 0x55f9aff49950 in SceneTree::_process_group(SceneTree::ProcessGroup*, bool) scene/main/scene_tree.cpp:951
    #16 0x55f9aff4cbf4 in SceneTree::_process(bool) scene/main/scene_tree.cpp:1028
    #17 0x55f9aff3acea in SceneTree::process(double) scene/main/scene_tree.cpp:508
    #18 0x55f9a6371a0f in Main::iteration() main/main.cpp:3614
    #19 0x55f9a608e211 in OS_LinuxBSD::run() platform/linuxbsd/os_linuxbsd.cpp:933
    #20 0x55f9a606cae7 in main platform/linuxbsd/godot_linuxbsd.cpp:74
    #21 0x7fdd91229d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
SUMMARY: AddressSanitizer: 488 byte(s) leaked in 3 allocation(s).

This example was found by Godot fuzzer - Qarminer, so it is quite unlikelly that this code could be used in real project, but still this should be handled gracefully.

Memory leaks or asan backtraces are visible when using Godot build with sanitizers support - https://github.com/qarmin/GodotBuilds/actions (linux -> linux-editor-sanitizers)

Steps to reproduce

Above

Minimal reproduction project

Above

@MJacred
Copy link
Contributor

MJacred commented Aug 17, 2024

This seems to be a duplicate of your issue #67589.

While the other title says set_current, the reproduction steps mention set_stream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants