kcp icon indicating copy to clipboard operation
kcp copied to clipboard

ikcp_release crash in android

Open nikohpng opened this issue 10 months ago • 4 comments

Description

I meet it in android when I call ikcp_release method. maybe I have a error usage,someone can give me some suggestion?

Version

libkcp this version maybe old, but I have compare lastest ikcp, have no any big change.

Stack

Build fingerprint: 'HUAWEI/BLA-AL00/HWBLA:10/HUAWEIBLA-AL00/10.0.0.175C00:user/release-keys'
Revision: '0'
ABI: 'arm64'
SYSVMTYPE: Maple
APPVMTYPE: Art
Timestamp: 2025-01-23 15:17:01+0800
pid: 1660, tid: 1660, name: example.sdkdemo  >>> com.example.sdkdemo <<<
uid: 10216
signal 11 (SIGSEGV), code 0 (SI_USER), fault addr --------
    x0  0000000000000000  x1  000000000000000b  x2  0000007e600a702d  x3  0000007e70b8bdd0
    x4  000000000000067c  x5  0000000000000a18  x6  0000007f58c7f000  x7  000000000067a5a2
    x8  0000000000000081  x9  5ac2e86c936621d5  x10 0000006485e613e8  x11 0000007f58cd701c
    x12 0000000000000058  x13 00000000fa000000  x14 0009e793d93c013d  x15 000013726f2a9dec
    x16 0000007e600c0cb8  x17 0000007f55ac6880  x18 0000007f588ce000  x19 000000000000000b
    x20 0000007e600a85b1  x21 0000007e70b8bdd0  x22 000000000000067c  x23 0000000000000000
    x24 0000007e600f8f18  x25 0000007f579c5020  x26 0000007e600f9030  x27 0000006485e61000
    x28 0000000018000004  x29 0000007eba75c140
    sp  0000007eba75c0a0  lr  0000007e6008b54c  pc  0000007f55ac6888

backtrace:
      #00 pc 00000000000bb888  /apex/com.android.runtime/lib64/bionic/libc.so (kill+8) (BuildId: b91c775ccc9b0556e91bc575a2511cd0)
      #01 pc 0000000000009548  /data/app/com.example.sdkdemo-y80BX0J4iay1x3XA-JgTFw==/lib/arm64/libBugly_Native.so (BuildId: b9c637d9e30c4ad0f33ec781b10389b2453ce17f)
      #02 pc 0000000000004cb8  /system/bin/app_process64 (art::SignalChain::Handler(int, siginfo*, void*)+352) (BuildId: e844be217eb39b34490d3798328d1f12)
      #03 pc 0000000000000638  [vdso] (__kernel_rt_sigreturn)
      #04 pc 00000000008e2a30  /data/app/com.example.sdkdemo-y80BX0J4iay1x3XA-JgTFw==/lib/arm64/libonesip.so (ikcp_release+140) (BuildId: 9785b490b670210163b41b6d23e825724d6702c1)
      #05 pc 00000000008dddb0  /data/app/com.example.sdkdemo-y80BX0J4iay1x3XA-JgTFw==/lib/arm64/libonesip.so (UDPSession::Destroy(UDPSession*)+80) (BuildId: 9785b490b670210163b41b6d23e825724d6702c1)
      #06 pc 00000000008dc670  /data/app/com.example.sdkdemo-y80BX0J4iay1x3XA-JgTFw==/lib/arm64/libonesip.so (Session_C_Destroy+20) (BuildId: 9785b490b670210163b41b6d23e825724d6702c1)

nikohpng avatar Feb 05 '25 04:02 nikohpng

are you using one kcp object in different threads?

skywind3000 avatar Feb 05 '25 08:02 skywind3000

are you using one kcp object in different threads?

when I use it , i will lock it. this is my code , like this

      // this will call pthread_mutex_lock, I have open PTHREAD_MUTEX_RECURSIVE
        status = lock_acquire(tp->timer_lock);
        if (status != SUCCESS) {
            LOG(4, ("kcp session restarted failed, lock is null"));
            return status;
        }
        itr = hash_first(tp->all_sess, &itr_val);
        char key[0x50] = {'\0'};
        while (itr) {
            void *entry = hash_this(tp->all_sess, itr);
            const char *k = Session_C_GetAddrStr(entry);
            memcpy(key, k, ansi_strlen(k));
            LOG(5, (THIS_FILE, "kcp restart session: %s, %d ready to release it", key, ansi_strlen(key)));
            Session_C_Destroy(entry);
            entry = NULL;
            hash_set(NULL, tp->all_sess, key, ansi_strlen(key), 0, entry);
            itr = hash_next(tp->all_sess, itr);
        }
        status = lock_release(tp->timer_lock);
        if (status != SUCCESS) {
            LOG(4, (tp->base.obj_name,"SIP kcp session restarted failed, lock release is null"));
            return status;
        }

and This crash only occurs once on Huawei phones. At present, there is no recurrence

nikohpng avatar Feb 05 '25 09:02 nikohpng

It has nothing to do with specific hardware, pure algorithm code.

skywind3000 avatar Feb 06 '25 02:02 skywind3000

It has nothing to do with specific hardware, pure algorithm code.

I know. I have found a crash fix in latest issue, It may be caused by it.

nikohpng avatar Feb 06 '25 02:02 nikohpng