# VST Loading Crash: ModuleHandle::closeEffect()

**URL:** <https://forum.juce.com/t/vst-loading-crash-modulehandle-closeeffect/11195>\
**Category:** General JUCE discussion\
**Created:** [October 31, 2012, 4:17pm UTC](https://forum.juce.com/t/vst-loading-crash-modulehandle-closeeffect/11195 "2012-10-31T16:17:25Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jrlanglois](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jrlanglois/32/21372_2.png) [@jrlanglois](https://forum.juce.com/u/jrlanglois)\
**Post date:** [October 31, 2012, 4:17pm UTC](https://forum.juce.com/t/vst-loading-crash-modulehandle-closeeffect/11195/1 "2012-10-31T16:17:25Z")

</div>

Hi Jules,

While playing around with the plugin host, I was trying to scan some plugins, and this free VST effect “triggered a breakpoint” in PluginHost (when attempting to close it): Combo.dll (from [mda](http://mda.smartelectronix.com/)).  
I’ve attempted debugging, but can’t seem to be able to figure out why since I’m not familiar enough with the VST code… so here’s a stack trace.

> [@](#):
>
> ```
> ntdll.dll!77baa912()	Unknown
> [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]	
> ntdll.dll!77babc07()	Unknown
> ntdll.dll!77baac5d()	Unknown
> ntdll.dll!77b45b89()	Unknown
> mda Combo.dll!100051b5()	Unknown
> mda Combo.dll!10003c6a()	Unknown
> mda Combo.dll!1000225e()	Unknown
> mda Combo.dll!10003a6f()	Unknown
> mda Combo.dll!10001036()	Unknown
> 
> ```
> 
> > Plugin Host.exe!juce::ModuleHandle::closeEffect(juce::AEffect \* eff) Line 454 C++  
> > Plugin Host.exe!juce::VSTPluginInstance::~VSTPluginInstance() Line 789 C++  
> > Plugin Host.exe!juce::VSTPluginInstance::`scalar deleting destructor’(unsigned int) C++  
> > Plugin Host.exe!juce::ScopedPointerjuce::VSTPluginInstance::~ScopedPointerjuce::VSTPluginInstance() Line 97 C++  
> > Plugin Host.exe!juce::VSTPluginFormat::findAllTypesForFile(juce::OwnedArrayjuce::PluginDescription,juce::DummyCriticalSection & results, const juce::String & fileOrIdentifier) Line 2762 C++  
> > Plugin Host.exe!juce::KnownPluginList::scanAndAddFile(const juce::String & fileOrIdentifier, bool dontRescanIfAlreadyInList, juce::OwnedArrayjuce::PluginDescription,juce::DummyCriticalSection & typesFound, juce::AudioPluginFormat & format) Line 151 C++  
> > Plugin Host.exe!juce::PluginDirectoryScanner::scanNextFile(bool dontRescanIfAlreadyInList) Line 85 C++  
> > Plugin Host.exe!juce::PluginListComponent::Scanner::timerCallback() Line 238 C++  
> > Plugin Host.exe!juce::timer::TimerThread::callTimers() Line 128 C++  
> > Plugin Host.exe!juce::timer::TimerThread::CallTimersMessage::messageCallback() Line 197 C++  
> > Plugin Host.exe!juce::WindowsMessageHelpers::dispatchMessageFromLParam(long lParam) Line 50 C++  
> > Plugin Host.exe!juce::MessageManager::dispatchNextMessageOnSystemQueue(bool returnIfNoPendingMessages) Line 111 C++  
> > Plugin Host.exe!juce::MessageManager::runDispatchLoopUntil(int millisecondsToRunFor) Line 120 C++  
> > Plugin Host.exe!juce::MessageManager::runDispatchLoop() Line 101 C++  
> > Plugin Host.exe!juce::JUCEApplication::main() Line 246 C++  
> > Plugin Host.exe!WinMain(void \* \_\_formal, void \* \_\_formal, const char \* \_\_formal, int \_\_formal) Line 107 C++  
> > Plugin Host.exe!\_\_tmainCRTStartup() Line 237 C  
> > Plugin Host.exe!WinMainCRTStartup() Line 164 C  
> > kernel32.dll!75688543() Unknown  
> > ntdll.dll!77b2ac69() Unknown  
> > ntdll.dll!77b2ac3c() Unknown

If I click “Continue” in VS, I can oddly still see the plugin in the list.  
[attachment=0]mda Combo - The Crasher.png[/attachment]

Also, deleting an instance of this plugin when used as a filter causes a crash of the plugin host… at the same method call (juce::ModuleHandle::closeEffect(juce::AEffect \* eff) Line 454).

This happens in Debug… and crashes the app when in release.

---

<div class="post-metadata">

**Author:** ![jrlanglois](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jrlanglois/32/21372_2.png) [@jrlanglois](https://forum.juce.com/u/jrlanglois)\
**Post date:** [October 31, 2012, 4:28pm UTC](https://forum.juce.com/t/vst-loading-crash-modulehandle-closeeffect/11195/2 "2012-10-31T16:28:21Z")

</div>

Just a note; FL Studio and Audition scan/load/close it fine…

---

<div class="post-metadata">

**Author:** ![TheVinn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thevinn/32/806_2.png) [@TheVinn](https://forum.juce.com/u/TheVinn)\
**Post date:** [October 31, 2012, 4:44pm UTC](https://forum.juce.com/t/vst-loading-crash-modulehandle-closeeffect/11195/3 "2012-10-31T16:44:19Z")

</div>

Try the Release build of the plugin host, but without the debugger attached. Does it still crash?

---

<div class="post-metadata">

**Author:** ![jrlanglois](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jrlanglois/32/21372_2.png) [@jrlanglois](https://forum.juce.com/u/jrlanglois)\
**Post date:** [October 31, 2012, 4:52pm UTC](https://forum.juce.com/t/vst-loading-crash-modulehandle-closeeffect/11195/4 "2012-10-31T16:52:50Z")

</div>

I tried it without the debugger attached in the first place, so yep.

---

<div class="post-metadata">

**Author:** ![jrlanglois](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jrlanglois/32/21372_2.png) [@jrlanglois](https://forum.juce.com/u/jrlanglois)\
**Post date:** [November 1, 2012, 3:24pm UTC](https://forum.juce.com/t/vst-loading-crash-modulehandle-closeeffect/11195/5 "2012-11-01T15:24:46Z")

</div>

Upon a further attempt of understanding the VST code while walking through this issue; it seems to be related to the plugin itself… Although such wouldn’t explain why the DAWs I have at hand can load, use and close this plugin fine.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 1, 2012, 3:34pm UTC](https://forum.juce.com/t/vst-loading-crash-modulehandle-closeeffect/11195/6 "2012-11-01T15:34:18Z")

</div>

There are many plugins out there that are written with dodgy assumptions about the exact order or timing with which their functions will be called, so they end up working ok in the host that they were written for, but get fragile when other hosts deviate slightly from that behaviour.

The juce host wrapper definitely doesn’t do anything silly or unreasonable, so I think that the tiny number of plugins that still fail are probably just a bit flakey. Unfortunately to attempt to guess what it is that they don’t like, and to change the wrapper to accommodate that is almost impossible without being able to debug them.

---

<div class="post-metadata">

**Author:** ![jrlanglois](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jrlanglois/32/21372_2.png) [@jrlanglois](https://forum.juce.com/u/jrlanglois)\
**Post date:** [November 1, 2012, 3:41pm UTC](https://forum.juce.com/t/vst-loading-crash-modulehandle-closeeffect/11195/7 "2012-11-01T15:41:55Z")

</div>

> [@](#):
>
> There are many plugins out there that are written with dodgy assumptions about the exact order or timing with which their functions will be called, so they end up working ok in the host that they were written for, but get fragile when other hosts deviate slightly from that behaviour.

In the back of my mind, I knew that that was the cause…

> [@](#):
>
> The juce host wrapper definitely doesn’t do anything silly or unreasonable, so I think that the tiny number of plugins that still fail are probably just a bit flakey. Unfortunately to attempt to guess what it is that they don’t like, and to change the wrapper to accommodate that is almost impossible without being able to debug them.

Fair enough!

Thanks for clarifying, Jules!

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 1, 2012, 4:04pm UTC](https://forum.juce.com/t/vst-loading-crash-modulehandle-closeeffect/11195/8 "2012-11-01T16:04:11Z")

</div>

Could be worth telling the plugin’s developer though - it’s much easier for them to debug it than for us to try to guess what’s wrong.

---

<div class="post-metadata">

**Author:** ![jrlanglois](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jrlanglois/32/21372_2.png) [@jrlanglois](https://forum.juce.com/u/jrlanglois)\
**Post date:** [November 1, 2012, 4:33pm UTC](https://forum.juce.com/t/vst-loading-crash-modulehandle-closeeffect/11195/9 "2012-11-01T16:33:44Z")

</div>

Yeah, good call

---

<div class="post-metadata">

**Author:** ![jrlanglois](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jrlanglois/32/21372_2.png) [@jrlanglois](https://forum.juce.com/u/jrlanglois)\
**Post date:** [November 2, 2012, 2:12pm UTC](https://forum.juce.com/t/vst-loading-crash-modulehandle-closeeffect/11195/10 "2012-11-02T14:12:39Z")

</div>

Hey Jules,

I got in touch with the developer of the MDA plugins (Paul Kellett) - he looked into it rather speedily! Here’s his reply to my e-mail letting him know that his plugin somehow crashes the plugin host:

> [@](#):
>
> I didn’t find any problems, just something strange - the JUCE host displays the plug-in version (1000) as 3.232 rather than 1.000 - I thought at first it was memory corruption which might explain your crashes, but looking in juce\_VSTPluginFormat.cpp (line 1865) it’s interpreting the version as a series of bytes, but version numbers in VST 2.x are not like that.

Paul is referring to the following method: juce::VSTPluginInstance::getVersion().

I did a bit of research and came across the following in the VST code’s documentation (see aeffect.h - line 180):

```auto
struct AEffect
{
//[...] code before here
	VstInt32 version; ///< plug-in version (example 1100 for version 1.1.0.0)
 //[...] more code after
}
```

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 2, 2012, 2:43pm UTC](https://forum.juce.com/t/vst-loading-crash-modulehandle-closeeffect/11195/11 "2012-11-02T14:43:58Z")

</div>

Ah… That’s a bit awkward then…

All juce-based plugins will use base 16 to build the version number; if other ones are using base 10, then that makes it things a bit tricky. If I change the host to use base 10, all the juce ones will look wrong. Hmm. Yeah. Not sure about that…

---

<div class="post-metadata">

**Author:** ![sonic59](https://avatars.discourse-cdn.com/v4/letter/s/a8b319/32.png) [@sonic59](https://forum.juce.com/u/sonic59)\
**Post date:** [November 2, 2012, 3:25pm UTC](https://forum.juce.com/t/vst-loading-crash-modulehandle-closeeffect/11195/12 "2012-11-02T15:25:11Z")

</div>

Well I think the Juce VST host is one of the few hosts that actually show the VST version number. FL Studio and Audtion don’t ever show it. Also I’m guessing most people were probably using a text label to put there version number in their plugin rather than using the code based plugin version number directly. This is probably why it has gone unnoticed all these years.

If all other hosts are following the VST spec properly and using base 10, then all the juce based vst plugins are showing to wrong version in all those hosts. Additionally since it is causing the juce host to crash, this is definitely a bug that should be fixed on the plugin and host side.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 2, 2012, 5:08pm UTC](https://forum.juce.com/t/vst-loading-crash-modulehandle-closeeffect/11195/13 "2012-11-02T17:08:28Z")

</div>

Hmm. Yes, I guess I’ll just have to change both the host and plugin classes. Damn.

---

<div class="post-metadata">

**Author:** ![jrlanglois](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jrlanglois/32/21372_2.png) [@jrlanglois](https://forum.juce.com/u/jrlanglois)\
**Post date:** [November 2, 2012, 7:29pm UTC](https://forum.juce.com/t/vst-loading-crash-modulehandle-closeeffect/11195/14 "2012-11-02T19:29:25Z")

</div>

I see your changes for this - cool!

I also see that you changed the juce\_AudioPluginModule file to use the decimal format instead of hex… that may not be good since [AU plugins utilize base-16 for version numbers](https://developer.apple.com/library/mac/documentation/MusicAudio/Conceptual/AudioUnitProgrammingGuide/AudioUnitDevelopmentFundamentals/AudioUnitDevelopmentFundamentals.html#//apple_ref/doc/uid/TP40003278-CH7-SW9) (see the Audio Unit Identification section)…

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 2, 2012, 7:47pm UTC](https://forum.juce.com/t/vst-loading-crash-modulehandle-closeeffect/11195/15 "2012-11-02T19:47:03Z")

</div>

> [@jrlanglois](#):
>
> that may not be good since [AU plugins utilize base-16 for version numbers](https://developer.apple.com/library/mac/documentation/MusicAudio/Conceptual/AudioUnitProgrammingGuide/AudioUnitDevelopmentFundamentals/AudioUnitDevelopmentFundamentals.html#//apple_ref/doc/uid/TP40003278-CH7-SW9) (see the Audio Unit Identification section)…

Oh, ffs… Yes, thanks for the heads-up.

---

<div class="post-metadata">

**Author:** ![jrlanglois](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jrlanglois/32/21372_2.png) [@jrlanglois](https://forum.juce.com/u/jrlanglois)\
**Post date:** [November 2, 2012, 7:51pm UTC](https://forum.juce.com/t/vst-loading-crash-modulehandle-closeeffect/11195/16 "2012-11-02T19:51:55Z")

</div>

Yep, no worries. (Not sure how this will affect RTAS and AAX though…)

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 2, 2012, 7:56pm UTC](https://forum.juce.com/t/vst-loading-crash-modulehandle-closeeffect/11195/17 "2012-11-02T19:56:07Z")

</div>

I’ve re-done it now, so the number stays in hex, and only gets converted to decimal for VST.

---

<div class="post-metadata">

**Author:** ![jrlanglois](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jrlanglois/32/21372_2.png) [@jrlanglois](https://forum.juce.com/u/jrlanglois)\
**Post date:** [November 2, 2012, 8:02pm UTC](https://forum.juce.com/t/vst-loading-crash-modulehandle-closeeffect/11195/18 "2012-11-02T20:02:18Z")

</div>

Alrighty - thanks Jules. 🙂

---

<div class="post-metadata">

**Author:** ![jrlanglois](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jrlanglois/32/21372_2.png) [@jrlanglois](https://forum.juce.com/u/jrlanglois)\
**Post date:** [November 2, 2012, 8:11pm UTC](https://forum.juce.com/t/vst-loading-crash-modulehandle-closeeffect/11195/19 "2012-11-02T20:11:31Z")

</div>

Ah dang - there’s another instance of JucePlugin\_VersionCode used in the VST wrapper that should be converted to decimal as well…

```auto
    VstInt32 getVendorVersion() { return JucePlugin_VersionCode; }
```

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 3, 2012, 10:13am UTC](https://forum.juce.com/t/vst-loading-crash-modulehandle-closeeffect/11195/20 "2012-11-03T10:13:02Z")

</div>

Drat! Easily fixed though, thanks!

[Next page](https://forum.juce.com/t/vst-loading-crash-modulehandle-closeeffect/11195.md?page=2)
