Author Topic: Issue with BassVst.BASS_VST_GetInfo  (Read 3330 times)

Ian @ un4seen

  • Administrator
  • Posts: 26107
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #25 on: 25 Jul '23 - 16:36 »
It may take a while to start the first time, as VS downloads symbol files from Microsoft. It should show a message when that's happening.

kafffee

  • Posts: 278
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #26 on: 25 Jul '23 - 16:49 »
I have a multi-project solution as it's a MVVM app. So I first changed the settings of all project.... That didnt work.

So I only enabled it on the main project, now it worked:

Ian @ un4seen

  • Administrator
  • Posts: 26107
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #27 on: 25 Jul '23 - 17:04 »
Is that call stack from a crash or just a breakpoint? If the latter then please get one from the former. The point of this is to find out where exactly it's crashing.

kafffee

  • Posts: 278
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #28 on: 25 Jul '23 - 17:27 »
Okay did it again. Now I get a different error. At first I thought this would have to do with forcing VS to quit via Taskmanager. But I restarted my computer completely and tried again. Still this new error. It occured when I was at the third breakpoint and then hit "continue".

Ian @ un4seen

  • Administrator
  • Posts: 26107
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #29 on: 26 Jul '23 - 12:37 »
That shows the crash happened in "Sketch Trumpet.dll", which is the VSTi that you loaded via BASS_VST_ChannelCreate (in the code you posted earlier). It looks like the problem is UI-related, as that DLL was called by USER32.DLL, which deals with UI stuff. Is that VSTi's UI working fine in other software?

It seems unlikely that BASS_VST_GetInfo is causing the problem, but rather the stuff in your code after that (perhaps the BASS_VST_EmbedEditor call). Does the crash still happen if you remove that stuff, eg. with just this?

Code: [Select]
        Dim vstInfo As New BASS_VST_INFO()
        If BassVst.BASS_VST_GetInfo(VSTInstrumentChannel, vstInfo) Then
            If vstInfo.hasEditor Then
            End If
        Else
        End If

kafffee

  • Posts: 278
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #30 on: 26 Jul '23 - 14:12 »
I ve tried a thousand times now and the error happens either at BASS_VST_GetInfo, at EmbedEditor or after that. Randomly.

Note: It only happens on some VSTi's, others work. I have also tried that a couple of times.

The DLL we are talking about works fine in my DAW, I have already made some beats with it. And in the test program I posted earlier it also works.

You said that the DLL was called by user32.dll, what about calling the Bass functions from another thread, Do you think this might work?

Chris

  • Posts: 2217
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #31 on: 26 Jul '23 - 14:35 »
Hi, can you check if you will have in your complete source somewhere a memory Leak ?


kafffee

  • Posts: 278
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #32 on: 26 Jul '23 - 14:37 »
Hi Chris,

how to do this?

Edit: Tried yet another VSTi DLL. There is something new happening: see screenshot

Edit2: The only difference to the test program that I can See ist that the test program is a WinForms app, the main project is a WPF MVVM app...
« Last Edit: 26 Jul '23 - 14:57 by kafffee »

rv

  • Posts: 387
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #33 on: 26 Jul '23 - 15:04 »
I think you need to use latest bass_vst.dll and bass.net , because in the past some of the variables were not large enough for 64 bit handles
Most of vst handle variables should be IntPtr and use UInt32 for DWORD in VB.net

Also, vst gui does not like if you run from different threads

Ian @ un4seen

  • Administrator
  • Posts: 26107
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #34 on: 26 Jul '23 - 15:14 »
I ve tried a thousand times now and the error happens either at BASS_VST_GetInfo, at EmbedEditor or after that. Randomly.

Can you post a call stack of a crash from after removing the code that I suggested? Please also enable the "Microsoft-Symbolserver" option (in your screenshot), which will allow more info about Microsoft DLLs (inc. USER32.DLL) in the call stacks.

The last call stack you posted (with USER32.DLL) looks like it's probably in the VST's UI message handler. The UI was presumably created by the BASS_VST_EmbedEditor call, which is why I suspect this particular crash won't happen when you remove that. If removing the BASS_VST_EmbedEditor call does prevent the crash, then also confirm which thread you're currently calling that from. If it isn't the main thread, try moving it there.

kafffee

  • Posts: 278
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #35 on: 26 Jul '23 - 20:01 »
@rv

I tried the newest versions, still the same error.

For my handles I am using the type Integer.

@Ian

I have two Screenshots for you:

(1) I removed the lines you suggested and it actually hit the breakpoint which I set to End Sub.

(2) I Hit continue then screenshot 10 showed up.

So I tried calling EmbedEditor from the main Thread but the original error showed up again.

Hopefully you can get some valuable Information from the screenshot.

Ian @ un4seen

  • Administrator
  • Posts: 26107
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #36 on: 27 Jul '23 - 12:13 »
That call stack confirms that it's crashing in the VST's UI message handler (WNDPROC callback). Was that definitely without the BASS_VST_EmbedEditor call? Perhaps you're still calling it elsewhere?

kafffee

  • Posts: 278
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #37 on: 27 Jul '23 - 13:23 »
Just to be sure I did it again: no crash when I take out the code you suggested.

Attached to this is the call stack.

I will try again with the code from my test project instead.

What else do you suggest?

Edit: okay did that with the test project Code, crash in BASS_VST_GetInfo. See attachment callstack12
« Last Edit: 27 Jul '23 - 13:31 by kafffee »

Ian @ un4seen

  • Administrator
  • Posts: 26107
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #38 on: 27 Jul '23 - 16:16 »
Please reproduce that crash again and use the "Save Dump As..." option in the "Debug" menu to generate a dump file, and then ZIP and upload that file to have a look at here:

   ftp.un4seen.com/incoming/

That will hopefully give some more info on what happened.

By the way, a call stack from a breakpoint (rather than a crash) doesn't tell us much, so no need to post those :)

Ian @ un4seen

  • Administrator
  • Posts: 26107
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #39 on: 28 Jul '23 - 14:35 »
The uploaded dump file reveals that the crash happened in the VST's handling of an "effEditGetRect" request from BASS_VST_GetInfo here:

   https://github.com/r10s/BASS_VST/blob/master/source/bass_vst_impl.cpp#L1862

The crash was caused by heap corruption, which is tricky to debug because the cause of the problem isn't where it's detected, ie. the cause is somewhere before that. To better locate where it really is, you can use Microsoft's GFlags tool, which comes installed with the Windows SDK. Run that and tick the "Enable page heap" box, and then run your app under the debugger again and see what message and call stack you get when it crashes.

If you would like to know more about GFlags, see here:

   https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/gflags

kafffee

  • Posts: 278
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #40 on: 28 Jul '23 - 15:38 »
Okay I downloaded and installed Windows 10 SDK with the latest version number  in the Visual Studio Installer.

But there is no folder "Debuggers" in c:\Programs(x86)\Windows Kits\10

Anything else I need to do or install? Or how can I start Gflags?

Edit: also installed windbg, still cant find that folder...
« Last Edit: 28 Jul '23 - 15:54 by kafffee »

Ian @ un4seen

  • Administrator
  • Posts: 26107
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #41 on: 28 Jul '23 - 16:41 »
I'm not sure if GFlags (or WinDbg) is included with the Windows SDK installed via VS. You can try the separate installer available here (select the "Debugging Tools for Windows" feature):

   https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/

kafffee

  • Posts: 278
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #42 on: 28 Jul '23 - 17:04 »
Okay it works. Do I need to Hit the OK Button in Gflags or only save changes or whatever that is called in English?

I tried without tapping on OK. Here ist the call stack:

The error is in English something like:

Access violation when writing at position xxxxx....

Ian @ un4seen

  • Administrator
  • Posts: 26107
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #43 on: 28 Jul '23 - 17:56 »
Although it's in the same call, that doesn't look like it's the same crash as last time. When GFlags catches a heap problem, there should be some extra info in the debugger's "Output" view. Do you see anything there?

It may be that you need to "Enable page heap" specifically for your EXE. You can do that in the "Image File" tab. Enter the EXE name (without path) in the "Image" box there and tick the "Enable page heap" box.

kafffee

  • Posts: 278
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #44 on: 29 Jul '23 - 06:22 »
Okay I made the changes in GFlags.exe.

Now without any changes of code I first get the error in call stack 14, then when I hit continue the error in call stack 15.

It did not happen in the procedure that we have, but it must have been somewhere here I guess (this gets executed before the procedure that we already have, during initialization of the program and the error here is something new):

Code: [Select]
For Each PlugInDatei In System.IO.Directory.GetFiles(MainModule.VSTVerzeichnis, "*.dll", IO.SearchOption.AllDirectories)
                Dim ProduktNameEffekt As String
                Dim ProduktNameInstrument As String
                Dim vstInfo As New BASS_VST_INFO()

                TestHandleInstrument = BassVst.BASS_VST_ChannelCreate(44100, 2, PlugInDatei, 0)

                Dim TestHandleEffekt As Integer = BassVst.BASS_VST_ChannelSetDSP(0, PlugInDatei, Nothing, 0)


                If (BassVst.BASS_VST_GetInfo(TestHandleEffekt, vstInfo)) AndAlso (Not String.IsNullOrEmpty(vstInfo.effectName)) AndAlso (Not vstInfo.isInstrument) Then
                    'ProduktName = vstInfo.productName
                    ProduktNameEffekt = vstInfo.effectName
                Else
                    ProduktNameEffekt = System.IO.Path.GetFileNameWithoutExtension(PlugInDatei)
                End If

                If (BassVst.BASS_VST_GetInfo(TestHandleInstrument, vstInfo)) AndAlso (Not String.IsNullOrEmpty(vstInfo.productName)) AndAlso (vstInfo.isInstrument) Then
                    'ProduktName = vstInfo.productName
                    ProduktNameInstrument = vstInfo.effectName
                Else
                    ProduktNameInstrument = System.IO.Path.GetFileNameWithoutExtension(PlugInDatei)
                End If

                BassVst.BASS_VST_ChannelRemoveDSP(0, TestHandleEffekt)
                BassVst.BASS_VST_ChannelFree(TestHandleInstrument)

                If vstInfo.isInstrument = False Then
                    If BassVst.BASS_VST_ChannelSetDSP(0, PlugInDatei, 0, 0) <> 0 Then
                        EffektListe.Add(New ViewModel.PlugInsViewModel(Nothing, PlugInDatei, ProduktNameEffekt, True, 0, Nothing, False, CType(System.Windows.Application.Current.Resources("VordergrundfarbeBrush"), SolidColorBrush), New List(Of Single)))
                    Else
                        BassVst.BASS_VST_ChannelRemoveDSP(0, 0)
                        SindEffekteInvalid = True
                    End If
                    'EffektListe.Add(New ViewModel.PlugInsViewModel(PlugInDatei, "Effekt1", True, 0, Nothing, False))
                    'EffektListe.Add(New ViewModel.PlugInsViewModel(PlugInDatei, "Effekt2", True, 0, Nothing, False))
                    'EffektListe.Add(New ViewModel.PlugInsViewModel(PlugInDatei, "Effekt3", True, 0, Nothing, False))
                Else
                    Dim InstrumentTestHandle As Integer = BassVst.BASS_VST_ChannelCreate(44100, 2, PlugInDatei, BASSFlag.BASS_STREAM_DECODE Or BASSFlag.BASS_SAMPLE_FLOAT)

                    If InstrumentTestHandle <> 0 Then
                        InstrumentenListe.Add(New ViewModel.PlugInsViewModel(Nothing, PlugInDatei, ProduktNameInstrument, True, 0, Nothing, False, Nothing, New List(Of Single)))
                    Else
                        BassVst.BASS_VST_ChannelFree(InstrumentTestHandle)
                        SindInstrumenteInvalid = True
                    End If

                End If
            Next

Falcosoft

  • Posts: 203
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #45 on: 29 Jul '23 - 12:37 »
I'm not sure if you have the same problem as I had with some plugins but for me it helped that after calling BASS_VST_ChannelCreate() I have not called BASS_VST_GetInfo() immediatley but started a timer with 100 ms delay and called BASS_VST_GetInfo() in the timer's callback.
Also be aware that some plugins can report real editor dimensions only after you initialized the editor. Before that you can get 0 for width/height . I'm not sure if it has been already fixed or not in the current Bass_VST release but there is/was a bug that sets hasEditor to false after 0 width/height is detected. It's unfortunate since this way you have no chance to detect if a plugin really has an editor but first reports 0 width/height so you can only get the dimensions after the editor has been initialized.

kafffee

  • Posts: 278
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #46 on: 29 Jul '23 - 13:03 »
 No, tried that but still the same Problem.... But thanks for the hint :-)

@Ian @ Un4Seen

I just saw that my used memory goes up to over 4GB, it used to be at like 600 MB. Does that have to do with Gflags?

Ian @ un4seen

  • Administrator
  • Posts: 26107
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #47 on: 31 Jul '23 - 12:17 »
Okay I made the changes in GFlags.exe.

Now without any changes of code I first get the error in call stack 14, then when I hit continue the error in call stack 15.

It's a different VST plugin ("SuperTron 6.1 (64).dll") that crashed this time. The "stack14" screenshot doesn't actually contain a call stack but rather the "Output" view, so can't see what call it was in at the time. Can you reproduce this crash?

Does this also mean you're loading multiple VST? When trying to locate a mysterious problem, it's a good idea to reduce the possible causes. So I would suggest loading one VST at a time to see if it only happens when using a particular one.

I just saw that my used memory goes up to over 4GB, it used to be at like 600 MB. Does that have to do with Gflags?

Is that memory used just by your app? If so, I don't think it should make that difference. To confirm whether it does, you can try disabling the "Enable page heap" settings that you previously enabled.

kafffee

  • Posts: 278
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #48 on: 31 Jul '23 - 13:15 »
I was able to reproduce the error (see screenshot).

I am loading every vst in a particular folder, sorting them by Instruments/effects, getting the name of them and sorting out invalid DLLs (32 or 64 bit), and then fill a listbox (effects) and a combobox (Instruments) with them. But they are freed immediately after that. At least they should be (see code, the namings are in German, but sound pretty much like English, if you still have problems reading it let me know).

Only when the user selects an Instrument from the combobox and hits a particular button, the procedure that we have been talking about all the time gets executed.

Using Gflags, the problem with Supertron in the initialization procedure comes up, which is new so I guess this has to do with enabling Page heap.

Ian @ un4seen

  • Administrator
  • Posts: 26107
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #49 on: 31 Jul '23 - 15:01 »
I am loading every vst in a particular folder, sorting them by Instruments/effects, getting the name of them and sorting out invalid DLLs (32 or 64 bit), and then fill a listbox (effects) and a combobox (Instruments) with them. But they are freed immediately after that. At least they should be (see code, the namings are in German, but sound pretty much like English, if you still have problems reading it let me know).

That's a lot of places for a problem to potentially be. For now, please try removing the "SuperTron 6.1 (64).dll" file and see if/where the crash is after that.

Looking at the last code snippet you posted, it seems like a lot of unnecessary loading and unloading there. I haven't tried it, but it seems to me that it could be reduced to something like this:

Code: [Select]
For Each PlugInDatei In System.IO.Directory.GetFiles(MainModule.VSTVerzeichnis, "*.dll", IO.SearchOption.AllDirectories)
                Dim ProduktName As String
                Dim vstInfo As New BASS_VST_INFO()

                Dim TestHandle As Integer = BassVst.BASS_VST_ChannelSetDSP(0, PlugInDatei, BASSVSTDsp.BASS_VST_DEFAULT, 0)
                If TestHandle <> 0 Then
                    If (BassVst.BASS_VST_GetInfo(TestHandle, vstInfo)) AndAlso (Not String.IsNullOrEmpty(vstInfo.effectName)) Then
                        ProduktName = vstInfo.effectName
                    Else
                        ProduktName = System.IO.Path.GetFileNameWithoutExtension(PlugInDatei)
                    End If
                    BassVst.BASS_VST_ChannelRemoveDSP(0, TestHandle)
                    If vstInfo.isInstrument = False Then
                        EffektListe.Add(New ViewModel.PlugInsViewModel(Nothing, PlugInDatei, ProduktName, True, 0, Nothing, False, CType(System.Windows.Application.Current.Resources("VordergrundfarbeBrush"), SolidColorBrush), New List(Of Single)))
                    Else
                        InstrumentenListe.Add(New ViewModel.PlugInsViewModel(Nothing, PlugInDatei, ProduktName, True, 0, Nothing, False, Nothing, New List(Of Single)))
                    End If
                End If
            Next

Does that make any difference?