Closing audio subsystem hangs in Linux if debugger attached

Not a showstopper by any means… but I’ve just noticed something odd.

I made my own SDL wrapper in C#. It is working great in all three operating systems. Rendering full OpenGL scenes and playing audio just fine.

I noticed recently that my program hangs upon calling SDL_CloseAudioDevice in Linux while debugging in VS Code. If I comment it out, it instead hangs on SDL_Quit, which presumably calls that same function when shutting down the audio subsystem. My default assumption is always that I goofed somewhere in my mapping code and somehow corrupted the native call, but I later noticed that everything works fine when I just run my project from console using dotnet run. So, the only difference seems to be whether a debugger is attached. I ran my project (from console) using dotnet run, attached VS Code debugger afterward, and it hung again upon closing.

I’m just wondering if there are any insights here to where I could dig into this further. Again, it’s not blocking me, but I would definitely prefer to understand why this happens and whether I can avoid it.

I have reproduced this in both EndeavourOS (Arch) and in Ubuntu. I think the Arch was running PipeWire while the Ubuntu was running PulseAudio.

(Also just reproduced it on Raspberry Pi 5 on SDL