Access violation after BassAsio.BASS_ASIO_Start call

Started by kafffee,

kafffee

Hey :)

As the subject already says, my program just ends with this error output in the debug console after I call BassAsio.BASS_ASIO_Start():

Code 3221225477 (0xc0000005) 'Access violation'

There is no error thrown, even though I run it in debug mode. It just ends two or three seconds after the (successful!) call of this function, just as if I ran it in the stand-alone release version.

What reasons might this have?

This is my code:

BassAsio.BASS_ASIO_Init(0, BASSASIOInit.BASS_ASIO_DEFAULT)

NativeASIODevSampleRate = BassAsio.BASS_ASIO_GetRate
BassAsio.BASS_ASIO_ChannelSetRate(True, 0, NativeASIODevSampleRate)
MessageBox.Show("channelsetrate: " & BassAsio.BASS_ASIO_ErrorGetCode.ToString)
BassAsio.BASS_ASIO_ChannelSetRate(False, 0, NativeASIODevSampleRate)
MessageBox.Show("channelsetrate: " & BassAsio.BASS_ASIO_ErrorGetCode.ToString)
BassAsio.BASS_ASIO_ChannelSetRate(True, 1, NativeASIODevSampleRate)
MessageBox.Show("channelsetrate: " & BassAsio.BASS_ASIO_ErrorGetCode.ToString)
BassAsio.BASS_ASIO_ChannelSetRate(False, 1, NativeASIODevSampleRate)
MessageBox.Show("channelsetrate: " & BassAsio.BASS_ASIO_ErrorGetCode.ToString)
MessageBox.Show("SampleRates: " & CStr(NativeASIODevSampleRate))
MainModule.Mixer = BassMix.BASS_Mixer_StreamCreate(CInt(NativeASIODevSampleRate), MainModule.Song.NumberOfChannels, BASSFlag.BASS_MIXER_NONSTOP Or BASSFlag.BASS_STREAM_DECODE)
Bass.BASS_ChannelSetAttribute(MainModule.Mixer, BASSAttribute.BASS_ATTRIB_BUFFER, 0.0F) ' disable playback buffering

If Not System.IO.Directory.Exists("C:\Test") Then System.IO.Directory.CreateDirectory("C:\Test")

If Recording.PlayBackStreamHandle <> 0 Then Bass.BASS_ChannelFree(Recording.PlayBackStreamHandle)

Dim filename As String = "C:\Test\input.mp3"

Recording.PlayBackStreamHandle = Bass.BASS_StreamCreateFile(filename, 0, 0, BASSFlag.BASS_STREAM_DECODE Or BASSFlag.BASS_SAMPLE_FLOAT)

Recording.SplitOriginal = BassMix.BASS_Split_StreamCreate(Recording.PlayBackStreamHandle, BASSFlag.BASS_STREAM_DECODE Or BASSFlag.BASS_SAMPLE_FLOAT, Nothing)

BassMix.BASS_Mixer_StreamAddChannel(MainModule.Mixer, Recording.SplitOriginal, BASSFlag.BASS_DEFAULT Or BASSFlag.BASS_MIXER_CHAN_NORAMPIN)

BassAsio.BASS_ASIO_ChannelEnableBASS(False, 0, MainModule.Mixer, True)
Dim ret = BassAsio.BASS_ASIO_Start(512)
If Not ret then MessageBox.Show(BassAsio.BASS_ASIO_ErrorGetCode.ToString)
                   

Ian @ un4seen

Please provide a dump file from the crash for more info. You can get a dump file by using Visual Studio's "Debug > Save Dump As..." menu option after the crash. Then ZIP and upload it here:

   ftp://ftp.un4seen.com/incoming/

You may need to enable mixed-mode debugging first:

   https://learn.microsoft.com/en-us/visualstudio/debugger/how-to-debug-in-mixed-mode

kafffee

Okay, I enabled mixed mode debugging and saved the dump file. But somehow I cannot open the ftp link, will I need special software to do this? Is there another way to transfer the file, maybe I could send you a link by email or so?

Might be important to know:

After I enabled mixed mode debugging and the crash happens, Visual Studio says that it's missing the *.pdb file (I think it was the bassasio.pdb).

Then I restarted the program and caused the error again, then it said:

-symbol file for asio4all64.dll not loaded
-original file path: C:\Program Files (x86)\ASIO4ALL v2\asio4all64.dll
-access violation when writing at position 0x00000235EC5A4000

Ian @ un4seen

You can open the FTP link in File Explorer, and then drag'n'drop the file into it.

kafffee

Ian @ un4seen

There isn't an exception record in the dump file. Did you definitely generate it when the crash was caught by the Visual Studio debugger? It also looks like you're currently using old versions of BASS/BASSASIO/BASSmix. Please try upgrading them to the latest versions, and if the problem still happens, get another dump file.

kafffee

Okay I updated BASS/BASSASIO/BASSmix and created another dump file after the crash. It's been transferred.

Ian @ un4seen

Thanks, this dump file does include an exception record. It shows that the crash happened in ASIO4ALL64.DLL, apparently in its own thread. To confirm whether it is something specific to ASIO4ALL, do you also get a crash when using other ASIO drivers? And is ASIO4ALL working OK in other 64-bit apps? Make sure they're 64-bit so that they're using ASIO4ALL64.DLL.

You could also try the pre-compiled CONTEST.EXE example from the BASSASIO package (C\BIN folder). That's 32-bit, so it'll be using the 32-bit ASIO4ALL.DLL driver. Use the "-l" and "-d" options to list and choose ASIO drivers.

kafffee

QuoteTo confirm whether it is something specific to ASIO4ALL, do you also get a crash when using other ASIO drivers?

Unfortunately I do not own any other ASIO dedicated devices/drivers.

QuoteAnd is ASIO4ALL working OK in other 64-bit apps?

When I switched to ASIO4ALL in my DAW it also crashed without any error message.

So I did some research and tried to disable all audio devices but one in the Windows system settings. When I switched to ASIO4ALL in my DAW then, it actually worked and I even heard the test sound.

So I thought that this was it and tried with my program but it crashed again. And: After I tried again with my DAW, it didn't even start up.

I am using ASIO4ALL version 2.18.0.0 - strange enough: on my other PC (with an older version of ASIO4ALL installed) my program does run. And: My own program used to not crash in an earlier version of itself with the same ASIO4ALL driver, but it actually never worked the way it was supposed to (another audio device was marked red in the ASIO4ALL control panel).

What is contest.exe supposed to do? Am I supposed to use 'l in the command line or actually after the program has started?

So the issue seems to be related to this specific ASIO4ALL driver. Do you have any suggestions what I could do?

Chris

Hi, Normally the most PC`s will have a Onboard Realtec Card.
You can test it with this Realtec Asio Driver.
https://github.com/samuelcaldas/Realtek-ASIO-Driver

kafffee

Downloaded the most current version of the ASIO4ALL driver (2.22). Now it works without crash on a bluetooth device. Only when I set the output to the onboard sound device it says that the device is in use by another application..... hmmm maybe another bug in the driver...

Or does a call of Bass.BASS_Init(-1, ...) (which is exactly this device) block it? Can you exclude this?

Ian @ un4seen

Quote from: kafffeeWhat is contest.exe supposed to do? Am I supposed to use 'l in the command line or actually after the program has started?

Use "-l" in the command-line to list available ASIO devices/drivers, and then use "-d" with the device number that you want. If you don't provide any command-line then it'll show the available options. Note you need to run it in a Command Prompt (or Powershell) window.

Quote from: kafffeeDownloaded the most current version of the ASIO4ALL driver (2.22). Now it works without crash on a bluetooth device. Only when I set the output to the onboard sound device it says that the device is in use by another application..... hmmm maybe another bug in the driver...

Or does a call of Bass.BASS_Init(-1, ...) (which is exactly this device) block it? Can you exclude this?

Normal shared output (from BASS or anything else) shouldn't block an ASIO driver. The driver will stop the shared output if necessary, like exclusive mode WASAPI does. If you're actually using exclusive mode WASAPI (eg. with BASSWASAPI), I guess there will be a conflict with the ASIO driver then.

kafffee

I have to check if I'm using WASAPI in my app, because I used to, maybe I forgot to remove some relevant code for it.

But my guess is more like that there's a problem with ASIO4ALL when I use the same device for playback and recording, e.g. the onboard sound or my USB mic, which also has a headphone jack for (CPU-) monitoring.

This seems obvious to me, because I already had this problem when I started with my app (at the time I was using the forementioned USB mic, and was running into the same issue).

I will keep evaluating and share my acquired wisdom here :)

------------------------------------------

Edit: Hard to tell if it's due to the fact that I use one device for in- and output. What I found out though is that when I exit the program there's another exception thrown when the ASIO control panel is open. Not when it's still closed.

Is there a function in bassasio that will close it again? I couldn't find such in the docs... Note:  BassAsio.BASS_ASIO_Free() does not avoid this either.