Author Topic: WaveWriter.Dispose() crashes app with unhandled exception when disk is full  (Read 121 times)

pgruebele

  • Posts: 75
I am using bass.net from C# and the following sequence causes BASS to generate an unhandled exception and crash the application.  It is not possible to catch the exception and prevent the crash so I think bass is doing some things asynchronously when calling Close() or Dispose() and not handling errors properly.

Steps to reproduce:

1. use a tool lie "fsutil file createnew e:\fill 56000000000" to almost fill the disk quickly.
2. Run the following code to cause the disk to fill up when writing WAV file and cause app crash because BASS is throwing an unhandled exception from another thread.

Code: [Select]
try
{
using (var writer = new WaveWriter(path, 1, 24000, 16, false))
{
try
{
while (true)
writer.Write(buffer, length);
}
catch
{
                                             // System.IO.IOException: 'There is not enough space on the disk.
}
}
}
catch
{
}

while (true) // We will get unhandled exception from BASS and the app will crash (IO exception says cannot seek stream)
;
}


Ian @ un4seen

  • Administrator
  • Posts: 23550
I don't think BASS.Net's WaveWriter class uses BASS (or BASSenc), so it seems like that crash probably isn't in BASS. Please see if you can reproduce it with the pre-compiled RECTEST.EXE example included in the BASSenc package (C\BIN folder). If that doesn't crash then you could try using BassEnc.BASS_Encode_Start with BASS_ENCODE_PCM in your test (instead of the WaveWriter class) and see if it still crashes.

pgruebele

  • Posts: 75
When I wrote "BASS crashes" I meant "Bass.Net crashes" since that is that this code is using.

If you think you will fix this bug in WaveWriter then I can just wait and won't change my code to use BASSenc.  Please let me know.

If seems that WaveWriter Dispose/Close logic needs fixing in that

1. After they return there should be no outstanding IO operations (since those could cause unhandled exceptions).
2. Especially if Dispose() encounters an IO error (seek/write/etc), then Dispose() should still close everything properly and THEN throw an exception telling the caller what went wrong.  But when throwing this exception there should be no outstanding IO operations since the object is supposed to be disposed.

Cheers

Ian @ un4seen

  • Administrator
  • Posts: 23550
Please note that BASS.Net isn't developed by un4seen but rather radio42. I would suggest trying BASSenc instead for the WAV writing (BASS_Encode_Start with BASS_ENCODE_PCM) and see how that goes. Let me know if something similar happens then too.

pgruebele

  • Posts: 75
Using bass.net directly as you suggested solves the issue.

I did not realize that bass.net is developed by someone else.