Snapcast: Snapserver causing zombie processes

Created on 18 Jan 2020  路  4Comments  路  Source: badaix/snapcast

I recently moved my snapserver from a raspberry to a pc and now it seems that snapserver is causing zombie processes:

# snapserver -v
snapserver v0.17.1
Copyright (C) 2014-2019 BadAix ([email protected]).
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Johannes Pohl.
# ps axo stat,ppid,pid,comm | grep -w defunct
Z     7904  7930 sh <defunct>
Z     7904 11129 sh <defunct>
Z     7904 12809 sh <defunct>
Z     7904 14367 sh <defunct>
Z     7904 15915 sh <defunct>
Z     7904 18380 sh <defunct>
Z     7904 19989 sh <defunct>
Z     7904 21514 sh <defunct>
Z     7904 23454 sh <defunct>
# ps axo stat,ppid,pid,comm | grep snapserver
Ssl      1  7904 snapserver

I'm using librespot as well and I'm not sure if it is librespot or snapcast that is causing this. Any ideas how to check further?

Here is my snapserver.conf:

# cat /etc/snapserver.conf 
###############################################################################
#     ______                                                                  #
#    / _____)                                                                 #
#   ( (____   ____   _____  ____    ___  _____   ____  _   _  _____   ____    #
#    \____ \ |  _ \ (____ ||  _ \  /___)| ___ | / ___)| | | || ___ | / ___)   #
#    _____) )| | | |/ ___ || |_| ||___ || ____|| |     \ V / | ____|| |       #
#   (______/ |_| |_|\_____||  __/ (___/ |_____)|_|      \_/  |_____)|_|       #
#                          |_|                                                #
#                                                                             #
#  Snapserver config file                                                     #
#                                                                             #
###############################################################################

# default values are commented
# uncomment and edit to change them


# HTTP RPC ####################################################################
#
[http]
# enable HTTP Json RPC (HTTP POST and websockets)
#enabled = true

# address to listen on, can be specified multiple times
# use "0.0.0.0" to bind to any IPv4 address or :: to bind to any IPv6 address
# or "127.0.0.1" or "::1" to bind to localhost IPv4 or IPv6, respectively
# use the address of a specific network interface to just listen to and accept
# connections from that interface
#bind_to_address = 0.0.0.0

# which port the server should listen to
#port = 1780

# serve a website from the doc_root location
#doc_root = 
#
###############################################################################


# TCP RPC #####################################################################
#
[tcp]
# enable TCP Json RPC
#enabled = true

# address to listen on, can be specified multiple times
# use "0.0.0.0" to bind to any IPv4 address or :: to bind to any IPv6 address
# or "127.0.0.1" or "::1" to bind to localhost IPv4 or IPv6, respectively
# use the address of a specific network interface to just listen to and accept
# connections from that interface
#bind_to_address = 0.0.0.0

# which port the server should listen to
#port = 1705
#
###############################################################################


# Stream settings #############################################################
#
[stream]
# address to listen on, can be specified multiple times
# use "0.0.0.0" to bind to any IPv4 address or :: to bind to any IPv6 address
# or "127.0.0.1" or "::1" to bind to localhost IPv4 or IPv6, respectively
# use the address of a specific network interface to just listen to and accept
# connections from that interface
#bind_to_address = 0.0.0.0

# which port the server should listen to
#port = 1704

# stream URI of the PCM input stream, can be configured multiple times
# Format: TYPE://host/path?name=NAME[&codec=CODEC][&sampleformat=SAMPLEFORMAT] 
#stream = pipe:///tmp/snapfifo?name=default
stream = spotify:///librespot?name=Spotify&devicename=Snapcast&bitrate=320&volume=45&enable-volume-normalisation&cache=/tmp/&linear-volume&normalisation-pregain=3&backend=alsa 
stream = pipe:///tmp/snapfifo?name=snapfifo&sampleformat=48000:16:2&codec=opus

# Default sample format
#sampleformat = 48000:16:2

# Default transport codec
# (flac|ogg|opus|pcm)[:options]
# Type codec:? to get codec specific options
#codec = flac

# Default stream read buffer [ms]
#stream_buffer = 20

# Buffer [ms]
#buffer = 1000

# Send audio to muted clients
#send_to_muted = false
#
###############################################################################


# Logging options #############################################################
#
[logging]

# enable debug logging
#debug = false

# log file name for the debug logs (debug must be enabled)
#debug_logfile = 
#
###############################################################################

Most helpful comment

It's Snapcast causing this: Librespot is started in a shell and it seems that Snapserver's watchdog process is killing librespot's parent shell from time to time.
In Snapcast v0.18 all streams are (will be) refactored to use less threads and the ProcessStream from which also librespot inherits, uses boost process instead of my hand crafted process lib. I have it running for a couple of weeks now, and there are now more zombie processes. Also the watchdog logic has been changed, so that librespot will no longer be killed, although it's still "vital". (when I've added librespot support some 3.5 years ago, librespot was not that mature and stable as it is nowadays).
So if you're curious, please build and test the develop branch. It's running stable for me (PipeStream with MPD and Librespot stream), but I want to be sure that there are no regressions introduced with the refactoring.

All 4 comments

It's Snapcast causing this: Librespot is started in a shell and it seems that Snapserver's watchdog process is killing librespot's parent shell from time to time.
In Snapcast v0.18 all streams are (will be) refactored to use less threads and the ProcessStream from which also librespot inherits, uses boost process instead of my hand crafted process lib. I have it running for a couple of weeks now, and there are now more zombie processes. Also the watchdog logic has been changed, so that librespot will no longer be killed, although it's still "vital". (when I've added librespot support some 3.5 years ago, librespot was not that mature and stable as it is nowadays).
So if you're curious, please build and test the develop branch. It's running stable for me (PipeStream with MPD and Librespot stream), but I want to be sure that there are no regressions introduced with the refactoring.

Thanks for explaining and fixing this issue!

I wanted to build the server myself and try but getting the error about boost headers missing. Besides apt install libboost-all-dev is there anything else that is needed?

control_session_http.hpp:23:10: fatal error: boost/beast/core.hpp: Datei oder Verzeichnis nicht gefunden
 #include <boost/beast/core.hpp>
          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

You need boost 1.70 or higher. The good new is that you don't need to install boost, just download a recent version and let the build system point to it, as described here:

Snapcast depends on boost 1.70 or higher. Since it depends on header only boost libs, boost does not need to be installed, but the boost include path must be set properly: download and extract the latest boost version and add the include path, e.g. calling make with prepended ADD_CFLAGS: ADD_CFLAGS="-I/path/to/boost_1_7x_0/" make.
For cmake you must add the path to the -DBOOST_ROOT flag: cmake -DBOOST_ROOT=/path/to/boost_1_7x_0

I tested the develop branch for some days now and snapserver didn't produce any zombie processes. Thanks!

Was this page helpful?
0 / 5 - 0 ratings