fallowu / bluecove

Automatically exported from code.google.com/p/bluecove
0 stars 1 forks source link

L2CAP Connection fails on 2.1.1-Snapshot.60 #105

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
As discussed here: http://groups.google.com/group/bluecove-
users/browse_thread/thread/fd66a8e7ca7fbc53

What steps will reproduce the problem?

UUID L2CAP = new UUID(0x0100);
String url = "btl2cap://localhost:" + L2CAP;
Connector.open(url);

What is the expected output? What do you see instead?

Should open L2CAP Connection.

Instead:

--------------------------------------------------------
BlueCove version 2.1.1-SNAPSHOT on bluez
java.io.IOException: Failed to bind socket. [22] Invalid argument
       at
com.intel.bluetooth.BluetoothStackBlueZ.l2OpenClientConnectionImpl(Native
Method)
Connecting to btl2cap://0016BC5CABDA:
1003;authenticate=false;encrypt=false;master=false...
       at
com.intel.bluetooth.BluetoothStackBlueZ.l2OpenClientConnection(BluetoothSta
ckBlueZ.java:
679)
       at
com.intel.bluetooth.BluetoothL2CAPClientConnection.<init>(BluetoothL2CAPCli
entConnection.java:
35)
       at
com.intel.bluetooth.MicroeditionConnector.openImpl(MicroeditionConnector.ja
va:
395)
       at
com.intel.bluetooth.MicroeditionConnector.open(MicroeditionConnector.java:
162)
       at javax.microedition.io.Connector.open(Connector.java:83)
       at blue_2.BTTest.run(BTTest.java:61)
       at blue_2.BTTest.main(BTTest.java:28)
--------------------------------------------------------

What BlueCove version are you using (include build number for SNAPSHOT)? On 
what operating system and jvm? Is this 64-bit or 32-bit OS and jvm?

2.1.1-Snapshot.60.

Ubuntu 9.10 64bit

Please provide any additional information below.
Please use "Attach a file" when uploading stack traces or other big files!

Works fine in non-snapshot

Original issue reported on code.google.com by Andrew....@gmail.com on 1 Mar 2010 at 4:38

GoogleCodeExporter commented 9 years ago
Bisecting this issue, I see that snapshot 20 still works, but snapshot 23 does 
not. I 
cannot test in-between versions, as they are not available. Checking out r2850 
(which 
should be the sources for snapshot 20), as well as trying to build from the 
snapshot 
20 sources.tar.gz does not fix the issue. To me, it appears as if the packaged 
sources 
were not exactly the sources the snapshot was built from.

Original comment by johannes.schindelin on 24 May 2010 at 11:51

GoogleCodeExporter commented 9 years ago
Okay, I had an idea. I put the libbluecove.so of snapshot 20 into the .jar of 
snapshot 23. And all of a sudden it worked! A little disassembly later, it 
appears 
that all that changed was the order of the local variables on the stack.

As you might have guessed, the issue is uninitialized memory: In line 45 of 
bluecove-
gpl/src/main/c/BlueCoveBlueZ_L2CAP.c, a struct sockaddr_l2 is declared, but 
never 
initialized to 0. family, psm and bdaddr are subsequently set, but cid is left 
as-is. 
The safe way is to memset() it to 0, which is what I did in this patch (along 
with a 
few other places where I deemed it safer to memset() than rely on all the 
fields 
being set properly:

http://pacific.mpi-cbg.de/cgi-bin/gitweb.cgi?
p=bluecove/.git;a=commitdiff_plain;h=c8dc4cb7a0aafbb23793164335294a81fdfcdd2e

Original comment by johannes.schindelin on 24 May 2010 at 12:27

GoogleCodeExporter commented 9 years ago
Thanks Johannes
 I applied the suggested changes. As well the same to RFCOMM code.
 In GPL and BlueZ Dbus versions.

 Once we made a new build somebody needs to confirm that this fixed the problem!

Original comment by skarzhev...@gmail.com on 24 May 2010 at 6:00

GoogleCodeExporter commented 9 years ago
Just let me know, I'll test at once. Thank you for applying the patch!

Original comment by johannes.schindelin on 24 May 2010 at 9:11