Bluetooth CUPS backend takes infinite time on device discovery

Bug #206579 reported by Till Kamppeter
8
Affects Status Importance Assigned to Milestone
bluez (Ubuntu)
Fix Released
Critical
Unassigned

Bug Description

Binary package hint: bluez-cups

When I am running

/usr/lib/cups/backend/bluetooth

or

sudo /usr/lib/cups/backend/bluetooth

it either takes very long or it can even habg infinitely.

Nothing appears in /var/log/cups/error_log, /var/log/messages, or /var/log/syslog.

This happens when there is no Bluetooth device around. If I put a Bluetooth plug into a printer I get an answer in a few seconds:

till@till-laptop:~/ubuntu/hplip/svn/pkg-hpijs/hplip/build-area$ time /usr/lib/cups/backend/bluetooth
network bluetooth://000461820B10 "Unknown" "Photosmart C8100 series (Bluetooth)" "MFG:HP;MDL:Photosmart C8100 series_BT;CMD:PCL,DW-PCL,DESKJET,DYN;CLS:PRINTER;DES:L2526;"

real 0m3.764s
user 0m0.008s
sys 0m0.004s
till@till-laptop:~/ubuntu/hplip/svn/pkg-hpijs/hplip/build-area$

As soon as I remove the Bluetooth plug the backend hangs again.

For a printer setup tool (or the command "lpinfo -v") this means that CUPS times out after 30 second on the bluetooth backend and so the device discovery takes always 30 seconds or longer when no Bluetooth printer is around.

Only workaround is doing

sudo chmod -x /usr/lib/cups/backend/bluetooth

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

This problem makes also the impression that bug 165197 is still there, even on small networks.

Changed in bluez-utils:
importance: Undecided → Medium
milestone: none → ubuntu-8.04
Revision history for this message
Steve Langasek (vorlon) wrote :

$ time /usr/lib/cups/backend/bluetooth

real 0m10.252s
user 0m0.004s
sys 0m0.000s
$

So what's different between your system and mine?

What does strace show the backend is doing during this time?

I note that if I have my bluetooth interface disabled, the bluetooth backend returns immediately.

I don't think 10 seconds is too long to wait for network discovery here; but of course, that's not currently how long it's taking for you.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :
Download full text (11.8 KiB)

Now I have done

strace /usr/lib/cups/backend/bluetooth

and got the output shown below. The strace output came together in a few seconds (< 30 sec) and then it was simply hanging at the "poll(" in the end of the shown output. So in the middle of that poll the backend was hanging indefinitely. The "<unfinished ...>" was added when I have killed the backend with Ctrl + C after several minutes (~10 min).

   Till

-------------------------

execve("/usr/lib/cups/backend/bluetooth", ["/usr/lib/cups/backend/bluetooth"], [/* 20 vars */]) = 0
brk(0) = 0x60b000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5acbfeb000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5acbfe9000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=115877, ...}) = 0
mmap(NULL, 115877, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5acbfcc000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/usr/lib/libdbus-1.so.3", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0pd\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=248432, ...}) = 0
mmap(NULL, 2344488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5acbb92000
mprotect(0x7f5acbbcd000, 2097152, PROT_NONE) = 0
mmap(0x7f5acbdcd000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3b000) = 0x7f5acbdcd000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/usr/lib/libglib-2.0.so.0", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240M\1\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=775416, ...}) = 0
mmap(NULL, 2872584, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5acb8d4000
mprotect(0x7f5acb990000, 2097152, PROT_NONE) = 0
mmap(0x7f5acbb90000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xbc000) = 0x7f5acbb90000
mmap(0x7f5acbb91000, 1288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5acbb91000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/usr/lib/libbluetooth.so.2", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0Pn\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=99800, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5acbfcb000
mmap(NULL, 2195064, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5acb6bc000
mprotect(0x7f5acb6d2000, 2097152, PROT_NONE) = 0
mmap(0x7f5acb8d2000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7f5acb8d2000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0...

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

My system is 64-bit (amd64) Hardy, updated yesterday and rebooted to run the current kernel.

till@till-laptop:~$ uname -a
Linux till-laptop 2.6.24-12-generic #1 SMP Wed Mar 12 22:31:43 UTC 2008 x86_64 GNU/Linux
till@till-laptop:~$ lspci
00:00.0 Host bridge: Intel Corporation Mobile 945GM/PM/GMS, 943/940GML and 945GT Express Memory Controller Hub (rev 03)
00:02.0 VGA compatible controller: Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller (rev 03)
00:02.1 Display controller: Intel Corporation Mobile 945GM/GMS/GME, 943/940GML Express Integrated Graphics Controller (rev 03)
00:1b.0 Audio device: Intel Corporation 82801G (ICH7 Family) High Definition Audio Controller (rev 02)
00:1c.0 PCI bridge: Intel Corporation 82801G (ICH7 Family) PCI Express Port 1 (rev 02)
00:1c.1 PCI bridge: Intel Corporation 82801G (ICH7 Family) PCI Express Port 2 (rev 02)
00:1c.2 PCI bridge: Intel Corporation 82801G (ICH7 Family) PCI Express Port 3 (rev 02)
00:1c.3 PCI bridge: Intel Corporation 82801G (ICH7 Family) PCI Express Port 4 (rev 02)
00:1d.0 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #1 (rev 02)
00:1d.1 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #2 (rev 02)
00:1d.2 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #3 (rev 02)
00:1d.3 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #4 (rev 02)
00:1d.7 USB Controller: Intel Corporation 82801G (ICH7 Family) USB2 EHCI Controller (rev 02)
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev e2)
00:1f.0 ISA bridge: Intel Corporation 82801GBM (ICH7-M) LPC Interface Bridge (rev 02)
00:1f.1 IDE interface: Intel Corporation 82801G (ICH7 Family) IDE Controller (rev 02)
00:1f.2 IDE interface: Intel Corporation 82801GBM/GHM (ICH7 Family) SATA IDE Controller (rev 02)
00:1f.3 SMBus: Intel Corporation 82801G (ICH7 Family) SMBus Controller (rev 02)
06:00.0 Network controller: Intel Corporation PRO/Wireless 3945ABG Network Connection (rev 02)
07:00.0 Ethernet controller: Marvell Technology Group Ltd. 88E8036 PCI-E Fast Ethernet Controller (rev 16)
09:04.0 CardBus bridge: Texas Instruments PCIxx12 Cardbus Controller
09:04.1 FireWire (IEEE 1394): Texas Instruments PCIxx12 OHCI Compliant IEEE 1394 Host Controller
09:04.2 Mass storage controller: Texas Instruments 5-in-1 Multimedia Card Reader (SD/MMC/MS/MS PRO/xD)
till@till-laptop:~$

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :
Download full text (9.4 KiB)

"sudo lsusb -vvv" output of my Bluetooth controller below. Note that the controller is supported as I can actually print via Bluetooth and also use a Bluetooth mouse with my computer.

--------------------------

Bus 004 Device 002: ID 044e:300d Alps Electric Co., Ltd
Device Descriptor:
  bLength 18
  bDescriptorType 1
  bcdUSB 2.00
  bDeviceClass 224 Wireless
  bDeviceSubClass 1 Radio Frequency
  bDeviceProtocol 1 Bluetooth
  bMaxPacketSize0 64
  idVendor 0x044e Alps Electric Co., Ltd
  idProduct 0x300d
  bcdDevice 19.15
  iManufacturer 1 ALPS
  iProduct 2 UGX
  iSerial 3 0116f414
  bNumConfigurations 1
  Configuration Descriptor:
    bLength 9
    bDescriptorType 2
    wTotalLength 193
    bNumInterfaces 3
    bConfigurationValue 1
    iConfiguration 0
    bmAttributes 0x80
      (Bus Powered)
    MaxPower 100mA
    Interface Descriptor:
      bLength 9
      bDescriptorType 4
      bInterfaceNumber 0
      bAlternateSetting 0
      bNumEndpoints 3
      bInterfaceClass 224 Wireless
      bInterfaceSubClass 1 Radio Frequency
      bInterfaceProtocol 1 Bluetooth
      iInterface 0
      Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x81 EP 1 IN
        bmAttributes 3
          Transfer Type Interrupt
          Synch Type None
          Usage Type Data
        wMaxPacketSize 0x0010 1x 16 bytes
        bInterval 1
      Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x02 EP 2 OUT
        bmAttributes 2
          Transfer Type Bulk
          Synch Type None
          Usage Type Data
        wMaxPacketSize 0x0040 1x 64 bytes
        bInterval 1
      Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x82 EP 2 IN
        bmAttributes 2
          Transfer Type Bulk
          Synch Type None
          Usage Type Data
        wMaxPacketSize 0x0040 1x 64 bytes
        bInterval 1
    Interface Descriptor:
      bLength 9
      bDescriptorType 4
      bInterfaceNumber 1
      bAlternateSetting 0
      bNumEndpoints 2
      bInterfaceClass 224 Wireless
      bInterfaceSubClass 1 Radio Frequency
      bInterfaceProtocol 1 Bluetooth
      iInterface 0
      Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x03 EP 3 OUT
        bmAttributes 1
          Transfer Type Isochronous
          Synch Type None
          Usage Type Data
        wMaxPacketSize ...

Read more...

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :
Download full text (18.7 KiB)

On another machine (Hardy 32-bit i386) the Bluetooth backend needs 30 seconds and in the end it returns info of device which it has cached somewhere as for the tests I have no Bluetooth device turned on.

-------------------------

till@till-laptop:~$ uname -a
Linux till-laptop 2.6.24-11-generic #1 SMP Fri Feb 29 22:08:31 UTC 2008 i686 GNU/Linux
till@till-laptop:~$

-------------------------

execve("/usr/lib/cups/backend/bluetooth", ["/usr/lib/cups/backend/bluetooth"], [/* 22 vars */]) = 0
brk(0) = 0x8052000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7eea000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=114461, ...}) = 0
mmap2(NULL, 114461, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7ece000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/usr/lib/libdbus-1.so.3", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0000M\0\000"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=214620, ...}) = 0
mmap2(NULL, 217920, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7e98000
mmap2(0xb7ecc000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x33) = 0xb7ecc000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/usr/lib/libglib-2.0.so.0", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0000\26\1"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=712748, ...}) = 0
mmap2(NULL, 716580, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7de9000
mmap2(0xb7e97000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xad) = 0xb7e97000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/usr/lib/libbluetooth.so.2", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\220G\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=78968, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7de8000
mmap2(NULL, 77756, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7dd5000
mmap2(0xb7de7000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12) = 0xb7de7000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/tls/i686/cmov/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\260e\1"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1364388, ...}) = 0
mmap2(NULL, 1369712, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7c86000
mmap2(0xb7dcf000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x149) = 0xb7dcf000
mmap2(0xb7dd2000, 9840, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7dd2000
close(3) ...

Revision history for this message
Steve Langasek (vorlon) wrote :

the polling that hangs here is on a dbus socket. well, that doesn't tell us much about why it's hanging, then; we'll need someone familiar with dbus debugging to look at this.

Steve Langasek (vorlon)
Changed in bluez-utils:
milestone: ubuntu-8.04 → none
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

The problem still persists in Intrepid.

bluez-utils 3.36 has changes in how DBUS is used. Perhaps someone should update the bluez-utils in Intrepid.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

I have raised the priority as this prevents Bluetooth printers from "just working" without letting device discovery taking an annoyingly long time. A program should simply not run infinitely long time.

Changed in bluez-utils:
importance: Medium → Critical
milestone: none → ubuntu-8.10-beta
Revision history for this message
Mario Limonciello (superm1) wrote :

Till:

Can you confirm this is still the same situation on the BlueZ 4.x packages that entered Intrepid?

Changed in bluez:
status: New → Incomplete
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Now there is no infinite loop any more, but

/usr/lib/cups/backend/bluetooth

exits immediately with exit status 1. This happens independent whether there is a Bluetooth printer or not. So the printer setup tool finds all the other printer (USB, network, ...) quickly now, but no Bluetooth printers.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

The Bluetooth Daemon

/usr/sbin/bluetoothd

is running.

Revision history for this message
Baptiste Mille-Mathias (bmillemathias) wrote :

Till,

in the future, avoid usign the same bug for various bug.
Is your latest problem still occur?

Revision history for this message
Mario Limonciello (superm1) wrote :

I've just tested with bluez 4.47, and it appears that the backend properly exits now with a zero return code.

Changed in bluez (Ubuntu):
status: Incomplete → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.