Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] OnCommissioningComplete handling in AndroidDeviceControllerWrapper.cpp occasionally crashes #13556

Closed
g-coppock opened this issue Jan 13, 2022 · 1 comment · Fixed by #13557

Comments

@g-coppock
Copy link
Contributor

Problem

When commissioning on Android, an issue is occasionally seen when OnCommissioningComplete is invoked. The general steps are:

  1. BLE Connect (m5stack in this case)
  2. EstablishPASEConnection
  3. Commission (using Wi-Fi credentials)

After receiving the response to the CommissioningComplete command, a crash is seen:

2022-01-13 16:54:45.459 10789-10904 D/DMG: Received Command Response Data, Endpoint=0 Cluster=0x0000_0030 Command=0x0000_0005
2022-01-13 16:54:45.459 10789-10904 D/ZCL: CommissioningCompleteResponse:
2022-01-13 16:54:45.459 10789-10904 D/ZCL:   errorCode: 0
2022-01-13 16:54:45.459 10789-10904 D/ZCL:   debugText: 
2022-01-13 16:54:45.459 10789-10904 D/CTL: Received success response 0x0
2022-01-13 16:54:45.459 10789-10904 D/CTL: Rendezvous cleanup
2022-01-13 16:54:45.461 10789-10904 V/ChipController: onCommissioningComplete(32A2BD0AEE5E34F7, 0) [CONTEXT forced=true service_id=288 ]
2022-01-13 16:54:45.462 10789-10904 A/java_vm_ext.cc:579] JNI DETECTED ERROR IN APPLICATION: jarray argument has non-array type: java.lang.Class<dalvik.annotation.optimization.CriticalNative>
    java_vm_ext.cc:579]     in call to ReleaseByteArrayElements

When debugging, the line on which the crash is occurring is:

https://github.com/project-chip/connectedhomeip/blob/master/src/controller/java/AndroidDeviceControllerWrapper.cpp#L395

if (operationalDatasetBytes != nullptr)
{
    env->ReleaseByteArrayElements(operationalDatasetBytes, operationalDataset, 0); // This line
    env->DeleteGlobalRef(operationalDatasetBytes);
}

It seems to indicate that operationalDatasetBytes is non-null. However, this is on the Wi-Fi commissioning path, and via logging I've verified that the line which assigns operationalDatasetBytes is never reached.

@mspang
Copy link
Contributor

mspang commented Jan 13, 2022

diff --git a/src/controller/java/AndroidDeviceControllerWrapper.h b/src/controller/java/AndroidDeviceControllerWrapper.h
index 02c26e1a1..a556ce550 100644
--- a/src/controller/java/AndroidDeviceControllerWrapper.h
+++ b/src/controller/java/AndroidDeviceControllerWrapper.h
@@ -120,12 +120,12 @@ private:
     bool mNodeIdRequested             = false;
 
     // These fields allow us to release the string/byte array memory later.
-    jstring ssidStr;
-    jstring passwordStr;
-    const char * ssid;
-    const char * password;
-    jbyteArray operationalDatasetBytes;
-    jbyte * operationalDataset;
+    jstring ssidStr = nullptr;
+    jstring passwordStr = nullptr;
+    const char * ssid = nullptr;
+    const char * password = nullptr;
+    jbyteArray operationalDatasetBytes = nullptr;
+    jbyte * operationalDataset = nullptr;
 
     AndroidDeviceControllerWrapper(ChipDeviceControllerPtr controller) : mController(std::move(controller))
     {

?

g-coppock added a commit to g-coppock/connectedhomeip that referenced this issue Jan 13, 2022
g-coppock added a commit to g-coppock/connectedhomeip that referenced this issue Jan 13, 2022
g-coppock added a commit to g-coppock/connectedhomeip that referenced this issue Jan 13, 2022
Fixes project-chip#13556

Tested locally on an Android device on the reported code path without a crash.
andy31415 pushed a commit that referenced this issue Jan 14, 2022
…#13557)

Fixes #13556

Tested locally on an Android device on the reported code path without a crash.
selissia pushed a commit to selissia/connectedhomeip that referenced this issue Jan 28, 2022
…project-chip#13557)

Fixes project-chip#13556

Tested locally on an Android device on the reported code path without a crash.
step0035 pushed a commit to hank820/connectedhomeip that referenced this issue Feb 8, 2022
…project-chip#13557)

Fixes project-chip#13556

Tested locally on an Android device on the reported code path without a crash.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants