projectM-visualizer / projectm

projectM - Cross-platform Music Visualization Library. Open-source and Milkdrop-compatible.
https://discord.gg/mMrxAqaa3W
GNU Lesser General Public License v2.1
3.28k stars 371 forks source link

ProjectM/Kodi SIGSEGVs with Unknown Presets #410

Closed stevenswart closed 1 year ago

stevenswart commented 4 years ago

22nd of August 2020

I am reporting four separate issues I am experiencing with ProjectM. I started having problems when I installed the massive community preset pack available on the ProjectM GitHub home page. Previously, I was not experiencing any problems. It seems that there are certain presets in there that cause problems. In some cases, I was able to determine a few of these that were causing problems, and reproduce the errors. In other cases, I was not able to do so.

This is the fourth of these issues – unknown presets that causes ProjectM to SIGSEGV. This report is actually two problems, the backtraces look different, and so they probably have different causes. I am not sure how to reproduce these problems; these were crashes that came up while I was testing. The short way would be to install the community presets and run Kodi/ProjectM under a debugger until they happen, but I don’t know how you would then tell which presets cause the problems. The long way would be to test all of the community presets manually, one by one, until you reproduce the problems, but that would be exceeding painful. Nevertheless, I am reporting these here for the sake of completeness.

I did some fairly extensive investigations into these problems in June this year, and was able to get as far as discovering that there are four separate issues, according to backtraces that I obtained with GDB.

My use case is that I consider myself to be a Kodi power user. I use Kodi to play music on my media server most of the time that I am home. I have the ProjectM addon installed for Kodi, and I love it. I only use the ProjectM PulseAudio executable when, for example, I am streaming music via a browser. But I was able to determine that these problems originate in the ProjectM library itself, not within Kodi, and they seem to affect both Kodi with the ProjectM visualiser installed, as well as the ProjectM PulseAudio executable.

The problems fall into two classes, crashes (three problems found), and freezes/deadlocks (one problem found). As of this writing, with the latest available software, both these problems still exist.

I love the new presets I have installed, and even though I installed them over two months ago, I am still surprised by the occasional preset that I have never seen before. I have been collecting presets for a long time now, but some of the presets in the community pack are stunning!

Nevertheless, it is annoying when my music occasionally stops and I have to kill/restart Kodi and try to figure out where it was before it crashed. Most annoying when I am listening to DJ sets of an hour or longer!

Kodi reports that I now have 40585 presets installed, so, as you can imagine, it would be an extremely painful exercise for me to manually test every single preset individually and remove the ones that cause problems, certainly, I don’t have that kind of time to spend. Also, I imagine that all of these presets used to work at some point in the Milkdrop/ProjectM lifecycle, and ideally, this should be fixed inside the ProjectM library itself, or in cases where there is a bad preset that does not parse, the exception it causes should be handled, and ProjectM should simply move on to the next preset, possibly adding the faulty preset to some kind of banned list. That would be a far more robust way of handling the problem, to my mind.

Hardware:

My media server is based on an HP Proliant MicroServer, Gen10 (WW Entry BTO Model), specs here:

https://h20195.www2.hpe.com/v2/GetDocument.aspx?docname=a00008701enw&doctype=quickspecs&doclang=EN_US&searchquery=&cc=us&lc=en

Briefly, the hardware is as follows:

CPU: AMD Opteron(TM) X3216 APU - Dual-core, x86_64 Memory-Main Memory-phys_mem: 8053063680 Monitor: LG TV Network Cards: NC332i Adapter x2, RTL8192EE PCIe Wireless Network Adapter Graphics Card: ATI Radeon R5 Graphics Sound Card: Kabini HDMI/DP Audio (built into graphics card).

The hardware info as reported by YaST may be found here:

https://paste.kodi.tv/lilaqabiqe.kodi

Sample Xorg.0.log may be found here:

https://paste.kodi.tv/serijohada

I am experiencing this problem on OpenSUSE Tumbleweed, latest version, updated today (22nd of August 2020), with Kodi Leia 18.8, installed from the packman repo. (Tumbleweed is OpenSUSE’s rolling release.)

However, I don’t think this is a problem with either the hardware or the operating system.

Backtrace 1 – ProjectM:

https://paste.kodi.tv/bazeticeni

Backtrace 2 – Kodi:

https://paste.kodi.tv/lexuwexeco.kodi

Kodi crashlog:

https://paste.kodi.tv/jafiyeliqa.kodi

stevenswart commented 3 years ago

2nd of November 2020

It looks like the internals have changed, but while I was testing two weekends ago, I picked up another segfault, the backtrace looks similar to the one I posted before. See attached Kodi.Crash2.backtrace.txt.

Kodi.Crash2.backtrace.txt

stevenswart commented 3 years ago

6th November 2020

I have been using the following methodology for the past few days:

In this manner, I hope to eventually remove all of the presets that cause problems from my preset collection.

I have only been doing this for a few days now, I will try to give a more complete report back later.

In the mean time, please see the attached segfault.presets.zip. This contains three presets that all cause segfaults. I don't know if they all have the same cause, but it should allow you to reproduce the problem(s).

segfault.presets.zip

revmischa commented 3 years ago

118

stevenswart commented 3 years ago

About a month ago, I started moving problem presets out of my preset working folder. I am uploading my latest collection of segfaulting presets here. All of these cause segfaults. Please see attached segfault.presets2.zip.

I am also going to list the filenames below, for anyone else who has the Community Preset Pack installed. This list is probably not complete, and I will probably update it later. Due to the random nature of the preset selection, ProjectM may run for months or years without ever loading a problem preset. But for now, this should solve a big part of the problem.

@AdamFX Effected Fourm Preset Artist - Martin - Rova - Flexi - Eos - Phat - AkashaDude - Orb - You know your FX'z - MilkDownFallHorizon S.milk
Cope - Inferno.milk
Flexi - spirally.milk
Starz in MilkHDFX - Stahlregen & Aderrasi + Eo.S + Geiss + Unchained + Zylot + Flexi + Martin + AdamFX Z.milk
amandio c - small life (goes disco).milk
enforced word wrap.milk
gastly - Soft Flames.milk
suksma + flexi geiss rovastar roosta demonld shifter - dr horicon willn't ignore her then dr qlubphoot.milk
suksma - ed geining hateops - flx matilda roam3-2.milk
suksma - missing that fresh feeling.milk
xtramartin (98).milk

segfault.presets2.zip

revmischa commented 3 years ago

It looks to me like some of these segfaults are connected to using custom shapes and a number of samples that is not a power of two. I'm not quite clear on what the best fix is.

[Preset] loading file "/home/cyber/dev/projectm/segfault/amandio c - small life (goes disco).milk"...
INFO: Displaying preset: amandio c - small life (goes disco).milk
Process 100944 stopped
* thread #1, name = 'projectMSDL', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
    frame #0: 0x0000555555659565 projectMSDL`TreeExprAdd::eval(this=0x000055555630f980, mesh_i=1514, mesh_j=-1) at Expr.cpp:738:41
   735           TreeExpr( Eval::infix_add, nullptr, _left, _right) {}
   736      float eval( int mesh_i, int mesh_j)
   737      {
-> 738          return left->eval(mesh_i, mesh_j) + right->eval(mesh_i, mesh_j);
   739      }
   740  #if HAVE_LLVM
   741      llvm::Value *_llvm(JitContext &jitx) override
(lldb) bt
* thread #1, name = 'projectMSDL', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
  * frame #0: 0x0000555555659565 projectMSDL`TreeExprAdd::eval(this=0x000055555630f980, mesh_i=1514, mesh_j=-1) at Expr.cpp:738:41
    frame #1: 0x00005555556599c4 projectMSDL`AssignMatrixExpr::eval(this=0x00005555562e55b0, mesh_i=1514, mesh_j=-1) at Expr.cpp:964:28
    frame #2: 0x0000555555659ca0 projectMSDL`ProgramExpr::eval(this=0x000055555664dc40, mesh_i=1514, mesh_j=-1) at Expr.cpp:1029:28
    frame #3: 0x000055555567d50d projectMSDL`CustomWave::PerPoint(this=0x000055555635d160, p=(x = 6.86636248E-44, y = 0, r = 1.13505176E-43, g = 0, b = 1.40129846E-45, a = 7.00649232E-45), context=const WaveformContext @ 0x00007fffffffd1a8) at CustomWave.cpp:530:28
    frame #4: 0x000055555567f8ad projectMSDL`Waveform::Draw(this=0x000055555635d160, context=0x0000555555a80118) at Waveform.cpp:73:45
    frame #5: 0x00005555555a634e projectMSDL`Renderer::RenderItems(this=0x0000555555a7ff90, pipeline=0x00005555563188b0, pipelineContext=0x000055555586f590) at Renderer.cpp:377:16
    frame #6: 0x00005555555a68c7 projectMSDL`Renderer::RenderFrameOnlyPass1(this=0x0000555555a7ff90, pipeline=0x00005555563188b0, pipelineContext=0x000055555586f590) at Renderer.cpp:476:13
    frame #7: 0x000055555558c731 projectMSDL`projectM::renderFrameOnlyPass1(this=0x00005555557fe9a0, pPipeline=0x00007fffffffd7d0) at projectM.cpp:438:40
    frame #8: 0x000055555558bfb6 projectMSDL`projectM::renderFrame(this=0x00005555557fe9a0) at projectM.cpp:322:41
    frame #9: 0x000055555556b895 projectMSDL`projectMSDL::renderFrame(this=0x00005555557fe9a0) at pmSDL.cpp:558:26
    frame #10: 0x0000555555571e72 projectMSDL`main(argc=1, argv=0x00007fffffffdef8) at projectM_SDL_main.cpp:499:25
    frame #11: 0x00007ffff7873cb2 libc.so.6`__libc_start_main(main=(projectMSDL`main at projectM_SDL_main.cpp:145:34), argc=1, argv=0x00007fffffffdef8, init=<unavailable>, fini=<unavailable>, rtld_fini=<unavailable>, stack_end=0x00007fffffffdee8) at libc-start.c:314:16
    frame #12: 0x0000555555569bee projectMSDL`_start + 46
labkey-matthewb commented 3 years ago

I'll take a look.

labkey-matthewb commented 3 years ago

Can someone provide a link to "amandio c - small life (goes disco).milk"

revmischa commented 3 years ago

It's the zip file posted above - https://github.com/projectM-visualizer/projectm/files/5611756/segfault.presets2.zip

labkey-matthewb commented 3 years ago

I think the problem is that

I think a simple fix would be something like this at the top of Waveform::Draw size_t samples = std::min(this->points.size(),this->samples);

revmischa commented 3 years ago

Could be a fix for that particular crash I posted yeah. I was able to get a number of crashes including in the FFT code, I think my fix helped with that? There may be a few things broken

labkey-matthewb commented 3 years ago

I think this may account for a lot of problems. In addition to asking for unexpected amounts of data from PCM. This is trashing random memory. Probably accounts for a variety of segfaults.

stevenswart commented 3 years ago

Good day, all!

Thank you for looking into this issue.

I have continued removing segfaulting presets. Please see attached Crashes.Segfault.4.zip.

My latest list is:

27_super_goats - mandelbrot - mandelawrot pan fried nz+.milk
27_super_goats - mandelbrot.milk
3D function draw template [flexi's learning by doing session 04].milk
@AdamFX Effected Fourm Preset Artist - Martin - Rova - Flexi - Eos - Phat - AkashaDude - Orb - You know your FX'z - MilkDownFallHorizon S.milk
A New Begining With Martin - acid wiring (RewiredFX)Ft AdamFX - Hexcollie - Armandio C - Geiss - Restructured DropDown D hog rot.milk
AdamFX n Martin Collide - Martin  - alien grand theft water G.milk
Aderrasi - Airhandler (NEOhm's DarkNeon Vortex -Figure8- Mix) - orb rt n777.milk
Anandamide - Android's Demise - species pay2.milk
Chemlock - Fire Iris - thanks to flexi, my life is good - blotch quicksilver dump.milk
Cope - Inferno.milk
Cope - Keanu Reeves Is A Bad Actor.milk
Cope - domains - phamily zhuhlc - vroom.milk
Cope - fractal explorer x.milk
Flexi + fiShbRaiN - operation fatcap [techstyle] [random mashup].milk
Flexi - rorschach bomb.milk
Flexi - spirally repetative 2.milk
Flexi - spirally.milk
Flexi, Stahlregen + Rovastar - layered gelatine fractopia + CatalystTheElder cpe mck roams.milk
ORB - 3 Pointed Flame.milk
ORB - Fract 2.milk
ORB - Sthal - Sunny Skies.milk
RLP + Geiss - Shake (VIOLENTLY - Shaken up Bleach Textures).milk
Rovastar - Genetic Disaster ultra-ky lard.milk
Setting New HDFX Trends -  Amandio c - small life (goes disco) ft AdamFx n Geiss .milk
Setting New HDFX Trends -  Amandio c - small life (goes disco) ft AdamFx n Geiss B.milk
Setting New HDFX Trends -  Amandio c - small life (goes disco) ft AdamFx n Geiss C.milk
Shifter - Thousand monkeys v2.1 nz+ aligned with qrooked.milk
Shifter - Thousand monkeys v2.1 nz+ what only certain modes of development can achieve.milk
Starz in MilkHDFX - Stahlregen & Aderrasi + Eo.S + Geiss + Unchained + Zylot + Flexi + Martin + AdamFX Z.milk
_geiss_experimental__Spiral Artifact (Filament Mix) - voronoi circles mix.milk
aic - mithrillogic.milk
amandio c - small life (goes disco).milk
amandio c, flexi - Planet escher - random2 nz+ re-divisible with slavery and amorality for a brave faction.milk
amandio c, flexi, martin - Op illusions - curved4.milk
barometric lensing outre.milk
cope + flexi - mother-of-whirl [mr understatement] - do ya kennitt.milk
cope + martin - silicon life - 777 3 totality of phuqunt.milk
cope - mandelbrot (32 iterations) - friggingdelic.milk
cpe domains flacc - rt roam.milk
cpe domains flacc - rt.milk
each mash path a rat mad well through face dump nz.milk
enforced word wrap.milk
fiShbRaiN + Flexi - witchcraft unleashed [00 the template] + shifter - turing tape - chompski grammatdron.milk
flexi + cope + martin - blue marble (specular version) - oil nz.milk
gastly - Soft Flames.milk
hooked into by sea life embroiled in the psychology of a madwoman.milk
martin - flexi - polynomial rheotomic in mandelbox code - diag side ungroup.milk
martin - fresco flash - defering metabolit.milk
martin - mandelbox explorer v1 nz+15.milk
martin - on silent paths.milk
martin - time machine - teflon love potion nz.milk
no rules, no judgement, only hate.milk
penile wrap twist fold and starch dump rep.milk
penile wrap twist fold and starch prepackaged dentritic anomolice.milk
post-anaphylactic wormhowl.milk
shifter - smoked glass - cpe mck roams nz+.milk
stahlregen + flexi + martin + fed - acid thunderstorm.milk
stickle feifer.milk
suksma + flexi geiss rovastar roosta demonld shifter - dr horicon willn't ignore her then - flx chr schistiq phlyblownsys insane artistically immoral.milk
suksma + flexi geiss rovastar roosta demonld shifter - dr horicon willn't ignore her then - lexicolon nz+2 thee anti-aesthete pin thee tale own thee .milk
suksma + flexi geiss rovastar roosta demonld shifter - dr horicon willn't ignore her then dr qlubphoot.milk
suksma - 3125 legislative pig's orbitael minimass - cope vs goat vs akuksma.milk
suksma - asiduit klonopin bastardent.milk
suksma - bonnie self.milk
suksma - clouded                        - 35mmqraephd roams.milk
suksma - clouded                       (1).milk
suksma - clouded                   .milk
suksma - clouded                .milk
suksma - clouded         .milk
suksma - clouded         roam3 dual.milk
suksma - clouded        (1).milk
suksma - ed geining hateops - flx matilda roam3-2.milk
suksma - fiShbRaiN - white sceam firefly + goody itpw - amber honey whoresflies.milk
suksma - fiShbRaiN - white sceam firefly + martin - pissDittyPickKombz vs praxis metatron.milk
suksma - flaming bag of wisconsin.milk
suksma - flexi 27goats digital-art.org - scathing review2 slobbering hot vessel cadavar juicy fruit.milk
suksma - g-martin m-flexi w-zylot wp-xxx c-m - leviawheatthin cracker sporadicyst no vectors - ye oaerbs tu maerror.milk
suksma - gratuitous evilizing of nitoramix - closer to eternal slavery.milk
suksma - irritants for strong men(1).milk
suksma - katatonic crone on fatalist eschatonal trudge23.milk
suksma - missing that fresh feeling.milk
suksma - my throat be a wellspring of blood - outrae eschaton skies.milk
suksma - outre seepia sweyy lurk memephetase (2).milk
suksma - phatal wheels raze archivingtillion souls (2).milk
suksma - seminar on how to die insane.milk
suksma - shiny-bladed homicide machine at dusk - quantum liquid beads riding cosmic strings.milk
suksma - spectro experiment 333 2 shifter orb.milk
suksma - spectro experiment 333 3 - pantera - hollow.milk
suksma - spectro experiment 666 + 27g + shf + rrn.milk
suksma - volcan dome.milk
suksma - water cooled red uranium vs dotes - two levels down the bergelev.milk
suksma - waterboard god + rape.milk
suksma - waves of hair it crashes.milk
suksma - xenakis visuals - phone weapon nz+ flesh melting sinistralia.milk
suksma - zgk - onerous clement - eye land.milk
technothrob holotorics - mrt sky pupae.milk
wave goodbye, too late.milk
xtramartin (100).milk
xtramartin (143).milk
xtramartin (192).milk
xtramartin (193).milk
xtramartin (261).milk
xtramartin (262).milk
xtramartin (31).milk
xtramartin (341).milk
xtramartin (403).milk
xtramartin (583).milk
xtramartin (728).milk
xtramartin (763).milk
xtramartin (94).milk
xtramartin (98).milk

Crashes.Segfault.4.zip

kblaschke commented 1 year ago

The crashes are most probably fixed in current libprojectM's master. Only in the case that the OpenGL context is not properly configured for the render thread it may crash, but that would happen every time, not only for certain presets.

Since the issue affects an external project, I'd suggest to re-test the problems and if they still exist, opening a new issue in the Kodi projectM plug-in issue tracker. If the new projectM API is finished, we'll drop the plug-in authors a note so they can port the code to the new release, which should in every aspect work better than the old one.

If the problem persists after the 4.0 release and the updated Kodi plug-in, please feel free to create a new issue here (or reopen this one with new information).