connectedhomeip: [SVE] [Android] Crash on Android13

Reproduction steps

I have an esp32-c3 device connected to my Android 13 phone. When the app runs for a while, the app will crash. But I can’t see the specific stack info. Log is as follows:

2022-09-07 10:33:45.374 11967-11979/com.yeelight.yeelight_fluid E/DL: Chip stack locking error at '../../src/transport/Session.h:190'. Code is unsafe/racy
2022-09-07 10:33:45.374 11967-11979/com.yeelight.yeelight_fluid E/-: chipDie chipDie chipDie
    
    --------- beginning of crash
2022-09-07 10:33:45.375 11967-11979/com.yeelight.yeelight_fluid A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 11979 (FinalizerDaemon), pid 11967 (.yeelight_fluid)

Bug prevalence

It crashes every time it starts up for a while。

GitHub hash of the SDK that was being used

f046787fa2c8bd7b55318b5d577665e8f5f47669

Platform

android

Platform Version(s)

Android 13

Type

Platform Issue

Anything else?

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (7 by maintainers)

Most upvoted comments

We did not test it in production yet, but i can confirm that our team did not see the issue since I added that line.

I edited the C++ source code. The issue seems to be solved. Is this the correct way?

ReportCallback::~ReportCallback()
{
    chip::DeviceLayer::StackLock stack;
    
    JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
    VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread"));
    if (mSubscriptionEstablishedCallbackRef != nullptr)
    {
        env->DeleteGlobalRef(mSubscriptionEstablishedCallbackRef);
    }
    env->DeleteGlobalRef(mReportCallbackRef);
    if (mReadClient != nullptr)
    {
        Platform::Delete(mReadClient);
    }
}