.Net 9 Preview 6 causes all BASS calls to instantly crash app

Started by pgruebele,

pgruebele

I just updated my app to .Net 9 preview 6 and all bass calls started crashing the app.  With Preview 5 things worked.  The rest of my app is working normally so this is some incompatibility between Bass and the latest .Net 9 Preview 6.

The error message is "... has exited with code 3221226505 (0xc0000409)." which seems to mean STATUS_STACK_BUFFER_OVERRUN so could this be an existing issue that is only no detected by the runtime?

I updated to the latest bass libraries and there is no change.

The native stack trace looks like this:
    KernelBase.dll!00007fff8a431f1e()   Unknown   No symbols loaded.
   bass.dll!00007ffede4f7004()   Unknown   No symbols loaded.

The exception says:
      Unhandled exception at 0x00007FFF8A431F1E (KernelBase.dll) in soundjar.exe: Unknown __fastfail() status code: 0x0000000000000039.



radio42

I haven't tried that latest preview myself, as I also don't see any advantage yet to migrate immediately.
But maybe this is a bug in the preview of .Net?

pgruebele

I will wait for Preview7 and try again.  For now I reverted to Preview 5 because of this issue...

pgruebele

Looks like .net 9 RC1 will be released shortly.  There is a breaking change regarding removal of BinaryFormatter: https://github.com/dotnet/runtime/issues/98245

If this is functionality the Bass .Net wrapper uses then this could explain the crash.  If not then I will test with RC1 and post back...

pgruebele

I did not hear back from you so I scanned your .net assembly and it looks like you indeed have references to BinaryFormatter which will throw exceptions in the .Net 9 release.  Not sure that these are causing my particular issue but this will certainly cause issues.

Here is the relevant post: https://github.com/dotnet/runtime/issues/98245

pgruebele

I just updated to the newly released .Net 9 Preview 7 and bass still crashes.

I think it is very unlikely that this is a .Net bug at this point and it is a show stopper for me.  Can you recreate this issue and publish a fix?

Thanks!

Ian @ un4seen

If you catch the crash in the debugger (in mixed mode), does the call stack lead back to a line in your code, and if so, what is it? Are you also able to reproduce the crash with any of the examples that come with BASS.Net?

pgruebele

Yes I upgraded the sample "simple.csproj" and it fails identically (see attaches screenshot).

I am also attaching the upgraded simple sample csproj for your convenience.


Ian @ un4seen

OK, that looks like it's crashing in the BASS_Init call. If you put a different BASS function call before that, does it crash at that call instead? Please also confirm what BASS version you're using, ie. what BASS_GetVersion returns. And if you haven't already done so, try the latest build:

   www.un4seen.com/stuff/bass.zip

pgruebele

I am already using the latest version from your download page.  Any call to bass crashes, not just bass init...

Ian @ un4seen

The BASS build linked above is newer than the one on the BASS webpage. Please reproduce the crash with it and (if it still happens) then use the debugger's "Save Dump As..." option to get a dump file, and ZIP and upload that to have a look at here:

   ftp.un4seen.com/incoming

pgruebele

With the latest version from your link the crash no longer happens.  Can I safely use this newer version?  It appears to use some additional DLLs...

pgruebele

Unfortunately with our app bass still crashes even with your latest version.  But we use a bunch of add-ons so in that sense our app is different from the simple sample app.

Are there newer versions of all the other DLLs including bass.net to try out?

pgruebele

It is still crashing later in our application as shown in the attached screenshot (the bass init call no longer crashes with your latest bass.dll).

Ian @ un4seen

Looks like it's in BASSmix now. An updated build of that is available here:

   www.un4seen.com/stuff/bassmix.zip

Regarding the BASS.DLL update, there are no known issues with it, so it should be safe to use. It imports the same DLLs as the release version, so there shouldn't be any difference there - what additional DLLs are you seeing?

pgruebele

The updated bassmix allows our app to pass that line but then it has the same crash on the next line at:

    Un4seen.Bass.AddOn.Enc.BassEnc.BASS_Encode_GetVersion()

I am guessing that if you fix that then the next line will crash as well so all the bass libraries need updating?

Ian @ un4seen

A BASSenc update is available here:

   www.un4seen.com/stuff/bassenc.zip

If there are any other add-ons affected, please try modifying this URL with the add-on's name to see if there's an updated version of that available too.

pgruebele

bassenc appears to have been the last problematic one.  Also never mind about the extra DLL loading.  Some DLLs just weren't being loaded previously due to the crash...

Ian @ un4seen

Good to hear that it's all working now. I think I know what it was - it's apparently related to the way that the 64-bit Windows DLLs were being built in 2022 (until December). The 3 affected DLLs were built in that time. All 3 are actually due for new releases soonish, but I'll get some rebuilds up on the BASS page in the meantime, although I would usually recommend using the latest builds (above) instead anyway.

BassPassion

Quote from: Ian @ un4seenGood to hear that it's all working now. I think I know what it was - it's apparently related to the way that the 64-bit Windows DLLs were being built in 2022 (until December). The 3 affected DLLs were built in that time. All 3 are actually due for new releases soonish, but I'll get some rebuilds up on the BASS page in the meantime, although I would usually recommend using the latest builds (above) instead anyway.

Do you happen to have an updated bassenc_dll for Windows on ARM as well?
The latest version I could find is 2.4.16.1 , which seems to be crashing (that version also crashed on x64)
For Windows x86/x64, v2.4.16.7 seems to be the latest, so I would love to have that for ARM as well.

Many thanks

Ian @ un4seen

The issue above only affected the x86_64 build, not the arm64 build, so your crash must be something else. Do you have any information on the crash, eg. a callstack?

BassPassion

Quote from: Ian @ un4seenThe issue above only affected the x86_64 build, not the arm64 build, so your crash must be something else. Do you have any information on the crash, eg. a callstack?

Ah, yes sorry, the crash on ARM64 is happening in bassenc_mp3.dll.

Exception thrown at 0x00007FF8436C57E8 (bassenc_mp3.dll) in myapp.exe: 0xC0000005: Access violation reading location 0x00007FF9436D2124.

>   bassenc_mp3.dll!00007ff8436c57e8()   Unknown
    bassenc_mp3.dll!00007ff8436c6164()   Unknown
    bassenc_mp3.dll!00007ff8436c1bc0()   Unknown
    bassenc_mp3.dll!00007ff8436b5200()   Unknown
    bassenc_mp3.dll!00007ff8436ba6d4()   Unknown
    bassenc_mp3.dll!00007ff8436b13a8()   Unknown
    bassenc.dll!00007ff86085362c()   Unknown
    bass.dll!00007ff83239f43c()   Unknown
    bass.dll!00007ff83239f9a8()   Unknown
    bass.dll!00007ff8323a00d0()   Unknown
    bass.dll!00007ff83239b680()   Unknown
    bass.dll!00007ff83239b8fc()   Unknown
    bass.dll!00007ff83239b9f0()   Unknown
    kernel32.dll!00007ff8b7a58740()   Unknown
    ntdll.dll!00007ff8b9490e54()   Unknown

This is my c# code (using the ManagedBass wrapper https://github.com/ManagedBass/ManagedBass)

_recordingHandle = BassEnc_Mp3.Start(_mixerStream, null, EncodeFlags.ConvertFloatAuto | EncodeFlags.Unicode, filePath);

Which is calling that wrapper:
public static int Start(int Handle, string Options, EncodeFlags Flags, EncodeProcedureEx ProcedureEx, IntPtr User)
{
    return BASS_Encode_MP3_Start(Handle, Options, Flags | EncodeFlags.Unicode, ProcedureEx, User);
}

Which in turn calls this:
[DllImport("bassenc_mp3", CharSet = CharSet.Unicode)]
private static extern int BASS_Encode_MP3_Start(int Handle, string Options, EncodeFlags Flags, EncodeProcedureEx ProcedureEx, IntPtr User);


Ian @ un4seen

OK, I'll email you a debug BASSenc_MP3 version to hopefully get some more info on that.