godotengine / godotengine/godot
Crash on close project when AudioStreamInteractive is extended from GDScript and sound is still playing
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
Reproducible in: 4.4.1.stable (official), 4.5.1.stable (official), 4.5.1.stable.custom_build (scons debug_symbols=yes)
### System information
Windows 11 (22631) – Vulkan
### Issue description
If create a GDScript that extends AudioStreamInteractive with custom class_name, assign it to an AudioStreamPlayer and close the project while the stream is playing,after 3-5 attempts crash:
```
================================================================
CrashHandlerException: Program crashed
Engine version: Godot Engine v4.5.1.stable.custom_build
Dumping the backtrace. Please include this when reporting the bug on: https://github.com/godotengine/godot/issues
[0] mtx_do_lock (D:\a\_work\1\s\src\vctools\crt\github\stl\src\mutex.cpp:79)
[1] mtx_do_lock (D:\a\_work\1\s\src\vctools\crt\github\stl\src\mutex.cpp:79)
[2] GDScriptInstance::~GDScriptInstance (G:\delete\godot-4.5.1-stable\modules\gdscript\gdscript.cpp:2177)
[3] GDScriptInstance::`scalar deleting destructor'
[4] Object::~Object (G:\delete\godot-4.5.1-stable\core\object\object.cpp:2266)
[5] AudioStreamInteractive::`scalar deleting destructor'
[6] AudioStreamPlaybackInteractive::`scalar deleting destructor'
[7] std::_Func_impl_no_alloc<`AudioServer::_delete_stream_playback_list_node'::`2'::,void,AudioServer::AudioStreamPlaybackListNode *>::_Do_call (h:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\functional:880)
[8] SafeList::maybe_cleanup (G:\delete\godot-4.5.1-stable\core\templates\safe_list.h:223)
[9] AudioServer::~AudioServer (G:\delete\godot-4.5.1-stable\servers\audio_server.cpp:2056)
[10] AudioServer::`scalar deleting destructor'
[11] Main::cleanup (G:\delete\godot-4.5.1-stable\main\main.cpp:5052)
[12] widechar_main (G:\delete\godot-4.5.1-stable\platform\windows\godot_windows.cpp:102)
[13] _main (G:\delete\godot-4.5.1-stable\platform\windows\godot_windows.cpp:124)
[14] main (G:\delete\godot-4.5.1-stable\platform\windows\godot_windows.cpp:136)
[15] __scrt_common_main_seh (D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
[16]
-- END OF C++ BACKTRACE --
================================================================
```
### Steps to reproduce
1. Add AudioStreamPlayer to the scene.
2. Create script my_interact.gd:
extends AudioStreamInteractive
class_name MyInteract
3. In the AudioStreamPlayer create new MyInteract resource → add any .ogg\.wav\.mp3 to attached resource
4. Autoplay = true.
Variant 1 : crash project :
5. Run scene (F6), close window while sound is still playing.
6. Repeat item 5 3-5 times and get CrashHandlerException in console
i test it on my second pc with win 10 and editor crashes too (win 11 only project) and on win 10 i got popup window:

original text:
Инструкция по адресу "adress" обратилась к памяти по адресу "adress" память не может быть written.
english:
The instruction at "adress" referenced memory at "adress". The memory could not be written.
Variant 2 : crash editor :
5. Playing = true.
6. Ctrl+Shift+Q (Quit to Project List)
7. Repeat 3-5 times and get editor crash with same as variant 1 CrashHandlerException
### Minimal reproduction project (MRP)
[112480.zip](https://github.com/user-attachments/files/23415567/112480.zip)
Contributor guide
Research direction
Start by running the attached 112480.zip reproduction and inspect the shutdown backtrace through modules/gdscript/gdscript.cpp, core/object/object.cpp, servers/audio_server.cpp, and core/templates/safe_list.h. Reproduce both project and editor shutdown variants repeatedly; done means closing while the AudioStreamInteractive stream plays no longer crashes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100