Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ivan Sorokin <vanyacpp@gmail.com>
To: alsa-devel@alsa-project.org
Subject: valgrind error in snd_tlv_get_dB_range
Date: Sun, 19 Jan 2014 14:16:11 +0400	[thread overview]
Message-ID: <52DBA5EB.3070104@gmail.com> (raw)

One program (qasmixer -- alsa mixer) on my system prints lots of 
valgrind errors.

The first one is this:

==25716== Conditional jump or move depends on uninitialised value(s)
==25716==    at 0x4E72307: snd_tlv_get_dB_range (tlv.c:170)
==25716==    by 0x4E8A746: get_dB_range (simple_none.c:1162)
==25716==    by 0x4E8A7E7: get_dB_range_ops (simple_none.c:1176)
==25716==    by 0x4E85590: snd_mixer_selem_get_playback_dB_range 
(simple.c:298)
==25716==    by 0x472B2B: 
QSnd::Mixer_Simple_Elem::set_snd_mixer_selem_id(_snd_mixer_selem_id*) 
(mixer_simple_elem.cpp:161)
==25716==    by 0x4724B8: 
QSnd::Mixer_Simple_Elem::Mixer_Simple_Elem(QObject*, _snd_mixer*, 
_snd_mixer_selem_id*) (mixer_simple_elem.cpp:31)
==25716==    by 0x479F17: 
QSnd::Mixer_Simple::create_mixer_elem(_snd_mixer_elem*) 
(mixer_simple.cpp:318)
==25716==    by 0x4797B3: QSnd::Mixer_Simple::create_mixer_elems() 
(mixer_simple.cpp:217)
==25716==    by 0x4795DF: QSnd::Mixer_Simple::open(QString const&) 
(mixer_simple.cpp:178)
==25716==    by 0x4D4754: Tray_Mixer::load_mixer() (tray_mixer.cpp:222)
==25716==    by 0x4D4505: 
Tray_Mixer::set_mdev_setup(Tray_Mixer_MDev_Setup*) (tray_mixer.cpp:137)
==25716==    by 0x4DB863: Desktop_Items::tray_mixer_create() 
(desktop_items.cpp:504)
==25716==  Uninitialised value was created by a heap allocation
==25716==    at 0x4C2CD7B: malloc (in 
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==25716==    by 0x4E8A572: init_db_range (simple_none.c:1114)
==25716==    by 0x4E8A70D: get_dB_range (simple_none.c:1159)
==25716==    by 0x4E8A7E7: get_dB_range_ops (simple_none.c:1176)
==25716==    by 0x4E85590: snd_mixer_selem_get_playback_dB_range 
(simple.c:298)
==25716==    by 0x472B2B: 
QSnd::Mixer_Simple_Elem::set_snd_mixer_selem_id(_snd_mixer_selem_id*) 
(mixer_simple_elem.cpp:161)
==25716==    by 0x4724B8: 
QSnd::Mixer_Simple_Elem::Mixer_Simple_Elem(QObject*, _snd_mixer*, 
_snd_mixer_selem_id*) (mixer_simple_elem.cpp:31)
==25716==    by 0x479F17: 
QSnd::Mixer_Simple::create_mixer_elem(_snd_mixer_elem*) 
(mixer_simple.cpp:318)
==25716==    by 0x4797B3: QSnd::Mixer_Simple::create_mixer_elems() 
(mixer_simple.cpp:217)
==25716==    by 0x4795DF: QSnd::Mixer_Simple::open(QString const&) 
(mixer_simple.cpp:178)
==25716==    by 0x4D4754: Tray_Mixer::load_mixer() (tray_mixer.cpp:222)
==25716==    by 0x4D4505: 
Tray_Mixer::set_mdev_setup(Tray_Mixer_MDev_Setup*) (tray_mixer.cpp:137)

I compiled libasound2 from the latest git from 
git://gitorious.org/alsa/alsa-lib.git with -g -O0, so you can see line 
numbers.

As I understand the problem is that init_db_range initialize invalid 
rec->db_info, because snd_hctl_elem_tlv_read failed to fully initialize tlv:

> 	tlv = malloc(tlv_size);                  // line 1114
> 	if (! tlv)
> 		return -ENOMEM;
> 	if (snd_hctl_elem_tlv_read(ctl, tlv, tlv_size) < 0)
> 		goto error;
> 	db_size = snd_tlv_parse_dB_info(tlv, tlv_size, &dbrec);
> 	if (db_size < 0)
> 		goto error;
> 	rec->db_info = malloc(db_size);
> 	if (!rec->db_info)
> 		goto error;
> 	memcpy(rec->db_info, dbrec, db_size);
> 	free(tlv);

I tried to trace problem in snd_hctl_elem_tlv_read, but I failed to do 
so due to lack of experience with alsa-lib.

Could someone more experienced with alsa-lib look at the problem?

             reply	other threads:[~2014-01-19 10:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-19 10:16 Ivan Sorokin [this message]
2014-01-19 11:19 ` valgrind error in snd_tlv_get_dB_range Clemens Ladisch
2014-01-19 12:22 ` Ivan Sorokin
2014-01-20  9:42   ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52DBA5EB.3070104@gmail.com \
    --to=vanyacpp@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox