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>
-- v2: faudio: Make sure at least some wavebank notifications get allocated (ASan).
From: Bernhard Übelacker bernhardu@mailbox.org
This appears in upstream discussion: https://github.com/FNA-XNA/FAudio/pull/393 --- libs/faudio/src/FACT.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libs/faudio/src/FACT.c b/libs/faudio/src/FACT.c index a2f407853e5..e1006cb63fa 100644 --- a/libs/faudio/src/FACT.c +++ b/libs/faudio/src/FACT.c @@ -525,7 +525,7 @@ uint32_t FACTAudioEngine_CreateInMemoryWaveBank( { if (pEngine->wavebank_notification_count == pEngine->wavebank_notifications_capacity) { - pEngine->wavebank_notifications_capacity *= 2; + pEngine->wavebank_notifications_capacity = FAudio_max(pEngine->wavebank_notifications_capacity * 2, 8); pEngine->wavebank_notifications = pEngine->pRealloc(pEngine->wavebank_notifications, pEngine->wavebank_notifications_capacity * sizeof(FACTNotification)); } @@ -570,7 +570,7 @@ uint32_t FACTAudioEngine_CreateStreamingWaveBank( { if (pEngine->wavebank_notification_count == pEngine->wavebank_notifications_capacity) { - pEngine->wavebank_notifications_capacity *= 2; + pEngine->wavebank_notifications_capacity = FAudio_max(pEngine->wavebank_notifications_capacity * 2, 8); pEngine->wavebank_notifications = pEngine->pRealloc(pEngine->wavebank_notifications, pEngine->wavebank_notifications_capacity * sizeof(FACTNotification)); }
v2: - Use `FAudio_max` instead of a separate `if` line.
This version is from the discussion in [this upstream issue](https://github.com/FNA-XNA/FAudio/pull/393#pullrequestreview-3494300971).