Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Library.close SIGSEGV on Android
14-12-2013, 03:08 PM
Post: #1
Library.close SIGSEGV on Android
Hello,

My Android app is crashing on library.close call.

Please, see my code below:

ohNet objects initialization:

Code:
InitParams initParams = new InitParams();
        
        initParams.setMsearchTimeSecs(1);
        initParams.setDvServerPort(0);
        initParams.setFatalErrorHandler(new IMessageListener() {
            @Override
            public void message(String msg) {
                logger.severe(msg);
            }
        });
        initParams.setLogOutput(new IMessageListener() {
            @Override
            public void message(String msg) {
                logger.log(Level.INFO, msg);
            }
        });
                
        library = new Library();
        library.initialise(initParams);
        library.setDebugLevel(DEBUG_LEVEL);
    
        NetworkAdapter currentSubnet = null;
        
        SubnetList subnetList = new SubnetList();
        logger.finest("subnets: ");
        for (int n = 0; n < subnetList.size(); n++) {
            NetworkAdapter subnet = subnetList.getSubnet(n);
            logger.finest(subnet.getName() + " address " + subnet.getAddress() + " subnet " + subnet.getSubnet() + " mask " + subnet.getMask());
            
            
            if (subnet.getSubnet().equals(address)) {
            //if (subnet.getAddress().equals(address)) {
                currentSubnet = subnet;
            }
        }
        subnetList.destroy();
        
        library.startCombined(address);
        
        // TODO: what to do if subnet is not found?
        if (currentSubnet != null) {
            library.setCurrentSubnet(currentSubnet);
        }
        else {
            logger.severe("start: address " + address + " is not found in ohNet's subnets list");
        }
        
        DeviceInfo deviceInfo = localDevice.getDeviceInfo();

        device = new DvDeviceStandard(deviceInfo.getDeviceID());
        device.setAttribute("Upnp.Domain", "upnp.org");
        device.setAttribute("Upnp.Type", UPNP_DEVICE_TYPE);
        device.setAttribute("Upnp.Version", ""+UPNP_DEVICE_TYPE_VERSION);
        device.setAttribute("Upnp.FriendlyName", deviceInfo.getDeviceName());
        device.setAttribute("Upnp.Manufacturer", deviceInfo.getManufacturer());
        device.setAttribute("Upnp.ModelName", deviceInfo.getModel());

        peerProvider = new PeerProvider(device);
        peerProvider.setupValues(deviceInfo);
        
        device.setEnabled();


ohNet objects destruction, in which SIGSEGV occurs:

Code:
if (list != null) {
            logger.finest("stop: list.destroy");

            list.destroy();
            list = null;
        }

        // TODO: bug! crashes on Android
        final Object lock = new Object();
        logger.finest("stop: device.setDisabled");
        device.setDisabled(new IDvDeviceListener() {
            @Override
            public void deviceDisabled() {
                synchronized (lock) {
                    logger.finest("stop: deviceDisabled");
                    lock.notify();
                }
            }
        });

        synchronized (lock) {
            try {
                lock.wait();
                logger.finest("stop: deviceDisabled wait finished");
            }
            catch (InterruptedException e) {
                logger.severe("stop: interrupted, when waiting for device disable");
            }
        }

        logger.finest("stop: peerProvider.dispose");
        peerProvider.dispose();
        logger.finest("stop: device.destroy");
        device.destroy();

        logger.finest("stop: library.close");
        library.close();

Where
list is a CpDeviceList
device is my DvStandardDevice
peerProvider is my own class derived from DvProvider

First time, i thinked, that PeerProvider caused the problem. Disabling it has no effect - close call still crashes.

I tried various methods to find, what cause this problem.
And i found, that if i remove DvDevice.setDisabled call (it's called before destroying ohNet objects and closing library), library.close call executed without SIGSEGV.

SIGSEGV also occurs when scan is in progress (list != null).

This code executes on Java desktop app without any errors.

Thanks in advance!

Best regards.
Find all posts by this user
17-12-2013, 04:27 PM
Post: #2
RE: Library.close SIGSEGV on Android
We've been trying to reproduce the issue from your code snippets, but haven't yet been able to.

Would you be able to post a complete, but concise, example application that exhibits just the problem you describe to help us investigate the issue further?
Find all posts by this user
17-12-2013, 04:57 PM
Post: #3
RE: Library.close SIGSEGV on Android
Thanks for your answer.

Ok, i'll take UPnP code from my app, and send you it as example application.

Also, it can be NDK version specific bug. What NDK version are you using?
If it's differs from that i use, i'll try to use your version.

Best regards.
Find all posts by this user
18-12-2013, 09:08 AM
Post: #4
RE: Library.close SIGSEGV on Android
We are currently using r9 of the NDK.

We have also been using the latest ohNet releases, if that is different from the version(s) you have been using.
Find all posts by this user
19-12-2013, 05:49 AM
Post: #5
RE: Library.close SIGSEGV on Android
I'm using NDK R8D. Will try on NDK R9.
Find all posts by this user


Forum Jump: