Go to file
howardchung b4270d79e1 audio/a2dp - fix crash during recovering process
The crash with stack trace:

(libc-2.27.so -raise.c:51 )      		raise
(libc-2.27.so -abort.c:79 )      		abort
(libc-2.27.so -libc_fatal.c:181 )        	__libc_message
(libc-2.27.so -malloc.c:5350 )   		malloc_printerr
(libc-2.27.so -malloc.c:4157 )   		_int_free
(libglib-2.0.so.0.5200.3 -gslist.c:878 )        g_slist_free_full
(bluetoothd -a2dp.c:165 )       		setup_unref
(bluetoothd -a2dp.c:2184 )      		a2dp_cancel
(bluetoothd -sink.c:317 )       		sink_unregister
(bluetoothd -service.c:176 )    		service_remove
(bluetoothd -device.c:4678 )    		device_remove
(bluetoothd -adapter.c:6573 )   		adapter_remove
(bluetoothd -adapter.c:8832 )   		index_removed
(bluetoothd -queue.c:220 )      		queue_foreach
(bluetoothd -mgmt.c:304 )       		can_read_data
(bluetoothd -io-glib.c:170 )    		watch_callback
(libglib-2.0.so.0.5200.3 -gmain.c:3234 )        g_main_context_dispatch
(libglib-2.0.so.0.5200.3 -gmain.c:3972 )        g_main_context_iterate
(libglib-2.0.so.0.5200.3 -gmain.c:4168 )        g_main_loop_run
(bluetoothd -main.c:798 )       		main
(libc-2.27.so -libc-start.c:308 )        	__libc_start_main
(bluetoothd + 0x0000b089 )      		_start
(bluetoothd + 0x0000b05f )      		_init

triggered when 'usb disconnect' happened during AVDTP_SET_CONFIGURATION
request is sent but haven't received the response.
In this situation, the recovering process goes into sink.c:sink_free and
then a2dp.c:a2dp_cancel, avdtp.c:cancel_request, avdtp.c:connection_lost,
avdtp.c:release_stream.

During recovering, the reference count of setup and avdtp decrease more
than it increase, which ends up causing the crash.

The reference count of setup decreases one more time since
a2dp.c:setconf_cfm(called by cfm->set_configuration in
avdtp.c:cancel_request) was called in the 'error mode', which didn't
reference the setup, but in a2dp.c:abort_cfm(called by cfm->abort in
avdtp.c:release_stream), the reference count decreased by 1.

In this case, abort_cfm shouldn't be called as we already know
setconf_cfm didn't send any request. Setting avdtp_sep_state to
AVDTP_STATE_ABORTING should avoid this issue.

The reference count of avdtp decrease one more time since
both sink.c:sink_free and sink.c:sink_set_state(called from
avdtp.c:connection_lost -> avdtp.c:avdtp_set_state) unreference avdtp
for the session. The changes in sink.c should avoid the issue.
2020-01-10 15:50:35 -08:00
android android/handsfree: Fix unaligned struct access 2019-05-13 20:23:48 +03:00
attrib build: Move declaration of _GNU_SOURCE back into individual source files 2018-12-06 21:28:18 +01:00
btio build: Move declaration of _GNU_SOURCE back into individual source files 2018-12-06 21:28:18 +01:00
client client: Fix memory leak 2019-12-08 06:08:46 +02:00
completion/zsh completion: add bluetoothctl zsh completions 2019-09-06 10:58:03 +03:00
doc mesh: Fix getting managed objects from ObjectManager 2019-12-18 07:46:16 -08:00
emulator emulator: Fix condition check in btdev_create() 2019-07-12 10:21:19 -07:00
gdbus gdbus: Split validation of object path and interface 2018-12-18 12:04:00 -03:00
gobex build: Move declaration of _GNU_SOURCE back into individual source files 2018-12-06 21:28:18 +01:00
lib lib: Add ba2strlc to match kernel printk format 2019-12-03 18:36:34 +02:00
mesh mesh: Fix BeaconFlags property type 2020-01-08 14:02:36 -08:00
monitor monitor: Decode LE CTE Request Failed event 2020-01-09 11:36:05 +01:00
obexd build: Move declaration of _GNU_SOURCE back into individual source files 2018-12-06 21:28:18 +01:00
peripheral peripheral: Walk rp->opcodes directly instead of interim variable 2019-05-07 16:49:03 +02:00
plugins sixaxis: Throw an error when cable setup fails 2019-06-13 11:24:55 +02:00
profiles audio/a2dp - fix crash during recovering process 2020-01-10 15:50:35 -08:00
src agent: Detect when ongoing request is already in progress 2019-12-27 10:35:55 -08:00
test mesh: Inform application about model subscriptions 2019-11-26 10:56:44 -08:00
tools meshctl: Fix meshctl crash 2020-01-06 07:29:34 -08:00
unit unit: Fix valgrind errors in test-mesh-crypto 2019-10-12 09:26:00 -07:00
.gitignore tools: Add mesh-cfgclient tool 2019-11-04 14:54:38 -08:00
.gitlint gitlint: Add .gitlint configuration 2018-08-08 11:03:10 +03:00
.mailmap Fix name in AUTHORS 2015-05-20 23:16:30 +03:00
acinclude.m4 build: Enable BIND_NOW 2019-05-13 20:22:23 +03:00
AUTHORS AUTHORS: mention Szymon's contributions 2020-01-09 11:37:28 +01:00
bootstrap Add --automake option 2006-08-18 19:41:53 +00:00
bootstrap-configure build: Add a few default configure options 2019-05-13 20:22:23 +03:00
ChangeLog Release 5.52 2019-10-31 07:58:44 +01:00
configure.ac mesh: Base config json code on newer version of json-c 2019-12-24 10:38:34 -08:00
COPYING Remove new page characters 2008-08-14 22:56:25 +02:00
COPYING.LIB Remove new page characters 2008-08-14 22:56:25 +02:00
HACKING Remove obsolete Debian notes from HACKING 2018-03-06 09:47:47 +02:00
INSTALL Big cleanup of CVS relics 2005-10-29 19:25:42 +00:00
Makefile.am build: Include dependencies for ell/settings.[ch] 2019-12-04 14:40:21 -08:00
Makefile.mesh mesh: Add mesh-main.conf file with general mesh configuration 2019-12-16 14:52:36 -08:00
Makefile.obexd Makefile.obexd: add missing mkdir in builtin.h generation 2019-10-09 17:35:04 +03:00
Makefile.plugins build: Move $(UDEV_CFLAGS) to global $(AM_CFLAGS) 2018-12-03 19:47:20 +01:00
Makefile.tools tools/mesh: add initial support for config storage 2019-11-04 14:54:38 -08:00
NEWS Initial revision 2002-03-08 21:10:06 +00:00
README README: Adding information for dependency get command for Debian 2019-11-27 06:43:45 +01:00
TODO TODO: Update mesh section 2019-12-20 09:01:49 -08:00

BlueZ - Bluetooth protocol stack for Linux
******************************************

Copyright (C) 2000-2001  Qualcomm Incorporated
Copyright (C) 2002-2003  Maxim Krasnyansky <maxk@qualcomm.com>
Copyright (C) 2002-2010  Marcel Holtmann <marcel@holtmann.org>


Compilation and installation
============================

In order to compile Bluetooth utilities you need following software packages:
	- GCC compiler
	- GLib library
	- D-Bus library
	- udev library (optional)
	- readline (command line clients)

	On a debian based system, this can be done by running the following command:
		sudo apt-get build-dep bluez
		./bootstrap

To configure run:
	./configure --prefix=/usr --mandir=/usr/share/man \
				--sysconfdir=/etc --localstatedir=/var

Configure automatically searches for all required components and packages.

To compile and install run:
	make && make install


Embedded Linux library
======================

In order to compile mesh support and test client utility the development
version of Embedded Linux library is required to be present. The development
repositories can be found here:

	git://git.kernel.org/pub/scm/libs/ell/ell.git
	https://kernel.googlesource.com/pub/scm/libs/ell/ell.git

The build systems requires that the Embedded Linux library source code
is available on the same top level directory as the source code:

	.
	|--- ell
	|    |--- ell
	|    `--- unit
	`--- bluez
	     |--- src
	     `--- tools

It is not required to build or install Embedded Linux library. The build
will happen when building the binaries and it will then be linked internally.

When using --enable-external-ell build option, it is not required that the
Embedded Linux library source code is available in the top level directory.

When neither --enable-mesh nor --enable-btpclient is specified, then this
part is irrelevant and Embedded Linux library is not required.


Configuration and options
=========================

For a working system, certain configuration options need to be enabled:

	--enable-library

		Enable installation of Bluetooth library

		By default the Bluetooth library is no longer installed.

		The user interfaces or command line utilities do not
		require an installed Bluetooth library anymore. This
		option is provided for legacy third party applications
		that still depend on the library.

		When the library installation is enabled, it is a good
		idea to use a separate bluez-library or libbluetooth
		package for it.

	--disable-tools

		Disable support for Bluetooth utilities

		By default the Bluetooth utilities are built and also
		installed. For production systems the tools are not
		needed and this option allows to disable them to save
		build time and disk space.

		When the tools are selected, it is a good idea to
		use a separate bluez-tools package for them.

	--disable-cups

		Disable support for CUPS printer backend

		By default the printer backend for CUPS is build and
		also installed. For systems that do not require printing
		over Bluetooth, this options allows to disable it.

		When the CUPS backend is selected, it is a good idea to
		use a separate bluez-cups package for it.

	--disable-monitor

		Disable support for the Bluetooth monitor utility

		By default the monitor utility is enabled. It provides
		support for HCI level tracing and debugging. For systems
		that don't require any kind of tracing or debugging
		capabilities, this options allows to disable it.

		The monitor utility should be placed in the main package
		along with the daemons. It is universally useful.

	--disable-client

		Disable support for the command line client

		By default the command line client is enabled and uses the
		readline library. For specific systems where BlueZ is
		configured by other means, the command line client can be
		disabled and the dependency on readline is removed.

		The client should be placed in the main package along
		with the daemons. It is universally useful.

	--disable-systemd

		Disable integration with systemd

		By default the integration with systemd is enabled and
		installed. This gives the best integration into all
		distributions based on systemd.

		This option is provided for distributions that do not
		support systemd. In that case all integration with the
		init system is up to the package.

	--disable-a2dp

		Disable A2DP profile

		By default bluetoothd supports A2DP profile using a built-in
		plugin, this option disables it.

		This option is provided for distributions that do not have any
		audio capabilities.

	--disable-avrcp

		Disable AVRCP profile

		By default bluetoothd supports AVRCP profile using a built-in
		plugin, this option disables it.

		This option is provided for distributions that do not have any
		audio capabilities.

	--disable-network

		Disable PANU, NAP, GN profiles

		By default bluetoothd supports PANU, NAP and GN profile using a
		built-in plugin, this option disables it.

		This option is provided for distributions that do not have any
		network capabilities.

	--disable-hid

		Disable HID profile

		By default bluetoothd supports HID profile using a built-in
		plugin, this option disables it.

		This option is provided for distributions that do not have any
		input capabilities.

	--disable-hog

		Disable HoG profile

		By default bluetoothd supports HoG profile using a built-in
		plugin, this option disables it.

		This option is provided for distributions that do not have any
		input capabilities.

	--enable-testing

		Enable testing tools

		By default tools used only for testing emulation are disabled.
		This option can be used to enable them.

		It is not recommended to enable this option for production
		systems. These tools may contain tests that depend on specific
		environment or kernel features in development.

	--enable-experimental

		Enable experimental tools

		By default all tools that are still in development
		are disabled. This option can be used to enable them.

		It is not recommended to enable this option for production
		systems. The behavior of the experimental tools is unstable
		and might still change.

	--enable-deprecated

		Enable deprecated tools

		By defauld all tools that are no longer maintained are
		disabled. This option can be used to enable them.

		It is not recommended to enable this option for production
		systems. The behavior of the deprecated tools may be unstable
		or simply don't work anymore.

	--enable-nfc

		This option enable NFC pairing support.

		By default the integration with neard is disabled, this gives
		the option to enable it in system where neard is supported.

		The plugin is built into bluetoothd therefore it does not need
		to be package separately.

	--enable-sap

		This option enable SAP profile using sap plugin.

		By default sap plugin is disabled since it requires tight
		integration with systems and is very rarely required.

		The plugin is built into bluetoothd therefore it does not need
		to be package separately.

	--enable-health

		This option enable health profiles.

		By default health plugin is disabled since its profiles are
		target for the health industry.

		The plugin is built into bluetoothd therefore it does not need
		to be package separately.

	--enable-midi

		This option enable MIDI support via ALSA Sequencer.

		By default midi plugin is disabled since it still considered
		experimental. When bluetoothd will create a new ALSA Sequencer
		client and port for each device connected that supports the
		MIDI GATT primary service.

		The plugin is built into bluetoothd therefore it does not need
		to be package separately.

Information
===========

Mailing lists:
	linux-bluetooth@vger.kernel.org

For additional information about the project visit BlueZ web site:
	http://www.bluez.org