Closed AnClark closed 1 year ago
Problem still exists on recent versions of my project. Here's backtrace:
(gdb) bt
#0 0x00007ff8bce965a4 in DISTRHO::MinatonPlugin::_processAudioFrame (this=0x13ad9390, audio_l=0x13bb3130,
audio_r=0x1442b1d0, frame_index=1972) at D:/Sources/minaton/plugin/MinatonProcess.cpp:113
#1 0x00007ff8bce95558 in DISTRHO::MinatonPlugin::run (this=0x13ad9390, inputs=0xcf9c740, outputs=0xcf9c730,
frames=2048, midiEvents=0x31fbea0, midiEventCount=0) at D:/Sources/minaton/plugin/MinatonPlugin.cpp:154
#2 0x00007ff8bcfafad5 in DISTRHO::PluginExporter::run (this=0x31fbe30, inputs=0xcf9c740, outputs=0xcf9c730,
frames=2048, midiEvents=0x31fbea0, midiEventCount=0)
at D:/Sources/minaton/dpf/distrho/src/DistrhoPluginInternal.hpp:964
#3 0x00007ff8bcfaae22 in DISTRHO::PluginVst3::process (this=0x31f4de0, data=0xcf9c900)
at D:/Sources/minaton/dpf/distrho/src/DistrhoPluginVST3.cpp:1587
#4 0x00007ff8bcfb2e23 in DISTRHO::dpf_audio_processor::process (self=0xa1aab8, data=0xcf9c900)
at D:/Sources/minaton/dpf/distrho/src/DistrhoPluginVST3.cpp:4116
Notice param frame_index
in BT frame #0. It stucks at a strange index number 1972
, but audio buffer size is acutally 2048.
that frame_index
has nothing to do with dpf, I suspect this is a bug in the plugin.
the 1st post leads me to think it is writing out of bounds and getting memory corrupted.
try running it through valgrind, like described in https://github.com/DISTRHO/Cardinal/blob/main/docs/DEBUGGING.md#plugin-usage (but change CARLA_BRIDGE_DUMMY=30
to CARLA_BRIDGE_DUMMY=1
OK, I'll debug further.
The bug is reproducible on REAPER with Wine. When WASAPI buffer size is 2048, problem occurs.
then maybe it is an issue with the plugin with higher buffer sizes, as simple as that. try in linux with such high buffer size too?
Sure. On REAPER for Linux, with PulseAudio & buffer size of 2048, the same problem occurred.
But at this time, the backtrace is much different:
(gdb) bt
#0 0x00007ffff795483c in () at /usr/lib/libc.so.6
#1 0x00007ffff7904668 in raise () at /usr/lib/libc.so.6
#2 0x00007ffff78ec4b8 in abort () at /usr/lib/libc.so.6
#3 0x00007ffff78ed390 in () at /usr/lib/libc.so.6
#4 0x00007ffff795e7b7 in () at /usr/lib/libc.so.6
#5 0x00007ffff7962f0c in malloc () at /usr/lib/libc.so.6
#6 0x00007fffbc2ceaf6 in () at /usr/lib/dri/crocus_dri.so
#7 0x00007fffbc7a6042 in () at /usr/lib/dri/crocus_dri.so
#8 0x00007fffbc2babfd in () at /usr/lib/dri/crocus_dri.so
#9 0x00007ffff7fcf0fe in () at /lib64/ld-linux-x86-64.so.2
#10 0x00007ffff7fcf1ec in () at /lib64/ld-linux-x86-64.so.2
#11 0x00007ffff7fcb56e in _dl_catch_exception () at /lib64/ld-linux-x86-64.so.2
#12 0x00007ffff7fd5ad6 in () at /lib64/ld-linux-x86-64.so.2
#13 0x00007ffff7fcb4e1 in _dl_catch_exception () at /lib64/ld-linux-x86-64.so.2
#14 0x00007ffff7fd5e4c in () at /lib64/ld-linux-x86-64.so.2
#15 0x00007ffff794e9ec in () at /usr/lib/libc.so.6
#16 0x00007ffff7fcb4e1 in _dl_catch_exception () at /lib64/ld-linux-x86-64.so.2
#17 0x00007ffff7fcb603 in () at /lib64/ld-linux-x86-64.so.2
#18 0x00007ffff794e4f7 in () at /usr/lib/libc.so.6
#19 0x00007ffff794eaa1 in dlopen () at /usr/lib/libc.so.6
#20 0x00007ffff549b4de in () at /usr/lib/libGLX_mesa.so.0
#21 0x00007ffff549f1c9 in () at /usr/lib/libGLX_mesa.so.0
#22 0x00007ffff549f4a3 in () at /usr/lib/libGLX_mesa.so.0
--Type <RET> for more, q to quit, c to continue without paging--
#23 0x00007ffff5483109 in () at /usr/lib/libGLX_mesa.so.0
#24 0x00007ffff5483b66 in () at /usr/lib/libGLX_mesa.so.0
#25 0x00007ffff5483c48 in () at /usr/lib/libGLX_mesa.so.0
#26 0x00007ffff71cd1c5 in glXChooseFBConfig () at /usr/lib/libGLX.so.0
#27 0x00007fffbeb51dd5 in DGL::puglX11GlConfigure(DGL::PuglView*) (view=0x12bfe80)
at /home/anclark/Sources/minaton/dpf/dgl/src/pugl-upstream/src/x11_gl.c:72
#28 0x00007fffbeb4d91a in DGL::puglRealize(DGL::PuglViewImpl*) (view=0x12bfe80)
at /home/anclark/Sources/minaton/dpf/dgl/src/pugl-upstream/src/x11.c:393
#29 0x00007fffbeaf97be in DGL::Window::PrivateData::initPost() (this=0x14e6170)
at /home/anclark/Sources/minaton/dpf/dgl/src/WindowPrivateData.cpp:282
#30 0x00007fffbeac7057 in DISTRHO::PluginWindow::PluginWindow(DISTRHO::UI*, DISTRHO::PluginApplication&, unsigned long, unsigned int, unsigned int, double)
(this=0x12c0690, uiPtr=0x12bf960, app=..., parentWindowHandle=0, width=658, height=595, scaleFactor=1)
at /home/anclark/Sources/minaton/dpf/distrho/src/DistrhoUIPrivateData.hpp:201
#31 0x00007fffbeac6802 in DISTRHO::UI::PrivateData::createNextWindow(DISTRHO::UI*, unsigned int, unsigned int, bool)
(ui=0x12bf960, width=658, height=595, adjustForScaleFactor=false)
at /home/anclark/Sources/minaton/dpf/distrho/src/DistrhoUI.cpp:207
#32 0x00007fffbeac68d7 in DISTRHO::UI::UI(unsigned int, unsigned int, bool)
(this=0x12bf960, width=658, height=595, automaticallyScaleAndSetAsMinimumSize=false)
at /home/anclark/Sources/minaton/dpf/distrho/src/DistrhoUI.cpp:221
#33 0x00007fffbeacfe02 in DISTRHO::MinatonUI::MinatonUI() (this=0x12bf960)
at /home/anclark/Sources/minaton/plugin/MinatonUI.cpp:25
#34 0x00007fffbead24b2 in DISTRHO::createUI() ()
at /home/anclark/Sources/minaton/plugin/MinatonUI.cpp:410
--Type <RET> for more, q to quit, c to continue without paging--
#35 0x00007fffbeab3459 in DISTRHO::UIExporter::UIExporter(void*, unsigned long, double, void (*)(void*, unsigned int, bool), void (*)(void*, unsigned int, float), void (*)(void*, char const*, char const*), void (*)(void*, unsigned char, unsigned char, unsigned char), void (*)(void*, unsigned int, unsigned int), bool (*)(void*, char const*), char const*, void*, double, unsigned int, unsigned int, char const*)
(this=0x7fffffff0340, callbacksPtr=0x0, winId=0, sampleRate=48000, editParamCall=0x0, setParamCall=0x0, setStateCall=0x0, sendNoteCall=0x0, setSizeCall=0x0, fileRequestCall=0x0, bundlePath=0x1fd29d0 "/home/anclark/Sources/minaton/build/bin/minaton.clap", dspPtr=0x229a890, scaleFactor=1, bgColor=0, fgColor=4294967295, appClassName=0x0)
at /home/anclark/Sources/minaton/dpf/distrho/src/DistrhoUIInternal.hpp:89
#36 0x00007fffbeab4103 in DISTRHO::ClapUI::getSize(unsigned int*, unsigned int*) const
(this=0x1fbdfe0, width=0x7fffffff03c8, height=0x7fffffff03cc)
at /home/anclark/Sources/minaton/dpf/distrho/src/DistrhoPluginCLAP.cpp:290
#37 0x00007fffbeaaf134 in DISTRHO::clap_gui_get_size(clap_plugin_t const*, uint32_t*, uint32_t*) (plugin=0x1fc1880, width=0x7fffffff03c8, height=0x7fffffff03cc)
at /home/anclark/Sources/minaton/dpf/distrho/src/DistrhoPluginCLAP.cpp:2130
Glibc reports:
corrupted double-linked list
[1] 15010 IOT instruction (core dumped) reaper
I've found out why my plugin crashes with 2048 samples on Windows.
I implement bufferSizeChanged()
so that if buffer size changes, I can reallocate my resampler buffer. But, REAPER does not invoke this method on buffer size changes.
I would be very surprised if that is the case. it is more likely that the buffer size is correct from the start, and thus never needs to change.
You can always call that manually yourself during init, like bufferSizeChanged(getBufferSize())
.
Basically, that is a callback for when things change. If the initial conditions do not change, there is no callback.
and regarding your backtrace. you very much likely have corrupted memory, which invalidates any possible debug afterwards. so you need to prevent memory from being corrupted in the first place, valgrind helps for finding where. also latest clang and gcc have built-in flags for similar things, called ASAN.
Thanks a lot!
Sounds like corrupted memory cause many weird things.
Besides using Valgrind, I also tried to use new
and delete
rather than malloc()
and free()
. Sounds like sometimes Glibc malloc()
may have bugs occasionally.
BTW, I already have a similar function initResampler()
(my own API) called. bufferSizeChanged()
invokes initResampler()
.
Sounds like sometimes Glibc
malloc()
may have bugs occasionally.
it 100% does not. otherwise all software would randomly break. dont assume the external libs to have problems before confirming issues in the local code.
and yes, memory corruption will turn everything into undefined and weird state. you cant assume the program to continue to work in any reliable way if any of its memory gets corrupted, it is too late after that
Thanks! I checked my plugin with Valgrind, and it reported a bunch of memory leak issues.
But now I have a better solution.
The problematic buffers are resampler input buffers. They should have the same size as host buffer, so I used to reallocate it on buffer size changes.
As host buffers has a bunch of common sizes (16 ~ 2048), I really don't need to reallocate my buffers all the time.
Now I prefer fixed size of my own buffer arrays, with enough size (16384). I believe this can work on almost all common hosts and DAWs. It can also deal with the situation of unexpected host buffer (e.g. getBufferSize()
reports 1024, but host calls run()
with frames of 2048).
typically you only reallocate buffers to the size that the host tells you it is going to use, the buffer size hint, but hosts can and will process with less samples sometimes (and more rarely also with more)
a very high buffer size wastes memory, but anyway that is your call and not an issue on DPF side. closing the ticket
OK, I will choose a smaller buffer size.
Many thanks!
Hi, falkTX!
I found that both VST3 and CLAP UI will crash REAPER, if I set audio output driver to WASAPI. But everything worked well with ASIO driver.
Related project: Minaton-XT
Here are backtraces:
CLAP (on create):
VST3 (on destroy):