alsactl distributed as part of Fedora 40 got a SEGV:
# journalctl
...
May 17 00:55:58 dev64.localdomain kernel: alsactl[1923]: segfault at 28 ip 00005600705b3373 sp 00007ffd9712bef0 error 4 in alsactl[5600705af000+13000] likely on CPU 5 (core 8, socket 0)
...
As the following output of the debug session, card_free() tried a card
pointing NULL:
$ sudo coredumpctl debug alsactl
PID: 1923 (alsactl)
UID: 0 (root)
GID: 0 (root)
Signal: 11 (SEGV)
Timestamp: Fri 2024-05-17 00:55:58 JST (3h 34min ago)
Command Line: /usr/sbin/alsactl -s -n 19 -c -E ALSA_CONFIG_PATH=/etc/alsa/alsactl.conf --initfile=/lib/alsa/init/00main rdaemon
Executable: /usr/sbin/alsactl
Control Group: /system.slice/alsa-state.service
Unit: alsa-state.service
Slice: system.slice
Boot ID: 241b5a2ef86f4940bb3d340583c80d88
Machine ID: 437365709a8c488c9481ee4b6651c2ec
Hostname: dev64.localdomain
Storage: /var/lib/systemd/coredump/core.alsactl.0.241b5a2ef86f4940bb3d340583c80d88.1923.1715874958000000.zst (present)
Size on Disk: 81.7K
Package: alsa-utils/1.2.11-1.fc40
build-id: 3b6fec58b3566d666d6e9fd48e8fcf04f03f0152
Message: Process 1923 (alsactl) of user 0 dumped core.
Module libasound.so.2 from rpm alsa-lib-1.2.11-2.fc40.x86_64
Module alsactl from rpm alsa-utils-1.2.11-1.fc40.x86_64
Stack trace of thread 1923:
#0 0x00005600705b3373 card_free (alsactl + 0xa373)
#1 0x00005600705c0e54 state_daemon (alsactl + 0x17e54)
#2 0x00005600705b2339 main (alsactl + 0x9339)
#3 0x00007f4c0b9b7088 __libc_start_call_main (libc.so.6 + 0x2a088)
#4 0x00007f4c0b9b714b __libc_start_main_impl (libc.so.6 + 0x2a14b)
#5 0x00005600705b2df5 _start (alsactl + 0x9df5)
ELF object binary architecture: AMD x86-64
GNU gdb (Fedora Linux) 14.2-1.fc40
Copyright (C) 2023 Free Software Foundation, Inc.
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.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/sbin/alsactl...
Reading symbols from /usr/lib/debug/usr/sbin/alsactl-1.2.11-1.fc40.x86_64.debug...
[New LWP 1923]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `/usr/sbin/alsactl -s -n 19 -c -E ALSA_CONFIG_PATH=/etc/alsa/alsactl.conf --init'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 free_list (list=0x20) at /usr/src/debug/alsa-utils-1.2.11-1.fc40.x86_64/alsactl/daemon.c:73
73 for (i = 0; i < list->size; i++)
(gdb) where
#0 free_list (list=0x20) at /usr/src/debug/alsa-utils-1.2.11-1.fc40.x86_64/alsactl/daemon.c:73
#1 card_free (card=card@entry=0x5600707455f0) at /usr/src/debug/alsa-utils-1.2.11-1.fc40.x86_64/alsactl/daemon.c:82
#2 0x00005600705c0e54 in state_daemon (file=file@entry=0x5600705c31a1 "/var/lib/alsa/asound.state", cardname=cardname@entry=0x0, period=period@entry=300,
pidfile=pidfile@entry=0x5600705c3170 "/var/run/alsactl.pid") at /usr/src/debug/alsa-utils-1.2.11-1.fc40.x86_64/alsactl/daemon.c:455
#3 0x00005600705b2339 in main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/alsa-utils-1.2.11-1.fc40.x86_64/alsactl/alsactl.c:459
(gdb) list
68
69 static void free_list(struct id_list *list)
70 {
71 int i;
72
73 for (i = 0; i < list->size; i++)
74 free(list->list[i]);
75 free(list->list);
76 }
77
(gdb) up
#1 card_free (card=card@entry=0x5600707455f0) at /usr/src/debug/alsa-utils-1.2.11-1.fc40.x86_64/alsactl/daemon.c:82
82 free_list(&c->blacklist);
(gdb) p c
$1 = (struct card *) 0x0
(gdb)
Closes: https://github.com/alsa-project/alsa-utils/pull/267
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
The 'call to sprintf' operation on line 413 requires 21 bytes
but the destination is only 16 bytes.
Fixes: https://github.com/alsa-project/alsa-utils/pull/247
Signed-off-by: Mingjie Shen <shen497@purdue.edu>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Fixes: 613372d
Fixes: cff2d1c
Compile errors when building in a subdir:
alsactl/alsactl.c:33:10: fatal error: os_compat.h: No such file or directory
33 | #include "os_compat.h"
| ^~~~~~~~~~~~~
alsactl/lock.c:34:10: fatal error: os_compat.h: No such file or directory
34 | #include "os_compat.h"
| ^~~~~~~~~~~~~
Fixes: https://github.com/alsa-project/alsa-utils/pull/213
Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
- ERESTART not supported platform: use EINTR instead
- add include/os_compat.h, well-used OS specific definition
- copied include/bswap.h from alsa-lib
- EPIPE and ESTRPIPE are different usage, but currently
EPIPE is used when ESTRPIPE is not defined.
To fix this problem, assign ESPIPE instead.
Fixes: https://github.com/alsa-project/alsa-utils/pull/186
Signed-off-by: SASANO Takayoshi <uaa@uaa.org.uk>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
It may be useful to collect the basic sound card information.
The output is in the YAML structured syntax (human and machine readable).
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Introduce the -K,--lock-dir parameter to specify the locking
directory. If the locking is active, files card<NUM>.lock
are used to serialize the multiple initialization requests
(udev, service).
Allow the relative -O,--lock-file argument (it's default now).
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
It may be useful to pipe the output to another program.
Fixes: https://github.com/alsa-project/alsa-utils/pull/109
Signed-off-by: Alex Xu (Hello71) <alex_y_xu@yahoo.ca>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
The driver may export only write-only elements. The previous
heuristics code do not handle this use case correctly.
Iterate through all elements and skip the write-only ones.
Fixes: https://github.com/alsa-project/alsa-utils/issues/122
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This patch adds --ucm-nodev (or -X) option to get those
messages back. The code works only with library 1.2.6+.
By default, these messages are suppressed:
alsactl[xxx]: alsa-lib parser.c:242:(error_node) UCM is not supported for this HDA model (HDA Intel PCH...)
alsactl[xxx]: alsa-lib main.c:1405:(snd_use_case_mgr_open) error: failed to import hw:0 use case configuration -6
Fixes: https://github.com/alsa-project/alsa-utils/issues/111
Link: https://lore.kernel.org/alsa-devel/20211027144008.27002-1-tiwai@suse.de/
Link: 23198a72cd
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Fixes:
| ../../alsa-utils-1.2.5/alsactl/utils.c: In function 'snd_card_clean_cfgdir':
| ../../alsa-utils-1.2.5/alsactl/utils.c:309:19: error: 'PATH_MAX' undeclared (first use in this function)
| 309 | char path[PATH_MAX];
| | ^~~~~~~~
| ../../alsa-utils-1.2.5/alsactl/utils.c:309:19: note: each undeclared identifier is reported only once for each function it appears in
Fixes: https://github.com/alsa-project/alsa-utils/pull/92
Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
If load_configuration fails with open_failed == true, load_state will
jump to the out label without config being initialized and pass this
uninitialized config value to snd_config_delete. This commit fixes this
issue by initializing config with NULL and checking if it is non-null
before invoking snd_config_delete.
Fixes: https://github.com/alsa-project/alsa-utils/pull/94
Fixes: f138117 ("alsactl: load_state() - initialize config variable for the open_failed case")
BugLink: https://github.com/alsa-project/alsa-utils/issues/93
Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
There may be nested iterations for hw: card names.
Handle this card name in snd_card_iterator_sinit().
BugLink: https://github.com/alsa-project/alsa-lib/issues/142
Fixes: eefc2c6 ("alsactl: use card iterator functions for all card loops")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
The /var/lib/alsa/card<NUMBER>.conf.d directories should be emptied
when the card is initialized. Implement this functionality directly
to alsactl.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Take the card iterator idea from the monitor code and
use it for all card loops. It reduces the code duplications
and makes things easy to review.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Also remove extra snd_config_update_free_global() call for dump-state.
There's a global call in the main() function.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
It is handy to remove all card controls created by applications.
This change allows to remove those controls for all cards, selected
card or selected card with a control id filter list like:
alsactl clean 0 "name='PCM'" "name='Mic Phantom'"
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
We added the check of asound.state file presence some time ago to
assure that alsactl gets called only if the state file is already
present. Since then, the situation has changed significantly:
e.g. now alsactl does initialize if the state file isn't present, and
the same alsa-restore.service is used to save the state. This means
that we should start this service no matter the state file exists at
the boot time or not. So, revert the old change again.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
A race at creating a lock file in state_lock() was discovered
recently: namely, between the first open(O_RDWR) and the second
open(O_RDWR|O_CREAT|O_EXCL) calls, another alsactl invocation may
already create a lock file, then the second open() will return EEXIST,
which isn't handled properly and treated as a fatal error.
In this patch, we check EEXIST case and try again open() with O_RDWR.
This must succeed usually, and if it fails, handle finally as the
fatal error.
BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1179904
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The state_lock() has a loop to wait for the lock file creation, and
the timeout value gets decremented twice mistakenly, which leads to a
half timeout (5 seconds) than expected 10 seconds. Fix it.
Signed-off-by: Takashi Iwai <tiwai@suse.de>