2010-05-21 09:01:56

by Fabian Greffrath

[permalink] [raw]
Subject: WRT non-UTF-8 device names

Dear Bluez list,

I am experiencing the following issues with the bluez 4.63-2 and
gnome-bluetooth 2.30.0-1 packages from Debian unstable:

Please find two text files attached. UTF-8.txt contains the string
"föøbär" in UTF-8 Unicode encoding, whereas non-UTF-8.txt contains the
same string in ISO-8859 encoding. Now please try the following steps,
assuming your bluetooth device identifies as hci0 and you have
bluetooth-applet running (please note that "no bluetooth icon in the
system" tray also means "it is impossible to establish a connection to
or from this device at all"):

$ sudo hciconfig hci0 name `cat UTF-8.txt`
$ sudo hciconfig -a
[...]
Name: 'föøbär'

$ sudo /etc/init.d/bluetooth restart
Stopping bluetooth: bluetoothd.
Starting bluetooth: bluetoothd.

[Not necessary here, everything is fine.]

$ sudo hciconfig hci0 name `cat non-UTF-8.txt`

[The bluetooth system tray icon disappears immediately.]

$ sudo hciconfig -a
[...]
Name: 'f��b�r'

[The device name contains non-UTF-8 characters against the spec.]

$ sudo /etc/init.d/bluetooth restart
Stopping bluetooth: bluetoothd.
Starting bluetooth: bluetoothd.

[Doesn't bring the icon back.]

$ sudo hciconfig hci0 name `cat UTF-8.txt`
$ sudo hciconfig -a
[...]
Name: 'föøbär'

[Now the name is back to the valid variant, but still no icon.]

$ sudo /etc/init.d/bluetooth restart
Stopping bluetooth: bluetoothd.
Starting bluetooth: bluetoothd.

[Finally the icon is back.]

Long story short: If the bluetooth adapter's device name contains
non-UTF-8 characters (which my dongle does by default), it requires a
manual device name change and a restart of the daemon (!) to bring the
device back to life. I have previously posted a patch to this list which
fixes this issue by instantly converting faulty device names to UTF-8
and writing them back to the device during the device configuration
phase:

<http://marc.info/?l=linux-bluetooth&m=127315737929319&w=2>

However, I have been told that my "patch might be just working around
the real issue instead of fixing it" and that "It sounds like there's
something else wrong in the initialization process which makes the
initialzation fail if the adapter contains some invalid default name".

So, please, try the steps I presented above yourself and tell me what is
wrong so I can attempt to fix the root of the problem. I am really
itching to get this issue fixed in the short term.

Thank you very much!

Cheers,
Fabian



Attachments:
non-UTF-8.txt (7.00 B)
UTF-8.txt (10.00 B)
Download all attachments

2010-05-25 12:56:57

by Fabian Greffrath

[permalink] [raw]
Subject: Re: WRT non-UTF-8 device names

Am 25.05.2010 14:38, schrieb Bastien Nocera:
> The output of "locale" as root would probably help.

Here you are:
$ su -c locale
LANG=de_DE.UTF-8
LC_CTYPE="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_PAPER="de_DE.UTF-8"
LC_NAME="de_DE.UTF-8"
LC_ADDRESS="de_DE.UTF-8"
LC_TELEPHONE="de_DE.UTF-8"
LC_MEASUREMENT="de_DE.UTF-8"
LC_IDENTIFICATION="de_DE.UTF-8"
LC_ALL=

> My guess is that we make assumptions as to a user entry being valid
> UTF-8 somewhere, when it could be non-UTF-8.
>
> As for your problem, I don't think we want to allow non-UTF-8 device
> names anyhow. They're not valid spec.

Sure, that's why my patch converts the device name to valid UTF-8 as
soon as it is possible to detect that it is actually non-UTF-8.
However, it may be right that this approach only fixes the symptoms
and does not cure the illness. But my knowledge of the Bluez code is
not deep enough to track down the real issue on my own.

Thanks for your reply anyway,
Fabian

2010-05-25 12:38:39

by Bastien Nocera

[permalink] [raw]
Subject: Re: WRT non-UTF-8 device names

On Fri, 2010-05-21 at 11:01 +0200, Fabian Greffrath wrote:
> Dear Bluez list,
>
> I am experiencing the following issues with the bluez 4.63-2 and
> gnome-bluetooth 2.30.0-1 packages from Debian unstable:

Stupid question, but do you use a UTF-8 locale, or not?

The output of "locale" as root would probably help.

My guess is that we make assumptions as to a user entry being valid
UTF-8 somewhere, when it could be non-UTF-8.

As for your problem, I don't think we want to allow non-UTF-8 device
names anyhow. They're not valid spec.


2010-05-25 11:35:22

by Fabian Greffrath

[permalink] [raw]
Subject: Re: WRT non-UTF-8 device names

Dear Bluez developers,

Am 21.05.2010 11:01, schrieb Fabian Greffrath:
> Long story short: If the bluetooth adapter's device name contains
> non-UTF-8 characters (which my dongle does by default), it requires a
> manual device name change and a restart of the daemon (!) to bring the
> device back to life. I have previously posted a patch to this list which
> fixes this issue by instantly converting faulty device names to UTF-8
> and writing them back to the device during the device configuration
> phase:
>
> <http://marc.info/?l=linux-bluetooth&m=127315737929319&w=2>
>
> However, I have been told that my "patch might be just working around
> the real issue instead of fixing it" and that "It sounds like there's
> something else wrong in the initialization process which makes the
> initialzation fail if the adapter contains some invalid default name".
>
> So, please, try the steps I presented above yourself and tell me what is
> wrong so I can attempt to fix the root of the problem. I am really
> itching to get this issue fixed in the short term.

this is a real issue (it bites me each and every time I plug in my USB
Bluetooth dongle) and it is easily reproducible following the simple
steps I have posted earlier. Please give me a hint how to track down
this bug and fix it.

Thanks,
Fabian