alsamixer: segfault in display_controls()

GitHub issues - opened <[email protected]>
Newsgroups gmane.linux.alsa.devel
Message-ID <[email protected]>
alsa-project/alsa-utils issue #335 was opened from fenugrec:

I think I know what sequence triggers this.

*** steps to reproduce
1-  connect a device that has no Capture controls (unclear if this is the crucial difference). Here this is a Presonus Studio 1824c
2- run alsamixer; F6 to select that Card
3- Go the Capture view (F4)
4- arrow right
5- go to All view (F5) -> segfault


*** backtrace
```
#0  display_control (control_index=0xffffffff) at /usr/src/debug/alsa-utils/alsa-utils-1.2.16/alsamixer/mixer_display.c:421
        control = 0x55855558ff60
        col = 0x0
        i = <optimized out>
        c = <optimized out>
        left = 0x2
        frame_left = 0xb
        bar_height = <optimized out>
        volumes = {0, 6.9531436082559572e-310}
        switches = {0x0, 0x0}
        index = 0x555a0710
        s = <optimized out>
        buf = "\360\030_UUU\000\000\003\000\000\000UU", '\000' <repeats 11 times>, "\230z\021\003\000\000\000\b\000\000\000\a\000\000\000\003\000\000\000UU\000\000\2352VUUU\000\000\2462VUUU\000"
        err = <optimized out>
#1  display_controls () at /usr/src/debug/alsa-utils/alsa-utils-1.2.16/alsamixer/mixer_display.c:674
        i = 0x0
#2  0x00005555555585dc in mainloop () at /usr/src/debug/alsa-utils/alsa-utils-1.2.16/alsamixer/mainloop.c:146
        pollfds = 0x55555560e790
        nfds = 0x2
        n = <optimized out>
        active_widget = 0x5555555676e0 <mixer_widget>
        revents = 0x1
        key = <optimized out>
        err = <optimized out>
#3  main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/alsa-utils/alsa-utils-1.2.16/alsamixer/cli.c:176
No locals.
```

The problem is the argument `control_index=0xffffffff` which comes from display_controls() around lines 660-670 ; in this debug run (after the segfault) I observe the following values

```
(gdb) p first_visible_control_index
$1 = 0xffffffff
(gdb) p controls_count
$2 = 0x5
(gdb) p visible_controls
$3 = 0x5
(gdb) p focus_control_index
$4 = 0x0
```

not sure why `first_visible_control_index` has that value...

Issue URL     : https://github.com/alsa-project/alsa-utils/issues/335
Repository URL: https://github.com/alsa-project/alsa-utils
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.