Author Topic: BASSMIDI from stuff causes foo_midi to hang on shutdown  (Read 146 times)

kode54

  • Posts: 119
Please see version numbers here:

https://hydrogenaud.io/index.php?topic=98907.msg996624#msg996624

I'll paste them for convenience, though:

bass.dll (v2.4.15.46) and bassmidi.dll (v2.4.13.14)

Compared to what I ship already:

bass.dll (v2.4.15.0) and bassmidi.dll (v2.4.13.0)

All BASS/BASSMIDI interaction happens in this file:

https://git.lopez-snowhill.net/chris/foo_midi/-/blob/master/BMPlayer.cpp

deus-ex

  • Posts: 286
Please let me point out that the issue appears to be related solely to the stuff release of bass.dll (v2.4.15.46), probably earlier stuff releases of bass.dll are affected likewise. I cannot test that as I don't have any earlier stuff version of bass.dll available. After I replaced bass.dll v2.4.15.46 with the official release v2.4.15.00 the issue was fixed.

Bassmidi.dll appears to have NO effect on the issue. Currently I'm using the bassmidi.dll stuff release v2.4.13.14 along with bass.dll v2.4.15.00 without issues.

Please let me know if I can do anything to help solving the issue.

Ian @ un4seen

  • Administrator
  • Posts: 23662
It's getting stuck in the BASS_Free call in the "Bass_Initializer" destructor. Since BASS 2.5.15, some thread synchronization code has been modified on Windows (to match the other platforms and allow some #ifdefs to be removed), but they can be left in a dodgy state when Windows kills threads during process termination. In this case, BASS_Free is left waiting for something that will never happen (because the other thread was killed). A DllMain function or global destructor should pretty much do nothing when the process is being terminated, as described here:

   https://devblogs.microsoft.com/oldnewthing/20120105-00/?p=8683

In a DllMain function you can check the "lpReserved" parameter to detect termination, but I'm not sure what you would do in a global destructor. Does FB2K ever unload the plugin? If not, you can probably just remove the destructor. Anyway, here's a BASS update in which BASS_Free should detect that the threads have been killed and abort:

   www.un4seen.com/stuff/bass.zip

Let me know if you still see the problem happening with that.

deus-ex

  • Posts: 286
I'm happy to confirm that with the updated bass.dll v2.4.15.48 the issue indeed appears to be fixed, there are no zombie foobar2000 processes to be found anymore.

Many thanks for identifying and fixing the issue. :)