FS#33036 - [alsa-utils] the rc.d service script does not parse detected sound cards correctly

Attached to Project: Arch Linux
Opened by Adam Delman (flyn) - Monday, 10 December 2012, 23:38 GMT
Last edited by Tobias Powalowski (tpowa) - Tuesday, 26 February 2013, 11:56 GMT
Task Type Bug Report
Category Upstream Bugs
Status Closed
Assigned To Tobias Powalowski (tpowa)
Architecture All
Severity High
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

In the extra/alsa-utils package the alsa rc.d service script contains a bug that prevents ALSA from properly parsing all the sound cards detected by the kernel. This bug is caused by incorrect use of the ls command.

In effect, this prevents the script from killing all the processes blocking the sound cards and so it does not complete the restart process properly.

Example of the error on my system:

The problem starts when the ls output reaches the /dev/snd/by-path folder (see the end of the bug report for the entire output of the script):

/dev/snd/by-path:
pci-0000:00:1b.0
pci-0000:05:01.0

The path for these two devices is incomplete, and the folder they are contained is suffixed with a colon.

As a temporary workaround on my system, I have changed the following line in the alsa rc.d service script from this:

FILES="$(ls -1 /dev/snd/* | grep -vi control)"

to this:

FILES="$(ls -1 /dev/snd/* | grep -vi control | sed 's/^\/dev\/snd\/by\-path://g'| sed 's/^\(pci-0000.*\)/\/dev\/snd\/by\-path\/\1/g')"


Output of the unmodified script on my system:

===================================================

[adam@adam-desktop rc.d]$ sudo bash -x /etc/rc.d/alsa force-restart
+ . /etc/rc.conf
++ DAEMONS=()
+ . /etc/conf.d/alsa
++ ALSA_ARGS='--file /var/lib/alsa/asound.state'
++ POWERSAVE=0
++ SAVE_VOLUME=yes
++ MUTE_VOLUME=no
+ . /etc/rc.d/functions
++ export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ unset TZ
++ . /etc/profile.d/locale.sh
+++ unset LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION
+++ '[' -n '' ']'
+++ '[' -n /root ']'
+++ '[' -r /root/.config/locale.conf ']'
+++ '[' -r /etc/locale.conf ']'
+++ . /etc/locale.conf
++++ LANG=en_US.utf8
+++ export LANG=en_US.utf8
+++ LANG=en_US.utf8
+++ '[' -n '' ']'
+++ '[' -n '' ']'
+++ '[' -n '' ']'
+++ '[' -n '' ']'
+++ '[' -n '' ']'
+++ '[' -n '' ']'
+++ '[' -n '' ']'
+++ '[' -n '' ']'
+++ '[' -n '' ']'
+++ '[' -n '' ']'
+++ '[' -n '' ']'
+++ '[' -n '' ']'
++ [[ force-restart == \s\t\a\r\t ]]
++ calc_columns
++ STAT_COL=80
++ [[ ! -t 1 ]]
++ [[ -t 0 ]]
+++ stty size
++ STAT_COL='42 114'
++ STAT_COL=114
++ (( STAT_COL == 0 ))
++ STAT_COL=101
++ [[ -t 1 ]]
++ SAVE_POSITION='\e[s'
++ RESTORE_POSITION='\e[u'
++ DEL_TEXT='\e[105G'
+++ tput colors
++ TERM_COLORS=8
++ (( 0 != 3 ))
++ case $TERM_COLORS in
++ unset TERM_COLORS
++ declare -a omit_pids
++ NETFS=nfs,nfs4,smbfs,cifs,codafs,ncpfs,shfs,fuse,fuseblk,glusterfs,davfs,fuse.glusterfs
++ (( RC_FUNCTIONS_HOOK_FUNCS_DEFINED != 1 ))
++ declare -A hook_funcs
++ declare -fr add_hook run_hook
++ declare -r RC_FUNCTIONS_HOOK_FUNCS_DEFINED=1
++ [[ '' != [nN][oO] ]]
++ tput setaf 0
+++ tput sgr0
++ C_CLEAR=''
+++ tput bold
++ C_MAIN=''
+++ tput setaf 4
++ C_OTHER=''
+++ tput setaf 0
++ C_SEPARATOR=''
+++ tput setaf 6
++ C_BUSY=''
+++ tput setaf 1
++ C_FAIL=''
++ C_DONE=''
+++ tput setaf 5
++ C_BKGD=''
++ C_H1=''
+++ tput setaf 6
++ C_H2=''
++ PREFIX_REG=::
++ PREFIX_HL=' >'
++ for f in '/etc/rc.d/functions.d/*'
++ [[ -e /etc/rc.d/functions.d/net-set-variable ]]
++ . /etc/rc.d/functions.d/net-set-variable
+++ add_hook multi_start net_set_variable
+++ [[ -n multi_start ]]
+++ [[ -n net_set_variable ]]
+++ hook_funcs[$1]+=' net_set_variable'
++ for f in '/etc/rc.d/functions.d/*'
++ [[ -e /etc/rc.d/functions.d/sshd-close-sessions ]]
++ . /etc/rc.d/functions.d/sshd-close-sessions
+++ add_hook shutdown_start sshd_close_sessions
+++ [[ -n shutdown_start ]]
+++ [[ -n sshd_close_sessions ]]
+++ hook_funcs[$1]+=' sshd_close_sessions'
+ case "$1" in
+ stat_busy 'Trying to TERM or KILL processes that are blocking ALSA...'
+ printf ':: Trying to TERM or KILL processes that are blocking ALSA... '
:: Trying to TERM or KILL processes that are blocking ALSA... + printf '\e[s'
+ deltext
+ printf '\e[105G'
+ printf ' [BUSY] '
[BUSY] ++ ls -1 /dev/snd/by-path /dev/snd/controlC0 /dev/snd/controlC1 /dev/snd/hwC0D2 /dev/snd/hwC1D0 /dev/snd/hwC1D2 /dev/snd/midiC1D0 /dev/snd/midiC1D1 /dev/snd/midiC1D2 /dev/snd/midiC1D3 /dev/snd/pcmC0D0c /dev/snd/pcmC0D0p /dev/snd/pcmC0D1c /dev/snd/pcmC0D1p /dev/snd/pcmC0D2c /dev/snd/pcmC1D0c /dev/snd/pcmC1D0p /dev/snd/pcmC1D1c /dev/snd/pcmC1D2c /dev/snd/pcmC1D2p /dev/snd/pcmC1D3p /dev/snd/pcmC1D4c /dev/snd/pcmC1D4p /dev/snd/seq /dev/snd/timer
++ grep -vi control
+ FILES='/dev/snd/hwC0D2
/dev/snd/hwC1D0
/dev/snd/hwC1D2
/dev/snd/midiC1D0
/dev/snd/midiC1D1
/dev/snd/midiC1D2
/dev/snd/midiC1D3
/dev/snd/pcmC0D0c
/dev/snd/pcmC0D0p
/dev/snd/pcmC0D1c
/dev/snd/pcmC0D1p
/dev/snd/pcmC0D2c
/dev/snd/pcmC1D0c
/dev/snd/pcmC1D0p
/dev/snd/pcmC1D1c
/dev/snd/pcmC1D2c
/dev/snd/pcmC1D2p
/dev/snd/pcmC1D3p
/dev/snd/pcmC1D4c
/dev/snd/pcmC1D4p
/dev/snd/seq
/dev/snd/timer

/dev/snd/by-path:
pci-0000:00:1b.0
pci-0000:05:01.0'
+ fuser -k -SIGTERM /dev/snd/hwC0D2 /dev/snd/hwC1D0 /dev/snd/hwC1D2 /dev/snd/midiC1D0 /dev/snd/midiC1D1 /dev/snd/midiC1D2 /dev/snd/midiC1D3 /dev/snd/pcmC0D0c /dev/snd/pcmC0D0p /dev/snd/pcmC0D1c /dev/snd/pcmC0D1p /dev/snd/pcmC0D2c /dev/snd/pcmC1D0c /dev/snd/pcmC1D0p /dev/snd/pcmC1D1c /dev/snd/pcmC1D2c /dev/snd/pcmC1D2p /dev/snd/pcmC1D3p /dev/snd/pcmC1D4c /dev/snd/pcmC1D4p /dev/snd/seq /dev/snd/timer /dev/snd/by-path: pci-0000:00:1b.0 pci-0000:05:01.0
Specified filename /dev/snd/by-path: does not exist.
Specified filename pci-0000:00:1b.0 does not exist.
Specified filename pci-0000:05:01.0 does not exist.
+ fuser -k /dev/snd/hwC0D2 /dev/snd/hwC1D0 /dev/snd/hwC1D2 /dev/snd/midiC1D0 /dev/snd/midiC1D1 /dev/snd/midiC1D2 /dev/snd/midiC1D3 /dev/snd/pcmC0D0c /dev/snd/pcmC0D0p /dev/snd/pcmC0D1c /dev/snd/pcmC0D1p /dev/snd/pcmC0D2c /dev/snd/pcmC1D0c /dev/snd/pcmC1D0p /dev/snd/pcmC1D1c /dev/snd/pcmC1D2c /dev/snd/pcmC1D2p /dev/snd/pcmC1D3p /dev/snd/pcmC1D4c /dev/snd/pcmC1D4p /dev/snd/seq /dev/snd/timer /dev/snd/by-path: pci-0000:00:1b.0 pci-0000:05:01.0
Specified filename /dev/snd/by-path: does not exist.
Specified filename pci-0000:00:1b.0 does not exist.
Specified filename pci-0000:05:01.0 does not exist.
+ stat_done
+ deltext
+ printf '\e[105G'
+ printf ' [DONE] \n'
[DONE]
+ /etc/rc.d/alsa restart
:: Saving ALSA Levels [DONE]
:: Restoring ALSA Levels


===================================================
This task depends upon

Closed by  Tobias Powalowski (tpowa)
Tuesday, 26 February 2013, 11:56 GMT
Reason for closing:  Won't fix
Additional comments about closing:  rc scripts are not supported anymore
Comment by Adam Delman (flyn) - Sunday, 16 December 2012, 18:49 GMT
  • Field changed: Percent Complete (100% → 0%)
One last piece of information regarding this issue: The functionality of the alsa rc.d script and the systemd service file (which calls alsactl, which does not have a force-restart option) is that the latter does not kill processes which have a lock on the sound card, it just restores the ALSA settings. Would it better to reopen this bug in the ALSA project bug tracker?
Comment by Tom Gundersen (tomegun) - Sunday, 16 December 2012, 18:51 GMT
Not sure what you are hoping to achieve? Restarting alsa causing the killing of random processes sounds iffy, so not sure if that's anything we'd want at all, but yeah, take this upstream if you want to discuss it further.

Loading...