Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unhandled exception from Jacobi.Vst.Host.Interop on ProcessReplacing #56

Open
cuikp opened this issue Feb 6, 2022 · 1 comment
Open

Comments

@cuikp
Copy link

cuikp commented Feb 6, 2022

When using Jacobi.Vst.Host.Interop from a .NET 5 host to interact with Effect-type VSTs (VST2), in some rare cases (only specific VSTs) calling ProcessReplacing crashes the managed host with an unhandled exception that is impossible to capture and handle from managed code (even the AppDomain.CurrentDomain.UnhandledException handler doesn't grab it) :

"An unhandled exception of type 'System.AccessViolationException' occurred in Jacobi.Vst.Host.Interop.dll
Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Or, with native code debugging on in Visual Studio:

"Exception thrown at 0x00007FFD0603993D (SynthMaster2FX.dll) in QuikDawEditor.exe: 0xC0000005: Access violation reading location 0x0000000000000054"

To Reproduce
Browsing the code I notice that ProcessReplacing is as follows:

float** ppInputs = inputs->Length == 0 ? _emptyAudio32 : _audioInputs.GetArray(inputs->Length);
float** ppOutputs = outputs->Length == 0 ? _emptyAudio32 : _audioOutputs.GetArray(outputs->Length);
int32_t inputSampleCount = CopyBufferPointers(ppInputs, inputs);
int32_t outputSampleCount = CopyBufferPointers(ppOutputs, outputs);
CallProcess32(ppInputs, ppOutputs, max(inputSampleCount, outputSampleCount));

(that is, without any error handling)

With all the numerous VSTs out there it would seem to be more trouble than it's worth to ferret out the specific cause of each error that a VST might be raising, but if the Vst.Host.Interop dll could simply handle any exceptions that are raised in this method (i.e not crash), it would allow the managed host program to grab the name of the VST so that it could just be ignored in the future.

  • OS: Windows 10
  • .NET Core 5.x

(In case it's useful to mention, the name of one VST that is raising the error is the free plugin "SynthMaster2FX.dll" by KV331 Audio)

@cuikp
Copy link
Author

cuikp commented Feb 6, 2022

By "impossible to capture and handle", I mean that the exception is not handleable by try/catch clauses, the WPF DispatcherUnhandledException handler or the AppDomain.CurrentDomain.UnhandledException handler, nor even by the AppDomain.CurrentDomain.FirstChanceException handler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant