# Crash closing hosted plugin editor

**URL:** <https://forum.juce.com/t/crash-closing-hosted-plugin-editor/18566>\
**Category:** General JUCE discussion\
**Created:** [July 28, 2016, 8:02am UTC](https://forum.juce.com/t/crash-closing-hosted-plugin-editor/18566 "2016-07-28T08:02:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikolaiaudios](https://avatars.discourse-cdn.com/v4/letter/n/77aa72/32.png) [@nikolaiaudios](https://forum.juce.com/u/nikolaiaudios)\
**Post date:** [July 28, 2016, 8:02am UTC](https://forum.juce.com/t/crash-closing-hosted-plugin-editor/18566/1 "2016-07-28T08:02:20Z")

</div>

I have a bug in my host where the app crashes after deleting the plugin editor. This only happens sometimes, on some systems with some plugins.  
Here is a snippet from a crash report.

> Process: MyHost [2365]  
> Path: /Applications/MyHost.app/Contents/MacOS/MyHost  
> Identifier: com.company.MyHost  
> Version: 1.0.0 (1.0.0)  
> Code Type: X86-64 (Native)  
> Parent Process: ??? [1]  
> Responsible: MyHost [2365]  
> User ID: 501

> Date/Time: 2016-07-24 18:35:04.105 +0200  
> OS Version: Mac OS X 10.11.5 (15F34)  
> Report Version: 11  
> Anonymous UUID: 620A8AB0-0A19-B8C3-BEF7-9F42691CF3BC

> Sleep/Wake UUID: EE920A89-3DF6-4A6B-AE76-BBAA1363846B

> Time Awake Since Boot: 70000 seconds  
> Time Since Wake: 11000 seconds

> System Integrity Protection: enabled

> Crashed Thread: 0 Juce Message Thread Dispatch queue: com.apple.main-thread

> Exception Type: EXC\_BAD\_ACCESS (SIGSEGV)  
> Exception Codes: KERN\_INVALID\_ADDRESS at 0x00000000000000d0  
> Exception Note: EXC\_CORPSE\_NOTIFY

> VM Regions Near 0xd0:  
> →   
> \_\_TEXT 0000000102a63000-000000010318d000 [7336K] r-x/rwx SM=COW /Applications/MyHost.app/Contents/MacOS/MyHost

> Global Trace Buffer (reverse chronological seconds):  
> 18446744069.972378 CFNetwork 0x00007fff8c4423cb TCP Conn 0x7fdccac61120 SSL Handshake DONE  
> 18446744070.337456 CFNetwork 0x00007fff8c4422a7 TCP Conn 0x7fdccac61120 starting SSL negotiation  
> 18446744070.337704 CFNetwork 0x00007fff8c440c71 TCP Conn 0x7fdccac61120 complete. fd: 10, err: 0  
> 18446744070.337791 CFNetwork 0x00007fff8c4cf54b TCP Conn 0x7fdccac61120 event 1. err: 0  
> 18446744070.488857 CFNetwork 0x00007fff8c43ff43 TCP Conn 0x7fdccac61120 started  
> 18446744070.522705 CFNetwork 0x00007fff8c403bc6 Creating default cookie storage with process/bundle identifier  
> 18446744070.522705 CFNetwork 0x00007fff8c403b5e Faulting in CFHTTPCookieStorage singleton  
> 18446744070.522705 CFNetwork 0x00007fff8c4039ed Faulting in NSHTTPCookieStorage singleton

> Thread 0 Crashed:: Juce Message Thread Dispatch queue: com.apple.main-thread  
> 0 com.WavesAudio.WaveShell-VST3.9.6.51 0x000000010b9af653 wvWavesV9\_11::PluginViewManager::WCPluginViewManagerMacCocoa::GetThreadWhereViewWasCreated(WSPluginView\*) + 11  
> 1 com.WavesAudio.WaveShell-VST3.9.6.51 0x000000010b9acf1f wvWavesV9\_11::PluginViewManager::ThrowIfNotInCorrectThread(WSPluginView\*) + 13  
> 2 com.WavesAudio.WaveShell-VST3.9.6.51 0x000000010b9b26dd wvWavesV9\_11::PluginViewManager::HidePluginView(WSPluginView\*) + 14  
> 3 com.WavesAudio.WaveShell-VST3.9.6.51 0x000000010b963c37 WCPluginGraphicaGS::DeactivateView() + 73  
> 4 com.WavesAudio.WaveShell-VST3.9.6.51 0x000000010b964fba WCPluginGraphicaGSOpenGL::DeactivateView() + 18  
> 5 com.WavesAudio.WaveShell-VST3.9.6.51 0x000000010b5c7dd5 WCWaveShell\_VST\_GUIEditor::close() + 71  
> 6 com.WavesAudio.WaveShell-VST3.9.6.51 0x000000010b5bffe6 Steinberg::Vst::VSTGUIEditor::removed() + 36  
> 7 com.company.MyHost juce::VST3Classes::VST3PluginWindow::~VST3PluginWindow() (in MyHost) (juce\_VST3PluginFormat.cpp:1407)  
> 8 com.company.MyHost juce::VST3Classes::VST3PluginWindow::~VST3PluginWindow() (in MyHost) (juce\_VST3PluginFormat.cpp:1405)  
> 9 com.company.MyHost PluginWindow::~PluginWindow() (in MyHost) (PluginWindow.cpp:82)  
> 10 com.company.MyHost PluginWindow::~PluginWindow() (in MyHost) (PluginWindow.cpp:75)

I managed to recreate the issue on my mac with a waves VST3 plugin.  
My app has the plugin editor as a scopedpointer inside a component owned by a document window. When destroying the window, the scopedpointer is set to nullptr and the desctructor ~VST3PluginWindow() is called  
Xcode breaks at warnOnFailure (view-\>removed());  
It seems to me like the plugin is trying to access the window that is being deleted?  
Is there a best practice for closing and freeing the editor?  
I see that the example host runs the message loop after deleteing the window, I have also implemented that, but the crash happens before this.

Any input would be greatly appreciated

---

<div class="post-metadata">

**Author:** ![fr810](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fr810/32/841_2.png) [@fr810](https://forum.juce.com/u/fr810)\
**Post date:** [July 29, 2016, 10:00am UTC](https://forum.juce.com/t/crash-closing-hosted-plugin-editor/18566/2 "2016-07-29T10:00:01Z")

</div>

Can you re-produce this with the audio plugin host? You could look at the source code of the audio plugin host to see how it’s done there.

---

<div class="post-metadata">

**Author:** ![nikolaiaudios](https://avatars.discourse-cdn.com/v4/letter/n/77aa72/32.png) [@nikolaiaudios](https://forum.juce.com/u/nikolaiaudios)\
**Post date:** [August 2, 2016, 3:25am UTC](https://forum.juce.com/t/crash-closing-hosted-plugin-editor/18566/3 "2016-08-02T03:25:41Z")

</div>

Sorry, it was a mistake on my side

---

<div class="post-metadata">

**Author:** ![javieraizpuru](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@javieraizpuru](https://forum.juce.com/u/javieraizpuru)\
**Post date:** [August 14, 2020, 10:40pm UTC](https://forum.juce.com/t/crash-closing-hosted-plugin-editor/18566/4 "2020-08-14T22:40:58Z")

</div>

Hi AudioStrom, I’m having exactly the same bug. Did you remember what was the mistake?

---

<div class="post-metadata">

**Author:** ![nikolaiaudios](https://avatars.discourse-cdn.com/v4/letter/n/77aa72/32.png) [@nikolaiaudios](https://forum.juce.com/u/nikolaiaudios)\
**Post date:** [August 15, 2020, 6:28pm UTC](https://forum.juce.com/t/crash-closing-hosted-plugin-editor/18566/5 "2020-08-15T18:28:06Z")

</div>

Hi  
That was a long time ago. But looking back at commits from that time It seems I simply made some calls in the destructor of the parent window that I should not have done, a bit over eager to clean up I guess. Just a silly, stupid mistake.  
4 years later, I have learned to test these things agains the demo host, and compare the code/behaviour
