xibosignage / xibo-linux

Xibo for Linux - Digital Signage Player
https://xibo.org.uk/xibo-for-linux
GNU Affero General Public License v3.0
76 stars 54 forks source link

xibo-player occasional crash while downloading files #256

Closed dmitttri closed 2 years ago

dmitttri commented 2 years ago

While performing requiested file download, xibo-player may crash with "Segmentation Fault" or "douible free or corruption"

It happens occasionaly, and is not easy repeateble. To reproduce it, I've made a procedure to manually delete cached contents, remove cacheFile.xml and schedule.xml, then start xibo-player without watchdog, just to print logs to stdout. This way xibo-player is forced to request all cache files again form CMS. Sometimes we can observe segfaults, but most of the time download process goes fine.

Log sample: [08:58:42.149] [28723] [debug]: [XMDS::RequiredFiles] Received [08:58:47.513] [28762] [debug]: [jquery-1.11.1.min.js] Downloaded [08:58:47.520] [28764] [debug]: [18.otf] Downloaded [08:58:47.520] [28763] [debug]: [368.html] Downloaded [08:58:47.521] [28765] [debug]: [369.html] Downloaded [08:58:52.849] [28791] [debug]: [16.ttf] Downloaded [08:58:52.878] [28792] [debug]: [14.otf] Downloaded [08:58:52.885] [28793] [debug]: [xibo-countdown-render.js] Downloaded [08:58:52.920] [28794] [debug]: [jquery-cycle-2.1.6.min.js] Downloaded Segmentation fault

I seems we can trigger segfaults more often with CMS layouts which has lot of small files.

dmitttri commented 2 years ago

Further investigation shows that downloader threads will concurrently access FileCache_ object, more particular it's save() method, which saves files and updates cache. In particular, updating file cache was causing this issue.

I made a fix for this problem, by adding a mutex in the FileCacheImpl class, and ensure addToCache method uses it to protect file cache access.

For this fix I have submitted a pull request #255

dasgarner commented 2 years ago

That's awesome thank you. I've merged that in and an AppImage should be building soon.

We're having some issues with our snap build environment (#253), but once those are fixed i'll push something up to beta with your fix included.

dmitttri commented 2 years ago

Thanks for your kind words, I am happy I could controbute to your awsome project.