Author Topic: MidiFilterProc throws an AccessViolationException in BASSMIDI x86 (BASS.NET 2.4)  (Read 2231 times)

KaleidonKep99

  • Posts: 173
Hello.
I recently stumbled upon a weird issue.

I use BASS_MIDI_StreamSetFilter to ignore specific tracks and events that the user doesn't want to play, and to send events to a VST instrument.
The 64-bit release of my converter, which makes use of this function, does work fine, but the 32-bit one throws an AccessViolationError inside MidiFilterProc, no matter what I do.

I'm pretty sure the 32-bit version of BASSMIDI is to blame, since everything works fine with the 64-bit library.
Even weirder is how passing an empty MidiFilterProc function still triggers the error.

Here's KMC x64 playing a MIDI with MidiFilterProc, which is used by my app to send events to the VST instrument:


And here's KMC x86, crashing as soon as BASS_ChannelGetData is called:

(Ignore BASS_ERROR_ILLPARAM, it's related to BASS_VST_ProcessEvent not recognizing the event.)

Ian @ un4seen

  • Administrator
  • Posts: 21133
Please upload a dump file for the crash. You can generate a dump file using the ProcDump tool. For example, run "procdump -e -ma -x . your.exe". Then ZIP and upload the generated dump file to have a look at here:

   ftp.un4seen.com/incoming/

KaleidonKep99

  • Posts: 173
I sent the dump. Its name is KeppyMIDIConverter.exe_180618_163556.dmp.

Ian @ un4seen

  • Administrator
  • Posts: 21133
For some reason I can't see the call stack in the dump file's exception record, but it looks like the crash may have happened when BASSMIDI called your MIDIFILTERPROC callback function. I'll send you a debug version to confirm that. I believe callback issues in .Net are usually the result of a delegate being garbarge collected, so you also could check that.

KaleidonKep99

  • Posts: 173
Here's the log, in case you didn't see the e-mail.

[attachment deleted by admin]

Ian @ un4seen

  • Administrator
  • Posts: 21133
I didn't receive your email for some reason, so just as well you posted the log here :)

The log doesn't show any problems with the MIDIFILTERPROC callback; it was called twice, and returned twice. The log doesn't reveal any other problems either. Did the AccessViolationError (described in the 1st post) happen when the log was generated?

KaleidonKep99

  • Posts: 173
I didn't receive your email for some reason, so just as well you posted the log here :)

The log doesn't show any problems with the MIDIFILTERPROC callback; it was called twice, and returned twice. The log doesn't reveal any other problems either. Did the AccessViolationError (described in the 1st post) happen when the log was generated?
It happened when the log was already generated, yes.

The weird thing is, it happens when there's nothing inside the MidiFilterProc function too. I don't know what's going on...

Chris

  • Posts: 1854
Hi, is in the MidiFilterProc any Guistuff? eg Access to a Component on your Form/MainThread?
If yes remove it and change it to Postmessage .....

KaleidonKep99

  • Posts: 173
Hi, is in the MidiFilterProc any Guistuff? eg Access to a Component on your Form/MainThread?
If yes remove it and change it to Postmessage .....
I already said that this happens when the MidiFilterProc function is empty too, so it must be something wrong with BASSMIDI.

Ian @ un4seen

  • Administrator
  • Posts: 21133
I tried adding a MIDIFILTERPROC callback to the MIDITEST example and there was no problem with it. Your log didn't show any problem with the MIDIFILTERPROC calls either. So I'm not sure what's going wrong there. To perhaps get a more useful dump file, please try generating a new dump file with the "-g" option added to the ProcDump command-line.

KaleidonKep99

  • Posts: 173
I tried adding a MIDIFILTERPROC callback to the MIDITEST example and there was no problem with it. Your log didn't show any problem with the MIDIFILTERPROC calls either. So I'm not sure what's going wrong there. To perhaps get a more useful dump file, please try generating a new dump file with the "-g" option added to the ProcDump command-line.
Done, I uploaded it to the FTP server, its name is "KeppyMIDIConverter.exe_180629_234316.dmp.7z".

Ian @ un4seen

  • Administrator
  • Posts: 21133
Unfortunately, the upload seems to be corrupt/incomplete. Can you try again? I forgot to ask you to include the BASSMIDI.LOG file from the same run as the dump file was generated, so please do that too (if you didn't already).

KaleidonKep99

  • Posts: 173
Sorry for the late response, I was doing my final exams! I just graduated. ;D ;D
I'll try getting the dump again asap.

KaleidonKep99

  • Posts: 173
Oops, sorry for making you wait for so long.
The file is "KeppyMIDIConverter.exe_180719_061327.dmp.7z".

Ian @ un4seen

  • Administrator
  • Posts: 21133
It looks like that dump file wasn't generated while using the debug BASSMIDI version that I sent you. Please reproduce the crash with the debug version and then upload both the dump and BASSMIDI.LOG files.

Btw, congrats on your exams :)

KaleidonKep99

  • Posts: 173
It looks like that dump file wasn't generated while using the debug BASSMIDI version that I sent you. Please reproduce the crash with the debug version and then upload both the dump and BASSMIDI.LOG files.

Btw, congrats on your exams :)
Oh damn I'm sorry, I'm getting everything wrong lately. ;D
I'll re-upload with the correct version.

KaleidonKep99

  • Posts: 173
Ok this time it has to work. ;D ;D ;D
Its name is "KeppyMIDIConverter.exe_180719_200007.dmp.7z".

Ian @ un4seen

  • Administrator
  • Posts: 21133
Can you upload the BASSMIDI.LOG file too? If you don't still have that from when the dump file was generated, please reproduce the problem again and upload the new dump and BASSMIDI.LOG files.

Also, is this what your MIDIFILTERPROC callback function currently looks like?

   https://github.com/KeppySoftware/Keppys-MIDI-Converter/blob/5be711088ad32eaf1f8c8aa3e12e145351fd39db/KeppyMIDIConverter/Functions/BASSControl.cs#L296

It looks like BASSCloseStreamCrash frees the stream? It isn't safe for a MIDIFILTERPROC callback function to free the stream. You could post a message and have the message handler call BASSCloseStreamCrash instead.

KaleidonKep99

  • Posts: 173
Can you upload the BASSMIDI.LOG file too? If you don't still have that from when the dump file was generated, please reproduce the problem again and upload the new dump and BASSMIDI.LOG files.

Also, is this what your MIDIFILTERPROC callback function currently looks like?

   https://github.com/KeppySoftware/Keppys-MIDI-Converter/blob/5be711088ad32eaf1f8c8aa3e12e145351fd39db/KeppyMIDIConverter/Functions/BASSControl.cs#L296

It looks like BASSCloseStreamCrash frees the stream? It isn't safe for a MIDIFILTERPROC callback function to free the stream. You could post a message and have the message handler call BASSCloseStreamCrash instead.
Yes I still have the log.

BASSCloseStreamCrash is called when an important part of the converter crashes. When it's called, it will show a dialog, and when the dialog gets closed, the converter force-quits.
I got rid of it to create the dump.

[attachment deleted by admin]

Ian @ un4seen

  • Administrator
  • Posts: 21133
I will send you another debug BASSMIDI version, to confirm that the MIDI stream isn't being freed.

KaleidonKep99

  • Posts: 173
Sent! "KeppyMIDIConverter.exe_180726_065303.dmp.7z".

Ian @ un4seen

  • Administrator
  • Posts: 21133
You forgot the BASSMIDI.LOG file again :)

KaleidonKep99

  • Posts: 173
Damnit...
Here! ;D ;D

[attachment deleted by admin]

Ian @ un4seen

  • Administrator
  • Posts: 21133
The log shows that the crash happened after your MIDIFILTERPROC function returned from a call. I'm wondering if perhaps .Net is corrupting the stack by writing beyond the expected BASS_MIDI_EVENT memory space. I'll send you another debug version to check that.

KaleidonKep99

  • Posts: 173
Done! KeppyMIDIConverter.exe_180727_214832.dmp.zip.