VST Host Sample throws StackOverflowException

May 9, 2009 at 10:54 AM

Hi,

i tried your VST host sample, but when i click on "Add" the Debugger shows the "System.StackOverflowException" as of infinite loop. As i tried it in my code, with parts from the sample, it happens also.

 

With the debugger i could localize the line in VstPluginContext.cpp (i marked it with ===>). The debugger jumps to the VstPluginContext::Create then it steps further to VstManagedPluginContext::Create at jumps back to VstPluginContext::Create.

 

    VstPluginContext^ VstPluginContext::Create(System::String^ pluginPath, Jacobi::Vst::Core::Host::IVstHostCommandStub^ hostCmdStub)
    {
        Jacobi::Vst::Core::Throw::IfArgumentIsNullOrEmpty(pluginPath, "pluginPath");
        Jacobi::Vst::Core::Throw::IfArgumentIsNull(hostCmdStub, "hostCmdStub");

        // verify file exist
        if(!System::IO::File::Exists(pluginPath))
        {
            throw gcnew System::IO::FileNotFoundException(pluginPath);
        }

===>      VstPluginContext^ pluginCtx = VstManagedPluginContext::Create(pluginPath, hostCmdStub);

        if(pluginCtx == nullptr)
        {
            pluginCtx = VstUnmanagedPluginContext::Create(pluginPath, hostCmdStub);
        }

 

Is it my mistake and i forgot somethig in my code or compiled your code wrong? Or does a solution/patch exist?

 

Greetings

RedFalcon

Coordinator
May 9, 2009 at 1:00 PM

Hi RedFalcon,

Thanx for bringing this to my attention. I'm not sure how this bug crept into the code, but thanx for the catch ;-)

Problem was that the Create method for both the VstManagedPluginContext and the VstUnmanagedPluginContext were protected and therefor not callable from the VstPluginContext class. .NET allows calling static methods on any type of the class hierarchy (so it reverted back to the VstPluginContext::Create method, which was the only one accessable). I've changed the name and the accessability of the methods and tested the Host sample. It now loads as expected. Please retrieve the latest version of the source code to receive this fix.

Sorry for the extra work you had to do.

Grtx,
Marc Jacobi

May 9, 2009 at 3:17 PM
Edited May 9, 2009 at 5:11 PM

Hi,

thanks for this fast reply and fix. I will test and post if it works.

 

Edit:

I tested it, now it opens your delay sample plugin without hassle. But i had a problem with other VSTs, it shows exception about manifest, strong names and signing of interop assembly. I removed reference to your sign file and some assembly files that you mention in "build steps" before i compiled VST.Net. Just ask and i will try to reconstruct steps, cause i forgot which plugin i have tested with it.

 

 

PS: I don't see programming or debugging as extra work, if i can help fix problems. It's my everyday job. ;)

 

Greetings

Andi

May 10, 2009 at 9:20 AM
Edited May 10, 2009 at 4:10 PM

Hi,

for the problem see my edit of the previous post. I tried it again with DSK Strings plugin an it throws MissingManifestResourceException. As i said your delay sample loaded just fine (although i looked only in the debugger, cause i am at the beginning with my KeyboardWorkstation and so it doesn't have much GUI), but others, i think unmanaged, have problems.

 

It throws the exception at the end of VstPluginContext::Create

 

    if(pluginCtx != nullptr)
        {
            try
            {
                pluginCtx->Initialize(pluginPath);
            }
            catch(...)
            {
                delete pluginCtx;

===>       throw;
            }
        }

 

Edit: After further debugging it seems to be this part:

if(pluginMain == NULL)
            {
                throw gcnew System::EntryPointNotFoundException(
                    System::String::Format(
                        Jacobi::Vst::Interop::Properties::Resources::VstUnmanagedPluginContext_EntryPointNotFound,
                        pluginPath));
            }

It tries to find VSTPluginMain as entry point and fails.

Edit: Maybe there should entry point search like here http://www.kvraudio.com/forum/printview.php?t=195887&start=0

They search for 3 different types of plugin entry points

hModule = LoadLibrary(_T("Components/Atmosphere.dll"));
if(hModule)
{
if (hModule) // if there, get its main() function
{
pMain = (VSTPluginMain) GetProcAddress(hModule, "VSTPluginMain");
if (!pMain)
pMain = (VSTPluginMain) GetProcAddress(hModule, "VstPluginMain()");
if (!pMain)
pMain = (VSTPluginMain) GetProcAddress(hModule, "main");
}

 

Greetings

Andi

Coordinator
May 11, 2009 at 7:15 AM

Hi Andi,

To my knowledge there are only 2 valid entry points for a VST Plugin: "VSTPluginMain" and "main".

VST.NET only supports VST 2.4, so it does not check for "main" because its the older name for the entry point.

There is an item you can vote on if you feel that VST.NET should also support older VST versions (< 2.4).
http://vstnet.codeplex.com/WorkItem/View.aspx?WorkItemId=3917

Grtx,
Marc

Jun 15, 2009 at 1:39 PM

hi obiwanjacobi,

thanks for this usefull and cool project. I'm not a guru of vst programming and i think that this project can help me :)

I download the last version (0.7 (18964)) now, but when i tried your VST host sample, i catch same error StackOverflowException when i click add to Jacobi.Vst.Samples.Delay from _SharedAssemblies.  This exception is thrown by this statement: VstPluginContext ctx = VstPluginContext.Create(pluginPath, hostCmdStub);

Maybe is there something wrong in my configuration or in my use?Is it my mistake adding this assembly? 

Thanks in advance,

Paolo

 

Coordinator
Jun 29, 2009 at 7:00 PM

Hi Paolo,

Download the latest source code.

http://vstnet.codeplex.com/SourceControl/ListDownloadableCommits.aspx#DownloadLatest

Build the libraries and you should be okay.

Hope it helps.