[PATCH 0/1] MR9688: faudio: Make sure at least one wavebank notification gets allocated (ASan).
With the update of faudio in d4479c27 I received below ASan report. It looks like the `wavebank_notifications_capacity` stays at zero, therefore a zero byte allocation is requested. CC: @zfigura - [ASan gitlab CI 32-bit report](https://gitlab.winehq.org/bernhardu/wine/-/jobs/215013#L5541) - [ASan gitlab CI 64-bit report](https://gitlab.winehq.org/bernhardu/wine/-/jobs/215014#L5831) - [Test patttern page, showing daily gitlab runs of xactengine3_7:xact3 failing](https://test.winehq.org/data/patterns.html#xactengine3_7:xact3) <details> <summary>ASan report with full symbols</summary> ``` ================================================================= ==312==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7ea2933e0690 at pc 0x6ffffdd0ec1f bp 0x7ffffe1ff280 sp 0x7ffffe1ff2c8 WRITE of size 1 at 0x7ea2933e0690 thread T0 #0 0x6ffffdd0ec1e in FACTAudioEngine_CreateStreamingWaveBank .../wine/libs/faudio/src/FACT.c:578 #1 0x6ffffdd03464 in IXACT3EngineImpl_CreateStreamingWaveBank .../wine/dlls/xactengine3_7/xact_dll.c:1280 #2 0x000140002c95 in test_notifications .../wine/dlls/xactengine3_7/tests/xact3.c:392 #3 0x0001400011bb in func_xact3 .../wine/dlls/xactengine3_7/tests/xact3.c:1576 #4 0x00014001af82 in run_test .../wine/include/wine/test.h:780 #5 0x00014001a9fc in main .../wine/include/wine/test.h #6 0x00014001cb1a in mainCRTStartup .../wine/dlls/msvcrt/crt_main.c:62 #7 0x6fffffc67a64 in BaseThreadInitThunk (C:\windows\system32\kernel32.dll+0x178027a64) #8 0x6fffffde0876 in RtlUserThreadStart (C:\windows\system32\ntdll.dll+0x170050876) 0x7ea2933e0690 is located 0 bytes inside of 1-byte region [0x7ea2933e0690,0x7ea2933e0691) allocated by thread T0 here: #0 0x6ffffe8bde13 in HeapAlloc /home/runner/work/llvm-mingw/llvm-mingw/llvm-project/compiler-rt\lib/asan/asan_malloc_win.cpp:230:3 #1 0x6ffffd02dca9 in allocator_Realloc .../wine/dlls/combase/malloc.c:211 #2 0x6ffffd02d3ba in IMalloc_Realloc .../obj\include\objidlbase.h:1336 #3 0x6ffffd02d370 in CoTaskMemRealloc .../wine/dlls/combase/malloc.c:399 #4 0x6ffffdd010e1 in XACT_Internal_Realloc .../wine/dlls/xactengine3_7/xact_dll.c:1661 #5 0x6ffffdd0ea8f in FACTAudioEngine_CreateStreamingWaveBank .../wine/libs/faudio/src/FACT.c:574 #6 0x6ffffdd03464 in IXACT3EngineImpl_CreateStreamingWaveBank .../wine/dlls/xactengine3_7/xact_dll.c:1280 #7 0x000140002c95 in test_notifications .../wine/dlls/xactengine3_7/tests/xact3.c:392 #8 0x0001400011bb in func_xact3 .../wine/dlls/xactengine3_7/tests/xact3.c:1576 #9 0x00014001af82 in run_test .../wine/include/wine/test.h:780 #10 0x00014001a9fc in main .../wine/include/wine/test.h #11 0x00014001cb1a in mainCRTStartup .../wine/dlls/msvcrt/crt_main.c:62 #12 0x6fffffc67a64 in BaseThreadInitThunk (C:\windows\system32\kernel32.dll+0x178027a64) #13 0x6fffffde0876 in RtlUserThreadStart (C:\windows\system32\ntdll.dll+0x170050876) SUMMARY: AddressSanitizer: heap-buffer-overflow .../wine/libs/faudio/src/FACT.c:578 in FACTAudioEngine_CreateStreamingWaveBank ``` </details> -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9688
From: Bernhard Übelacker <bernhardu(a)mailbox.org> --- libs/faudio/src/FACT.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/faudio/src/FACT.c b/libs/faudio/src/FACT.c index a2f407853e5..f5ada0293a5 100644 --- a/libs/faudio/src/FACT.c +++ b/libs/faudio/src/FACT.c @@ -525,6 +525,7 @@ uint32_t FACTAudioEngine_CreateInMemoryWaveBank( { if (pEngine->wavebank_notification_count == pEngine->wavebank_notifications_capacity) { + if (!pEngine->wavebank_notifications_capacity) pEngine->wavebank_notifications_capacity = 1; pEngine->wavebank_notifications_capacity *= 2; pEngine->wavebank_notifications = pEngine->pRealloc(pEngine->wavebank_notifications, pEngine->wavebank_notifications_capacity * sizeof(FACTNotification)); @@ -570,6 +571,7 @@ uint32_t FACTAudioEngine_CreateStreamingWaveBank( { if (pEngine->wavebank_notification_count == pEngine->wavebank_notifications_capacity) { + if (!pEngine->wavebank_notifications_capacity) pEngine->wavebank_notifications_capacity = 1; pEngine->wavebank_notifications_capacity *= 2; pEngine->wavebank_notifications = pEngine->pRealloc(pEngine->wavebank_notifications, pEngine->wavebank_notifications_capacity * sizeof(FACTNotification)); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9688
participants (1)
-
Bernhard Übelacker