aharpour / bluecove

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

Services search crashes JVM #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
An attempt to search for services crashes the JVM Here is a snippet from a 
test program which will reproduce the problem.  The complete program could 
be supplied if required.  The Vector devices have been loaded with devices 
discovered by a previous search for devices (this works).  

    System.out.println("\nStarting services search");

    DiscoveryListener serviceDiscoveryListener = new DiscoveryListener() {
      public void servicesDiscovered(int transID,
          ServiceRecord[] serviceRecords) {
        if (serviceRecords == null || serviceRecords.length == 0)
          System.out.println("No services");
        else
          for (int i = 0; i < serviceRecords.length; i++)
            printServiceRecord(serviceRecords[i]);
      }

      public void deviceDiscovered(RemoteDevice remoteDevice,
          DeviceClass deviceClass) {
      }

      public void inquiryCompleted(int discType) {
      }

      public void serviceSearchCompleted(int transID, int respCode) {
        System.out.println("Device search completed");
        searchControl.setDone();
      }
    };

    if (devices != null && devices.size() > 0)
      for (int i = 0; i < devices.size(); i++) {
        RemoteDevice remoteDevice = (RemoteDevice) devices.get(i);
        System.out.println("\nDevice: " + remoteDevice.getBluetoothAddress
());
        searchControl.setNotDone();
        discoveryAgent.searchServices(null, null, remoteDevice,
            serviceDiscoveryListener);

        long serviceSearchStart = System.currentTimeMillis();
        while (System.currentTimeMillis() - serviceSearchStart < 
maxWaitMs) {
          Thread.sleep(waitMs);
          // System.out.println("Checking if search is complete");
          if (searchControl.isDone())
            break;
        }

        printRemoteDevice(remoteDevice);
        System.out.println();
      }

Here is the result:

Starting services search

Device: 000eed6542b2
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d7cf51e, pid=4568, 
tid=3052
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_11-b03 mixed mode, sharing)
# Problematic frame:
# V  [jvm.dll+0x8f51e]
#
# An error report file with more information is saved as hs_err_pid4568.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#

I have tried several hardware and software combinations.  The OS in all 
cases is Windows XP with SP2.  It is regularly updated with Microsoft 
fixes.  

The BlueCove jar and the intelbth dll were recently downloaded.  It 
reports version 1.2.2.  

When run on a Dell lap top with built-in Bluetooth card, Dell supplied 
drivers, and the Avetana Bluetooth stack, the programs works as expected.  

The program does not work at all with BlueCove and the Dell supplied stack 
(not expected anyway).  Switching to the Windows SP2 stack allows the 
program to work partially (the device search works) but the services 
search fails as described above.  

I have also tested with a Bluetooth dongle in place of the built-in card.  
The program behaves the same.  

I have tried an HP lap top with no built in Bluetooth with the dongle and 
again the behaviour is the same.  

I have tried several JVM: Sun 1.5.0_11 and 1.4.2_12 and IBM 1.4.1 (failed 
at the same point but different dump data).  

John Lawler
jwlawler@yahoo.com

Original issue reported on code.google.com by jwlaw...@yahoo.com on 27 Apr 2007 at 11:27

GoogleCodeExporter commented 9 years ago
I have managed to find an explanation of the problem.  I traced the problem to 
this 
line:

        discoveryAgent.searchServices(null, null, remoteDevice,
            serviceDiscoveryListener);

The second parameter is an array of UUIDs,  I developed the code initially 
using the 
Avetana implementation and it accepts this parameter as null.  It turns out 
that the 
BlueCove implementation does not accept null for this parameter.  Replacing the 
null 
with

        UUID[] uuidSet = new UUID[1];
        uuidSet[0] = RFCOMM_PROTOCOL_UUID;

solves the problem.  

So, now I explicitly searching for the RFCOMM protocol which is suitable at the 
moment but I wonder how I would search for any service.  

John Lawler
jwlawler@yahoo.com

Original comment by jwlaw...@yahoo.com on 2 May 2007 at 2:48

GoogleCodeExporter commented 9 years ago
I'll fix crashes JVM
But discoveryAgent.searchServices(null, null, ...) Is not valid case!
It is not working on Phone with JSR-82 e.g. SE K790. It is giving NullPointer 
Exception.

Original comment by skarzhev...@gmail.com on 8 May 2007 at 9:49

GoogleCodeExporter commented 9 years ago

Original comment by skarzhev...@gmail.com on 4 Jun 2007 at 6:23