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

Crash when placing call #4073

Closed
pwinckles opened this issue Sep 12, 2024 · 2 comments · Fixed by #4074
Closed

Crash when placing call #4073

pwinckles opened this issue Sep 12, 2024 · 2 comments · Fixed by #4074

Comments

@pwinckles
Copy link

pwinckles commented Sep 12, 2024

Describe the bug

I am using the Java pjsua2 bindings. I noticed when I built off head that the application segfaults when I place a call. This crash does not happen on 2.13.1 or 2.14.1. I did a bisect and identified that the crash was introduced by this commit: aa56436

The setup is two accounts registered to a PBX and one of the accounts attempts to place a call to the other.

Steps to reproduce

import org.pjsip.pjsua2.*;

import java.util.concurrent.TimeUnit;

public class Sample {

    static {
        pjsua2JNI.class.getName();
    }

    private static class TestAccount extends Account {

        private final String uri;
        private final String user;
        private final String password;
        private final String registrarUri;

        private TestAccount(String uri, String user, String password, String registrarUri) {
            this.uri = uri;
            this.user = user;
            this.password = password;
            this.registrarUri = registrarUri;
        }

        void create() throws Exception {
            var pjsipConfig = new AccountConfig();
            pjsipConfig.setIdUri(uri);
            pjsipConfig.getRegConfig().setRegistrarUri(registrarUri);
            pjsipConfig
                    .getSipConfig()
                    .getAuthCreds()
                    .add(new AuthCredInfo("digest", "*", user, 0, password));
            create(pjsipConfig);
        }
    }

    private static class TestCall extends Call {
        public TestCall(Account acc) {
            super(acc);
        }
    }

    public static void main(String[] args) throws Exception {
        var host = "";
        var registrarUri = "sip:%s:5160;transport=tcp".formatted(host);
        var usr1 = "";
        var pwd1 = "";
        var usr2 = "";
        var pwd2 = "";

        var ep = createEndpoint();

        try {
            var acc1 = new TestAccount("sip:101@%s:5160".formatted(host), usr1, pwd1, registrarUri);
            var acc2 = new TestAccount("sip:102@%s:5160".formatted(host), usr2, pwd2, registrarUri);

            acc1.create();
            acc2.create();

            var call = new TestCall(acc1);
            call.makeCall("sip:102@%s:5160;transport=tcp".formatted(host), new CallOpParam());

            TimeUnit.SECONDS.sleep(30);

            call.delete();
            acc1.delete();
            acc2.delete();
        } finally {
            try {
                ep.libDestroy();
                ep.delete();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    private static Endpoint createEndpoint() {
        var ep = new Endpoint();
        try {
            ep.libCreate();
            var epConfig = new EpConfig();
            epConfig.getLogConfig().setLevel(6);
            epConfig.getLogConfig().setConsoleLevel(6);
            epConfig.getUaConfig().setUserAgent("Test/1.0");
            ep.libInit(epConfig);

            var transportConfig = new TransportConfig();
            transportConfig.setPort(5060);
            ep.transportCreate(pjsip_transport_type_e.PJSIP_TRANSPORT_TCP, transportConfig);

            ep.libStart();
        } catch (Exception e) {
            e.printStackTrace();
            try {
                ep.libDestroy();
                ep.delete();
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }
        return ep;
    }

}

PJSIP version

Broken starting at aa56436

Context

  • ARM Mac
  • SWIG 4.2.1
  • Java 21
  • Configuration flags: --disable-video --disable-sdl --disable-ffmpeg --disable-v4l2 --disable-openh264 --disable-ssl --disable-darwin-ssl --enable-kqueue CFLAGS="-fPIC"
  • config_site.h contents:
#define PJSUA_MAX_ACC                       300
#define PJSUA_MAX_CALLS                     100
#define PJSUA_MAX_PLAYERS                   PJSUA_MAX_CALLS
#define PJSUA_MAX_RECORDERS                 PJSUA_MAX_CALLS
#define PJSUA_MAX_CONF_PORTS                (PJSUA_MAX_CALLS+2*PJSUA_MAX_PLAYERS)
#define PJSUA_MAX_BUDDIES                   0
#define PJ_IOQUEUE_MAX_HANDLES              (PJSUA_MAX_CALLS * 3)
#define PJ_HAS_IPV6 1

Log, call stack, etc

Logs:


12:22:40.884           pjsua_call.c !Making call with acc #1 to sip:102@[REDACTED]:5160;transport=tcp
12:22:40.884            pjsua_aud.c  .Set sound device: capture=-1, playback=-2, mode=0, use_default_settings=0
12:22:40.884            pjsua_aud.c  ..Opening sound device (speaker + mic) PCM@16000/1/20ms
12:22:40.884        coreaudio_dev.c  ...Using VoiceProcessingIO audio unit
12:22:40.884        coreaudio_dev.c  ...Warning: audio device id settings are ignored when using VPIO
12:22:43.388        coreaudio_dev.c  ...core audio stream started
12:22:43.389         dlg0x13e3c48a8  .UAC dialog created
12:22:43.394        coreaudio_dev.c !Player thread started, (107 frames)
12:22:43.394         os_core_unix.c  Info: possibly re-registering existing thread
12:22:43.394        coreaudio_dev.c !Recorder thread started, (106 frames)

Call stack:

C  [pjsua2-2757382263470969104.tmp+0xccbb4]  pjsua_call_make_call+0x63c
C  [pjsua2-2757382263470969104.tmp+0xa8f88]  pj::Call::makeCall(std::__1::basic_string<char, std::__1::char_traits<char>, std::__
1::allocator<char>> const&, pj::CallOpParam const&)+0x80
C  [pjsua2-2757382263470969104.tmp+0x58228]  Java_org_pjsip_pjsua2_pjsua2JNI_Call_1makeCall+0x150
j  org.pjsip.pjsua2.pjsua2JNI.Call_makeCall(JLorg/pjsip/pjsua2/Call;Ljava/lang/String;JLorg/pjsip/pjsua2/CallOpParam;)V+0
j  org.pjsip.pjsua2.Call.makeCall(Ljava/lang/String;Lorg/pjsip/pjsua2/CallOpParam;)V+11
@sauwming
Copy link
Member

sauwming commented Sep 13, 2024

It should have been fixed in #4073, no? (Yes, sorry, it should be #4056)

@pwinckles
Copy link
Author

@sauwming I assume you mean #4056? If so, then no. The crash still happens on head.

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