Popup Menu Crash in Plugin

Today I had an one-time-only crash, I am not able to reproduce it now, crash happened while I opening a popup on a Plugin-GUI:
Host uses the same code-base as the juce-Plugin Host, latest tip develop:

I think this could be interesting, here the stack trace

Unhandled exception thrown: read access violation.
modal->**** was 0xFFFFFFFFFFFFFEBF.

>	Plugin.vst3!juce::Component::ComponentHelpers::modalWouldBlockComponent(const juce::Component & maybeBlocked, juce::Component * modal) Line 477	C++
 	Plugin.vst3!juce::Component::ComponentHelpers::sendMouseEventToComponentsThatAreBlockedByModal<void (__cdecl juce::Component::*)(juce::MouseInputSource,juce::Point<float>,juce::Time)>(juce::Component & modal, void(juce::Component::*)(juce::MouseInputSource, juce::Point<float>, juce::Time) && function) Line 488	C++
 	Plugin.vst3!juce::Component::exitModalState(int returnValue) Line 1776	C++
 	Plugin.vst3!juce::PopupMenu::HelperClasses::MenuWindow::hide(const juce::PopupMenu::Item * item, bool makeInvisible) Line 494	C++
 	Plugin.vst3!juce::PopupMenu::HelperClasses::MouseSourceState::highlightItemUnderMouse(juce::Point<int> globalMousePos, juce::Point<int> localMousePos, const unsigned int timeNow) Line 1427	C++
 	Plugin.vst3!juce::PopupMenu::HelperClasses::MouseSourceState::handleMousePosition(juce::Point<int> globalMousePos) Line 1343	C++
 	Plugin.vst3!juce::PopupMenu::HelperClasses::MouseSourceState::timerCallback() Line 1312	C++
 	Plugin.vst3!juce::Timer::TimerThread::callTimers() Line 119	C++
 	Plugin.vst3!juce::Timer::TimerThread::CallTimersMessage::messageCallback() Line 181	C++
 	Plugin.vst3!juce::InternalMessageQueue::dispatchMessage(juce::MessageManager::MessageBase * message) Line 202	C++
 	Plugin.vst3!juce::InternalMessageQueue::dispatchMessages() Line 240	C++
 	Plugin.vst3!juce::InternalMessageQueue::messageWndProc(HWND__ * h, unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 163	C++
 	[External Code]	
 	Host.exe!juce::InternalMessageQueue::dispatchNextMessage(bool returnIfNoPendingMessages) Line 149	C++
 	Host.exe!juce::dispatchNextMessageOnSystemQueue(bool returnIfNoPendingMessages) Line 266	C++
 	Host.exe!juce::MessageManager::runDispatchLoop() Line 107	C++
 	Host.exe!juce::JUCEApplicationBase::main() Line 266	C++
 	Host.exe!WinMain(HINSTANCE__ * __formal, HINSTANCE__ * __formal, char * __formal, int __formal) Line 523	C++

Did you use showMenuAsync() to open the popup?

yes

Thanks for reporting. From the stack trace, my guess is that calling ModalComponentManager::endModal may destroy the component before sendMouseEventToComponentsThatAreBlockedByModal is called, and this function ends up dereferencing a dangling pointer. I’ll put a solution together.

1 Like

I think this patch should resolve the issue:

Please try updating and let us know if you encounter any further issues.

1 Like