Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 293349 - sys-kernel/gentoo-sources-2.6.31-r5 (alsa-lib 1.0.21a): using aplay with a bluetooth headset causes a memory leak
Summary: sys-kernel/gentoo-sources-2.6.31-r5 (alsa-lib 1.0.21a): using aplay with a bl...
Status: RESOLVED TEST-REQUEST
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo ALSA team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-16 08:01 UTC by Geoff Lywood
Modified: 2012-10-06 15:41 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Geoff Lywood 2009-11-16 08:01:16 UTC
When I attempt to use aplay to play a wav file to my bluetooth headset, and the file requires audio resampling (rate conversion), I hear no sound and the kernel leaks memory rapidly.

Reproducible: Always

Steps to Reproduce:
1. Plug in, power on, and pair the bluetooth headset with the USB dongle.
2. Put this in my .asoundrc:

pcm.btheadset {
   type bluetooth
   device 00:1A:45:FE:05:98
}
pcm.btrate {
   type rate
   slave {
      pcm btheadset
      rate 8000
      format s16_le
   }
   converter "linear"
}

3. Record something:
$ arecord -f s16_le -D btheadset sound.wav
Say some stuff, Ctrl-C.
(Yes, I do mean "btheadset".)

4. Play it back:
$ aplay -f s16_le -D btheadset sound.wav
(This works just fine. I hear my own voice.)

5. Play it back, using the rate conversion plugin:
$ aplay -f s16_le -D btrate sound.wav
(Notice, now I'm using "btrate". This causes the kernel to leak memory, within 30 seconds or a minute everything starts swapping, and there's not much I can do other than hard reboot. The headset makes that faint "turning on" static noise, but I do not hear my voice.)

6. Now I decide that .asoundrc must be the problem, so I change it to this:
pcm.btheadset {
   type bluetooth
   device 00:1A:45:FE:05:98
}
pcm.btplug {
   type plug
   slave.pcm "btheadset"
}

7. Try playing back that same clip again:
$ aplay -f s16_le -D btplug sound.wav
(Aha! This works just fine again. I hear myself.)

8. Now try playing back a clip that's not recorded at 8000 Hz:
$ aplay -D btheadset /usr/share/sounds/alsa/Front_Center.wav
(Again, this leaks kernel memory in excess of 10 MB per second. No sound.)

Whenever it fails (steps 5 and 8), I get lots and lots and lots (hundreds if not thousands) of messages like this in my dmesg output:
btusb_send_frame: hci0 urb c96b1200 submission failed
btusb_send_frame: hci0 urb c96b1400 submission failed
btusb_send_frame: hci0 urb c96b1600 submission failed
btusb_send_frame: hci0 urb c96b1800 submission failed
btusb_send_frame: hci0 urb c96b1a00 submission failed
btusb_send_frame: hci0 urb c96b1c00 submission failed
btusb_send_frame: hci0 urb c96b1e00 submission failed
btusb_send_frame: hci0 urb c96b2000 submission failed
btusb_send_frame: hci0 urb c96b2200 submission failed
btusb_send_frame: hci0 urb c96b2400 submission failed
btusb_send_frame: hci0 urb c96b2600 submission failed

(notice the pattern of 0x200 bytes being leaked each time)


Expected Results:  
I believe that both of those .asoundrc configurations are correct, and should have produced working audio.

geoff@wakko ~ $ uname -a
Linux wakko 2.6.31-gentoo-r5 #2 Sun Nov 15 15:31:02 PST 2009 i686 Intel(R) Pentium(R) M processor 1.70GHz GenuineIntel GNU/Linux
geoff@wakko ~ $ equery l gentoo-sources
 * Searching for gentoo-sources ...
[IP-] [ ~] sys-kernel/gentoo-sources-2.6.31-r5 (2.6.31-r5)
geoff@wakko ~ $ equery l alsa-lib
 * Searching for alsa-lib ...
[IP-] [ ~] media-libs/alsa-lib-1.0.21a (0)
geoff@wakko ~ $ equery l alsa-plugins
 * Searching for alsa-plugins ...
[IP-] [ ~] media-plugins/alsa-plugins-1.0.21 (0)
geoff@wakko ~ $ equery l alsa-utils
 * Searching for alsa-utils ...
[IP-] [ ~] media-sound/alsa-utils-1.0.21 (0.9)
geoff@wakko ~ $ emerge --info
Portage 2.1.7.4 (default/linux/x86/10.0/desktop, gcc-4.4.2, glibc-2.11-r0, 2.6.31-gentoo-r5 i686)
=================================================================
System uname: Linux-2.6.31-gentoo-r5-i686-Intel-R-_Pentium-R-_M_processor_1.70GHz-with-gentoo-2.0.1
Timestamp of tree: Sun, 08 Nov 2009 23:00:01 +0000
app-shells/bash:     4.0_p35
dev-java/java-config: 2.1.9-r1
dev-lang/python:     2.6.4, 3.1.1-r1
dev-util/cmake:      2.6.4-r3
sys-apps/baselayout: 2.0.1
sys-apps/openrc:     0.5.2-r1
sys-apps/sandbox:    2.2
sys-devel/autoconf:  2.13, 2.63-r1
sys-devel/automake:  1.10.2, 1.11
sys-devel/binutils:  2.20
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.2.6a
virtual/os-headers:  2.6.30-r1
ACCEPT_KEYWORDS="x86 ~x86"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -march=i686 -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/X11/xkb"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/udev/rules.d"
CXXFLAGS="-O2 -march=i686 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests distlocks fixpackages news parallel-fetch protect-owned sandbox sfperms strict unmerge-logs unmerge-orphans userfetch"
GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/distributions/gentoo"
LANG="en_US.UTF8"
LC_ALL="en_US.UTF8"
LDFLAGS="-Wl,-O1"
LINGUAS="en en_CA en_US"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X a52 aac acl acpi ada alsa avahi berkdb bluetooth branding bzip2 cairo cdr cli consolekit cracklib crypt cups dbus divx dri dts dvd dvdr eds emboss encode evo fam firefox flac fortran gdbm gecko-sdk gif git gmedia gnome gnutls gpm gstreamer gtk hal iconv ipv6 java java6 jpeg libnotify libsamplerate logrotate mad mikmod mmx modules mp3 mp4 mpeg msn mudflap ncurses nls nntp nptl nptlonly nsplugin ogg opengl openmp pam pcre pdf perl pidgin png ppds pppd python qt3support quicktime readline reflection scanner sdl session snmp spell spl sse sse2 ssl startup-notification subversion svg sysfs tcpd theora thunar tiff tk truetype unicode usb v4l2 vim-syntax vorbis win32codecs wmp x264 x86 xml xorg xulrunner xv xvid zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="evdev keyboard mouse synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en en_CA en_US" USERLAND="GNU" VIDEO_CARDS="intel" 
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Geoff Lywood 2009-11-16 08:05:23 UTC
Oops. There is a major typo in the description. Step 8 should be:

8. Now try playing back a clip that's not recorded at 8000 Hz:
$ aplay -D btplug /usr/share/sounds/alsa/Front_Center.wav
(Again, this leaks kernel memory in excess of 10 MB per second. No sound.)

Note that it is "btplug" that is broken, not "btheadset" as originally reported. (Attempting this with "btheadset results in distorted sound due to mismatched sample rates, but at least it doesn't leak memory.)
Comment 2 Jesse Adelman 2009-12-28 02:37:18 UTC
Wow, this caused a panic which ate all my RAM and swap, and soon the kernel panicked. I have an even simpler setup of .asoundrc:

pcm.bluetoothraw {
    type bluetooth
    device 00:23:7F:20:2F:53
    profile "auto"
}

pcm.bluetooth {
    type plug
    slave {
        pcm bluetoothraw
    }
} 

Same error filling syslog/dmesg. I'm even running bluez-4.59 (latest upstream), and tuxonice-sources-2.6.31.
Comment 3 Daniel T Chen 2010-08-31 23:48:27 UTC
This should be fixed in commit a256766c10c of upstream alsa-lib git.
Comment 4 mikopp 2010-10-19 15:30:52 UTC
just tested this with alsa 1.0.23 and bluez 4.0.75
Comment 5 mikopp 2010-10-19 15:31:36 UTC
I have the same problem, same error message, same simple .asoundrc

What do you need to further investigate this
Comment 6 Tony Vroon (RETIRED) gentoo-dev 2012-02-20 08:38:36 UTC
Could you confirm whether alsa-lib 1.0.25 fixes this please?
Comment 7 Pacho Ramos gentoo-dev 2012-10-06 15:41:40 UTC
(In reply to comment #6)
> Could you confirm whether alsa-lib 1.0.25 fixes this please?