AuburnSounds / Dplug

Audio plugin framework. VST2/VST3/AU/AAX/LV2 for Linux/macOS/Windows.
https://dplug.org/
Other
479 stars 32 forks source link

MergedAlloc encouraging errors (was buffer override effect when going from 64 samples to 256 samples in REAPER) #807

Closed p0nce closed 8 months ago

p0nce commented 9 months ago

User sent a video that illustrates the problem. Very probably not a Dplug problem (99% confidence) but how to avoid that kind of bug could be a documentation problem. EDIT: Lens had similar issue at release

p0nce commented 9 months ago

Reproduced, VST2 or VST3, in REAPER v6.82 + Windows with Steinberg UR22 ASIO driver.

To reproduce:

p0nce commented 9 months ago

Reproduce with process:

$ process -i dance.wav "Inner Pitch 1.0.dll" -buffer 64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,512,512,512,512,512,512 -o output.wav

gives in the 64 to 256 transition: image

p0nce commented 9 months ago

This was a buffer not resized from 64 to 128 samples, Intel Inspector find the bug approximately. What would help is a warning from MergedAlloc in debug mode, that sentinel bytes have changed. For example it could use malloc instead of one merged allocation.

The problem is that MergedAlloc and aligned allocation can hide more bugs, because no protection fault happen. Or, simply using slices instead of pointers work too.

p0nce commented 8 months ago

Added detection of most buffer overflows when using MergedAllocation. Each buffer has 32-byte of 0xCC after.