xris1658 / yadaw

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

Vital on Linux crashes or freezes on unloading #4

Open xris1658 opened 1 week ago

xris1658 commented 1 week ago

Vital is a synthesizer by Vital Audio, available in multiple formats including VST3 and CLAP.

Reproduce

You can reproduce this issue with the main app, VST3Test and CLAPTest.

Error message

Signal: SIGSEGV (Segmentation fault)

Process finished with exit code -1

Stack trace

If the plugin crashes, then it's on the plugin thread JUCE Timer, and all of the addresses cannot be accessed.

If the plugin freezes, then we can grab stack traces from the main thread and JUCE Timer thread.

Main thread

Module Name Address
libc.so.6 futex_wait 0x00007ffff62912c0
libc.so.6 __GI___lll_lock_wait 0x00007ffff62912c0
libc.so.6 lll_mutex_lock_optimized 0x00007ffff6298002
libc.so.6 ___pthread_mutex_lock 0x00007ffff6298002
Vital.so Renderer::removeWindowHandle(ApplicationEditor *) 0x00007fffeae03aec
Vital.so PluginEditor::~PluginEditor() 0x00007fffeadfcfc4
Vital.so PluginEditor::~PluginEditor() 0x00007fffeadfd059
Vital.so juce::JuceVST3EditController::JuceVST3Editor::ContentWrapperComponent::~ContentWrapperComponent() 0x00007fffead19db3
Vital.so juce::JuceVST3EditController::JuceVST3Editor::ContentWrapperComponent::~ContentWrapperComponent() 0x00007fffead19df9
Vital.so juce::JuceVST3EditController::JuceVST3Editor::removed() 0x00007fffead1ab0b
Vital.so non-virtual thunk to juce::JuceVST3EditController::JuceVST3Editor::removed() 0x00007fffead1b77a
VST3Test YADAW::Audio::Plugin::VST3PluginGUI::detachWithWindow VST3PluginGUI.cpp:88
VST3Test YADAW::Audio::Plugin::VST3PluginGUI::~VST3PluginGUI VST3PluginGUI.cpp:24
VST3Test YADAW::Audio::Plugin::VST3PluginGUI::~VST3PluginGUI VST3PluginGUI.cpp:32
VST3Test std::default_delete::operator() unique_ptr.h:85
VST3Test std::__uniq_ptr_impl::reset unique_ptr.h:182
VST3Test std::unique_ptr::reset unique_ptr.h:456
VST3Test YADAW::Audio::Plugin::VST3Plugin::uninitializeEditController VST3Plugin.cpp:674
VST3Test YADAW::Audio::Plugin::VST3Plugin::uninitialize VST3Plugin.cpp:320
VST3Test testPlugin main.cpp:413
VST3Test main main.cpp:473
libc.so.6 __libc_start_call_main 0x00007ffff6229d90
libc.so.6 __libc_start_main_impl 0x00007ffff6229e40
VST3Test _start 0x00005555555742d5

JUCE Timer

Module Name Address
libc.so.6 __futex_abstimed_wait_common64 0x00007ffff6291117
libc.so.6 __futex_abstimed_wait_common 0x00007ffff6291117
libc.so.6 __GI___futex_abstimed_wait_cancelable64 0x00007ffff6291117
libc.so.6 __pthread_cond_wait_common 0x00007ffff62942dd
libc.so.6 ___pthread_cond_clockwait64 0x00007ffff62942dd
libc.so.6 ___pthread_cond_clockwait64 0x00007ffff62942dd
Vital.so juce::WaitableEvent::wait(int) const 0x00007fffeac00d89
Vital.so juce::Timer::TimerThread::run() 0x00007fffeac1ab97
Vital.so juce::threadEntryProc(void *) 0x00007fffeac01e14
libc.so.6 start_thread 0x00007ffff6294ac3
libc.so.6 clone3 0x00007ffff6326850

Those function names indicate that a deadlock occurred between JUCE Timer and the main thread.

More details

This issue is introduced after implementing Linux run loops (Steinberg::Linux::IRunLoop in VST3, and clap_host_posix_fd_support in CLAP), which are mainly used for plugin event loops. If I removed those implementations (e.g. by not returning a pointer of VST3RunLoop in VST3Host::queryInterface), then the plugin will not respond to GUI events, but will not crash on unloading.

xris1658 commented 23 hours ago

For now I am still locating the root cause, but I am pretty sure that it's not the problem of VST3RunLoop and EventFileDescriptorSupport's impls. I have reimplemented EventFileDescriptorSupport with Linux poll API, and even replaced VST3RunLoop with IRunLoop impl from Ardour, only to get the same issue I had met with my old impls.

Making things worse, Dr. Memory have just crashed before the plugin GUI is shown. Since this issue is only on Linux, it might be a good idea to use Valgrind.