• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Crash after receiving IAmRequest NPDU

    BACnet4J general discussion
    2
    4
    1.2k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      Joshua
      last edited by

      Hey there,

      I've managed to get the BACnet4J library running on my Android Things device ( a master on an MS/TP network), communicating with another BACnet device (another master). See my previous question for more info.

      However, when I try to send a WhoIsRequest to the other device, it reads in the response and then my whole application crashes. Here is a log:

      2018-09-27 17:11:57.831 5290-5316/my.company.peripheraltest D/UartOutputStream: bytes written:	[55,ff,6,ff,11,0,4,1a,1,0,10,8,bc,f9]
      2018-09-27 17:11:57.832 5290-5316/my.company.peripheraltest W/System.err: [BACnet4J MS/TP node] DEBUG com.serotonin.bacnet4j.npdu.mstp.MasterNode - 17 doneWithToken:SendMaintenancePFM
      2018-09-27 17:11:57.846 5290-5316/my.company.peripheraltest D/UartOutputStream: bytes written:	[55,ff,1,13,11,0,0,6f]
      2018-09-27 17:11:57.867 5290-5316/my.company.peripheraltest W/System.err: [BACnet4J MS/TP node] DEBUG com.serotonin.bacnet4j.npdu.mstp.MasterNode - 17 pollForMaster:DoneWithPFM
      2018-09-27 17:11:57.881 5290-5316/my.company.peripheraltest D/UartOutputStream: bytes written:	[55,ff,0,18,11,0,0,35]
      2018-09-27 17:11:57.893 5290-5290/my.company.peripheraltest D/UartInputStream: bytes read:		[55,ff,6,ff,18,0,15,41]
      2018-09-27 17:11:57.894 5290-5316/my.company.peripheraltest W/System.err: [BACnet4J MS/TP node] DEBUG com.serotonin.bacnet4j.npdu.mstp.MasterNode - 17 passToken:SawTokenUser
      2018-09-27 17:11:57.902 5290-5290/my.company.peripheraltest D/UartInputStream: bytes read:		[1,20,ff,ff,0,ff,10,0]
      2018-09-27 17:11:57.910 5290-5290/my.company.peripheraltest D/UartInputStream: bytes read:		[c4,2,0,0,7c,22,1,e0]
      2018-09-27 17:11:57.921 5290-5290/my.company.peripheraltest D/UartInputStream: bytes read:		[91,3,22,1,4,83,b8]
      2018-09-27 17:11:57.923 5290-5316/my.company.peripheraltest W/System.err: [BACnet4J MS/TP node] DEBUG com.serotonin.bacnet4j.npdu.mstp.MasterNode - 17 idle:ReceivedDataNoReply
      2018-09-27 17:11:57.925 5290-5316/my.company.peripheraltest W/System.err: [BACnet4J MS/TP node] DEBUG com.serotonin.bacnet4j.npdu.Network - Received NPDU from local network. From=Address [networkNumber=0, macAddress=[18]], local=0
      2018-09-27 17:11:57.929 5290-5316/my.company.peripheraltest W/System.err: [BACnet4J MS/TP node] DEBUG com.serotonin.bacnet4j.npdu.Network - Received NPDU from [18]: NPDU [from=Address [networkNumber=0, macAddress=[18]], linkService=null, queue=[10,0,c4,2,0,0,7c,22,1,e0,91,3,22,1,4]]
      2018-09-27 17:11:57.933 5290-5290/my.company.peripheraltest D/UartInputStream: bytes read:		[55,ff,1,1b,18,0,0,7f]
          
          --------- beginning of crash
      2018-09-27 17:11:57.936 5290-5317/my.company.peripheraltest A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x68 in tid 5317 (BACnet4J transp), pid 5290 (.peripheraltest)
      2018-09-27 17:11:57.985 5322-5322/? I/crash_dump32: type=1400 audit(0.0:643): avc: denied { write } for name="trace_marker" dev="tracefs" ino=47 scontext=u:r:crash_dump:s0:c512,c768 tcontext=u:object_r:debugfs_tracing:s0 tclass=file permissive=1
      2018-09-27 17:11:58.048 5323-5323/? I/crash_dump32: obtaining output fd from tombstoned, type: kDebuggerdTombstone
      2018-09-27 17:11:58.049 196-196/? I//system/bin/tombstoned: received crash request for pid 5290
      2018-09-27 17:11:58.050 5323-5323/? I/crash_dump32: performing dump of process 5290 (target tid = 5317)
      2018-09-27 17:11:58.050 5323-5323/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
      2018-09-27 17:11:58.051 5323-5323/? A/DEBUG: Build fingerprint: 'Things/iot_rpi3/rpi3:8.1.0/OIM1.180327.056/4925377:userdebug/dev-keys'
      2018-09-27 17:11:58.051 5323-5323/? A/DEBUG: Revision: '0'
      2018-09-27 17:11:58.051 5323-5323/? A/DEBUG: ABI: 'arm'
      2018-09-27 17:11:58.051 5323-5323/? A/DEBUG: pid: 5290, tid: 5317, name: BACnet4J transp  >>> my.company.peripheraltest <<<
      2018-09-27 17:11:58.051 5323-5323/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x68
      2018-09-27 17:11:58.051 5323-5323/? A/DEBUG: Cause: null pointer dereference
      ...
      

      The crash and dump are not very useful, but it does say that the cause is a null pointer dereference.

      Although I can't reproduce it right now, sometimes when I run in debug mode in Android Studio, I get a different crash error:

      2018-09-27 17:43:56.784 5998-6025/my.company.peripheraltest E/AndroidRuntime: FATAL EXCEPTION: BACnet4J transport for device 123
          Process: my.company.peripheraltest, PID: 5998
          java.lang.BootstrapMethodError: Exception from call site #50 bootstrap method
              at com.serotonin.bacnet4j.service.unconfirmed.IAmRequest.handle(IAmRequest.java:109)
              at com.serotonin.bacnet4j.transport.DefaultTransport.receiveAPDU(DefaultTransport.java:645)
              at com.serotonin.bacnet4j.transport.DefaultTransport.receiveImpl(DefaultTransport.java:573)
              at com.serotonin.bacnet4j.transport.DefaultTransport.run(DefaultTransport.java:493)
              at java.lang.Thread.run(Thread.java:764)
           Caused by: java.lang.NoClassDefFoundError: Invalid descriptor: ([FLjava/util/Map;Lkotlin/jvm/functions/Function1;)Ljava/util/Map;.
              at com.serotonin.bacnet4j.service.unconfirmed.IAmRequest.handle(IAmRequest.java:109) 
              at com.serotonin.bacnet4j.transport.DefaultTransport.receiveAPDU(DefaultTransport.java:645) 
              at com.serotonin.bacnet4j.transport.DefaultTransport.receiveImpl(DefaultTransport.java:573) 
              at com.serotonin.bacnet4j.transport.DefaultTransport.run(DefaultTransport.java:493) 
              at java.lang.Thread.run(Thread.java:764) 
      

      When I debug, I can get as far as line 109 of IAmRequest (in the handle method). That line is:

      localDevice.execute(() -> { ... });
      

      So I think it's to do with the runnable or something that is happening within the runnable, but I'm not sure. It doesn't get to line 118, which fires the IAmReceived callback.

      I've never seen this type of crash or error before, so any help would be appreciated. Maybe I'm just not setting everything up completely right.

      Here is my code:

      byte thermostatMACAddress = 17;
      int networkNumber = 0;
      int localDeviceId = 123;
      UartInputStream ins = new UartInputStream(uartDevice);
      UartOutputStream outs = new UartOutputStream(uartDevice, txControlPin);
      MasterNode thermostatNode = new MasterNode("UART", ins, outs, thermostatMACAddress, 1);
      MstpNetwork network = new MstpNetwork(thermostatNode, networkNumber);
      DefaultTransport transport = new DefaultTransport(network);
      localDevice = new LocalDevice(localDeviceId, transport);
      try {
          localDevice.initialize();
          localDevice.getEventHandler().addListener(new Listener());
          localDevice.sendLocalBroadcast(new WhoIsRequest());
      } catch (Exception e) {
          e.printStackTrace();
      }
      
      1 Reply Last reply Reply Quote 0
      • phildunlapP
        phildunlap
        last edited by

        @joshua said in Crash after receiving IAmRequest NPDU:

        The crash and dump are not very useful, but it does say that the cause is a null pointer dereference.

        That it is a SIGSEGV (segmentation violation) tells you that it's probably a null pointer dereferenced in some native code. Usually if I see a SIGSEGV I update Java if possible. An NPE in Java is just an exception, it doesn't arouse the OS to kill the process as an NPE in native code can. I guess in this case it would be update Kotlin. I am not sure of BACnet4J's compatibility or having been tested against Kotlin / Android. Do you know what version of Java this is running on? Is that the same JVM you're debugging against?

        So I think it's to do with the runnable or something that is happening within the runnable, but I'm not sure. It doesn't get to line 118, which fires the IAmReceived callback.

        I think it's related to versions. Your code looks fine. Certainly doesn't look like you are doing anything to cause a NoClassDefFoudError or a SIGSEGV, so I have to think there could be a compatibility issue with the JVM you're using, or a bug in that version of it.

        J 1 Reply Last reply Reply Quote 0
        • J
          Joshua @phildunlap
          last edited by

          @phildunlap

          You were right, my Kotlin dependency was using the java 7 stdlib, not 8. That's why it complained and crashed at the lambda.

          I will remember your tip about SIGSEGV in the future!

          Thank you.

          1 Reply Last reply Reply Quote 0
          • phildunlapP
            phildunlap
            last edited by

            Certainly! Thanks for sharing the resolution!

            1 Reply Last reply Reply Quote 0
            • First post
              Last post