xris1658 / yadaw

Yet Another Digital Audio Workstation
GNU General Public License v3.0
18 stars 1 forks source link

Rare potential crash on starting audio engine with AudioGraph backend #3

Closed xris1658 closed 3 months ago

xris1658 commented 7 months ago

Description / Reproduce

On rare circumstances, starting the audio engine with AudioGraph backend (which is the only backend YADAW uses on Windows) will crash the program.

Log / Stack trace

Though the actual crash is rare, we can locate this problem on every startup with Dr. Memory. The following log is from result.txt generated after one session:

Error #1: UNADDRESSABLE ACCESS beyond heap bounds: reading 0x000001cb9ec9b240-0x000001cb9ec9b244 4 byte(s)
# 0 replace_memmove                                                            [D:\a\drmemory\drmemory\drmemory\replace.c:757]
# 1 YADAW::Audio::Backend::processInputs                                       [C:\Users\xris1658\Project\YADAW\src\audio\backend\AudioGraphBusConfiguration.cpp:134]
# 2 std::_Iterator_base12::_Adopt                                              [C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\xmemory:1287]
# 3 std::_Vector_iterator<>::_Unwrapped                                        [C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\vector:341]
# 4 ```YADAW::Controller::AudioEngine::process'::`2'::<lambda_1>::operator()'::`2'::<lambda_1>::operator()'::`2'::<lambda_1>::operator() [C:\Users\xris1658\Project\YADAW\src\controller\AudioEngineController.cpp:130]
# 5 std::vector<>::begin                                                       [C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\vector:1804]
# 6 std::for_each<>                                                            [C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\algorithm:284]
# 7 ``YADAW::Controller::AudioEngine::process'::`2'::<lambda_1>::operator()'::`2'::<lambda_1>::operator() [C:\Users\xris1658\Project\YADAW\src\controller\AudioEngineController.cpp:127]
# 8 std::_For_each_ivdep<>                                                     [C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\execution:1165]
# 9 std::_Static_partitioned_for_each2<>::_Process_chunk                       [C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\execution:1182]
#10 std::_Run_available_chunked_work<>                                         [C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\execution:222]
#11 std::_Run_chunked_parallel_work<>                                          [C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\execution:232]
#12 std::for_each<>                                                            [C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\execution:1212]
#13 `YADAW::Controller::AudioEngine::process'::`2'::<lambda_1>::operator()     [C:\Users\xris1658\Project\YADAW\src\controller\AudioEngineController.cpp:124]
#14 std::for_each<>                                                            [C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\algorithm:284]
#15 YADAW::Controller::AudioEngine::process                                    [C:\Users\xris1658\Project\YADAW\src\controller\AudioEngineController.cpp:120]
#16 YADAW::Controller::audioGraphCallback                                      [C:\Users\xris1658\Project\YADAW\src\controller\AudioGraphBackendController.cpp:147]
#17 winrt::impl::delegate<>::Invoke                                            [C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt\winrt\Windows.Foundation.h:895]
#18 Windows.Media.Audio.dll!DllGetClassObject                                 +0x3a12c  (0x00007ffdb5fcc7fd <Windows.Media.Audio.dll+0x4c7fd>)
#19 Windows.Media.Audio.dll!?                                                 +0x0      (0x00007ffdb5f82ad5 <Windows.Media.Audio.dll+0x2ad5>)
Note: @0:00:20.197 in thread 7268
Note: refers to 0 byte(s) beyond last valid byte in prior malloc
Note: prev lower malloc:  0x000001cb9ec9b240-0x000001cb9ec9b240
Note: allocated here:
Note: # 0 replace_malloc                                 [D:\a\drmemory\drmemory\common\alloc_replace.c:2580]
Note: # 1 MFPlat.DLL!MFCreatePropertiesFromMediaType    +0x1e9e   (0x00007ffe1edbb62f <MFPlat.DLL+0x11b62f>)
Note: # 2 MFPlat.DLL!MFCreatePropertiesFromMediaType    +0x2219   (0x00007ffe1edbb9aa <MFPlat.DLL+0x11b9aa>)
Note: # 3 MFPlat.DLL!MFCreatePropertiesFromMediaType    +0x2219   (0x00007ffe1edbb9aa <MFPlat.DLL+0x11b9aa>)
Note: # 4 MFPlat.DLL!MFCreatePropertiesFromMediaType    +0x2edb   (0x00007ffe1edbc66c <MFPlat.DLL+0x11c66c>)
Note: # 5 MFPlat.DLL!MFCreatePropertiesFromMediaType    +0x2edb   (0x00007ffe1edbc66c <MFPlat.DLL+0x11c66c>)
Note: # 6 MFPlat.DLL!MFCreatePropertiesFromMediaType    +0xaa1    (0x00007ffe1edba232 <MFPlat.DLL+0x11a232>)
Note: # 7 MFPlat.DLL!MFCreatePropertiesFromMediaType    +0x2dce   (0x00007ffe1edbc55f <MFPlat.DLL+0x11c55f>)
Note: # 8 WinTypes.dll!RoCreateNonAgilePropertySet      +0x5d15   (0x00007ffe21340b46 <WinTypes.dll+0x20b46>)
Note: # 9 MFPlat.DLL!MFCreateVideoMediaType             +0xd8     (0x00007ffe1ecb1359 <MFPlat.DLL+0x11359>)
Note: #10 MFPlat.DLL!MFAverageTimePerFrameToFrameRate   +0x516    (0x00007ffe1ecdb237 <MFPlat.DLL+0x3b237>)
Note: #11 MFPlat.DLL!MFCreateMemoryBuffer               +0x55     (0x00007ffe1ecc29c6 <MFPlat.DLL+0x229c6>)
Note: instruction: mov    (%rcx) -> %ecx

Note that "previous lower malloc" in MFCreatePropertiesFromMediaType allocated 0 bytes, which is weird giving that it seems allocating audio buffers we'd like to read in the callback.