Shirakumo / harmony

A Common Lisp sound system
https://shirakumo.github.io/harmony
zlib License
55 stars 6 forks source link

Random crash with SBCL GC (probably cl-mixed bug) #22

Open AkashaP opened 2 years ago

AkashaP commented 2 years ago

Hello. I am getting a random crash playing a few sound files as MP3s in harmony. Stack trace mentions cl-mixed.

tested with latest versions: harmony commit [cc92624] mixed commit [72cfd9b]

rough steps:

  1. Use steps in #20 , that is:
    (ql:quickload :harmony)
    (org.shirakumo.fraf.harmony:start (org.shirakumo.fraf.harmony:make-simple-server))
    (org.shirakumo.fraf.harmony:play #p"some-file.mp3") ...
  2. play a few sound files (like maybe 20 times over spamming sound effects)
  3. go afk for 10 minutes (not playing sounds or anything)
  4. program randomly crashes. No restarts offered - the whole SBCL process completely self destructs

if i missed something please let me know

Stack trace (visible only in the sly-inferior-lisp for sbcl buffer):

Shinmera commented 2 years ago

what does "SBCL optimized debug 3, safety 3, speed 0, space 0" mean? What OS is this?

AkashaP commented 2 years ago

linux, kubuntu 5.13.0-35-generic those flags means that in .sbclrc there are these lines:

(sb-ext:restrict-compiler-policy 'debug 3 3)
(sb-ext:restrict-compiler-policy 'safety 3 3)
(sb-ext:restrict-compiler-policy 'speed 0 0)
(sb-ext:restrict-compiler-policy 'space 0 0) 
(sb-ext:restrict-compiler-policy 'compilation-speed 0 0)

Following Optimize from the CLHS: http://www.lispworks.com/documentation/lw50/CLHS/Body/d_optimi.htm

useful for getting maximum debug output available.

Shinmera commented 2 years ago

Aha. What happens if you remove those restrictions and recompile all involved systems?

AkashaP commented 2 years ago

i think this has stopped the crashing, i've been sitting it for a few minutes playing some sounds occasionally, then initiated (gc), and it still hasn't crashed

to be fair, i think my configuration is pretty extreme. It is even bugging out cl-ppre. I might need to adjust the values.

AkashaP commented 2 years ago

actually, it just crashed. i think alt tabbing and stuff might be contributing to the frequency of crashes but i am not sure

i wouldn't be surprised if this was some obscure incompatibility involved with a bunch of libraries i am using in conjuction, specifically cl-bodge which i have been hacking around in which uses a lot of cffi

Shinmera commented 2 years ago

Alt-tabbing shouldn't influence anything at all.

However, please do try to test with a clean image. I cannot vouch for stuff that does whatever else in the back.

The error is pointing towards a kludge in harmony being tripped -- to avoid stalling the audio thread too badly it has to inhibit GCing and hit specific trigger points. I don't know what could be interfering with that however, and have not personally had any crashes like that even after running the same image for many hours at a time, and running an entire game for many hours, as well.

AkashaP commented 2 years ago

alright, i'll do this and work towards pinpointing this problem. thank you for the insights.

Shinmera commented 2 years ago

Sure. Sorry I can't be of more help at the moment. Getting to the bottom of stuff like this is a nightmare, so best of luck!

AkashaP commented 2 years ago

i never found the problem but i have sketched a (really over engineered...) workaround: separate harmony into its own executable and control it over IPC.

i included a bunch of features like different ways of killing the separate program when the main program closes or crashes (didn't fully test), process revival in case harmony crashed, but since i did this i haven't had either harmony or my application crash, so i guess it counts as some form of solution?

https://gitlab.com/akashadutchie/euphony-harmony

Shinmera commented 2 years ago

Wow, that's quite the workaround.