Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to investigate and fix libpjsua2.so crash

SIGSEGV SEGV_MAPERR at 0x00000008

0  libpjsua2.so                   0x56585a88 pj::Call::getInfo() const
1  libpjsua2.so                   0x56546b44 std::allocator<pj::CallMediaInfo>::allocator()

I'm using pjsip for one of my hobby project(complies with GPL). Above you can see the stacktrace received from crashlytics. I'm using Java wrapper for pjsip.

There are a lot of users(50 %) affected by this error, however I'm not able to reproduce it on my local devices.

Not sure but I suspect that following java call lead to error. Which call C++ via JNI

public void notifyCallState(MyCall call) {
    if (currentCall == null || call.getId() != currentCall.getId())
        return;

    CallInfo ci;
    try {
        ci = call.getInfo();
    } catch (Exception e) {
        ci = null;
    }
    Message m = Message.obtain(handler, MSG_TYPE.CALL_STATE, ci);
    m.sendToTarget();

    if (ci != null && ci.getState() == pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED) {
        currentCall = null;
    }
}

Code snippet is taken from examples which come from psjua download. Link to http repo. My code is the same. Any help highly appreciated

like image 369
user12384512 Avatar asked Nov 01 '22 01:11

user12384512


1 Answers

From the stacktrace is looks like call is null, and getId method is at 0x8 offset.

If that's really the case, the fix is to make sure notifyCallState isn't called with null argument, or to check it inside the method, i.e.:

if (call == null || currentCall == null || call.getId() != currentCall.getId())
    return;
like image 114
domen Avatar answered Nov 15 '22 04:11

domen