Android bug in API 2.4.0?

The following happens sometimes in Android API 2.4.0. Haven't seen it in earlier versions.

java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.remove(ConcurrentHashMap.java:1068)
at com.mbientlab.metawear.impl.DefaultMetaWearBoard$RouteBuilder$ProcessedDataSignal.unsubscribe(DefaultMetaWearBoard.java:1902)
at com.mbientlab.metawear.impl.DefaultMetaWearBoard$RouteManagerImpl.remove(DefaultMetaWearBoard.java:336)
at com.mbientlab.metawear.impl.DefaultMetaWearBoard$RouteBuilder$37.run(DefaultMetaWearBoard.java:2793)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)

Comments

  • Exists in 2.3.0 also so likely not new.
    1. What are the steps that lead this error?
    2. Can you consistently reproduce said error?
    3. What is the data route you are using?
  • It was a accelerometer data route for boot logging and streaming from a split. It was reproducible and was triggered when doing multiple board resets after each other.
    Now I also see that I get this exception by calling removeRoutes on a board where the setup has failed and no routes have been added. (removeRoutes in DefaultMetawearBoard.java:3809)
  • edited January 2016
    Another one on Android 5.1.1. Hard to know what causes it to occur though. Only happens sometimes. But now 3 different ways it crashes on ProcessedDataSignal.unsubscribe. This was in a setup with multiple boards connected at once. Possible race conditions?

    java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Object.hashCode()' on a null object reference at
    java.util.concurrent.ConcurrentHashMap.replaceNode(ConcurrentHashMap.java:916)
    at java.util.concurrent.ConcurrentHashMap.remove(ConcurrentHashMap.java:907)
    at com.mbientlab.metawear.impl.DefaultMetaWearBoard$RouteBuilder$ProcessedDataSignal.unsubscribe(DefaultMetaWearBoard.java:1902)
    at com.mbientlab.metawear.impl.DefaultMetaWearBoard$RouteManagerImpl.remove(DefaultMetaWearBoard.java:336)
    at com.mbientlab.metawear.impl.DefaultMetaWearBoard$RouteBuilder$37.run(DefaultMetaWearBoard.java:2793)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5254)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697)

  • You earlier mentioned that you were only streaming / logging so it's odd that you are running into errors in the ProcessedDataSignal class.  What is the data route you are using (code, not a description) and what are the steps I need to take to (possibly?) trigger the NPE (ordered list of what I need to do)?
  • Code in short:

    accelModule.routeData().fromAxes().split().branch().log(ACCEL_DATA).branch().process(new Rms()).process(new Comparison(Comparison.Operation.GT, 1)).stream("alarm").end().commit()
    .onComplete(new AsyncOperation.CompletionHandler<RouteManager>() {
    public void failure(Throwable error) {resetBoard();}
    public void success(RouteManager result) {
    result.subscribe("alarm", new RouteManager.MessageHandler() {
    public void process(Message message) {
    loggingModule.downloadLog(0.1f, new Logging.DownloadHandler() {});}});
    result.setLogMessageHandler(ACCEL_DATA, new RouteManager.MessageHandler() {
    public void process(Message message) {}});}});


    resetBoard(){
    mwBoard.removeRoutes();
    debugModule.resetDevice();
    }

    Perhaps possible ways to force a crash:
    * One thread downloading log data
    * One thread resetting board by removing and adding the routes
    * Simultaneously do stream data processing
  • Found one way to make it crash now repeatedly. Add new routes and call disconnect immediately before the routes have been added successfully.
  • Ok, so you do have data processing in your route.  If there were not any, then that would be a more troubling issue.  I setup null pointer checks for unsubscribing from data processors to address the crash.
This discussion has been closed.