Hi,
I’m new to pjsip and developing an ios app with callkit.
I’m using the trunk version of pjsip to make sure we handle callkit. Recently I started getting a crash at startup when calling pjsua_acc_add.
The error I get is:
malloc: *** mach_vm_map(size=105553116389376) failed (error code=3)
*** error: can't allocate region
I have traced it back to the changes that were done in r5455. My code works ok with r5454, but crashes with code r5455.
In reviewing the call stack the crash seems to happen at the following instruction (in the function pjsua_acc_config_dup, file: pjsua_acc.c):
pj_memcpy(dst, src, sizeof(pjsua_acc_config));
So it seems the additions that were made to the pjsua_acc_config structure are somehow causing the size of the struct to not calculate properly.
Can anybody help in identifying this issue in the pjsip code?
Here is my startup code for reference:
pjsua_acc_id acc_id;
/* Create pjsua first! */
status = pjsua_create();
if (status != PJ_SUCCESS) {
// Log Error
return;
}
/* Init pjsua */
pjsua_config_default(&cfg);
cfg.cb.on_reg_state = &on_reg_state;
cfg.cb.on_call_state = &on_call_state;
cfg.cb.on_incoming_call = &on_incoming_call;
cfg.cb.on_call_media_state = &on_call_media_state;
cfg.cb.on_call_tsx_state = &on_call_tsx_state;
cfg.stun_host = pj_str("stun.l.google.com <http://stun.l.google.com/>:19302");
cfg.max_calls=1;
pjsua_media_config_default(&media_cfg);
media_cfg.no_vad = 1;
pjsua_logging_config_default(&log_cfg);
log_cfg.console_level = kPJSUA_LOG_LEVEL;
log_cfg.level = kPJSUA_LOG_LEVEL;
status = pjsua_init(&cfg, &log_cfg, &media_cfg);
if (status != PJ_SUCCESS) {
// Log Error
return;
}
/* Add TCP transport. */
pjsua_transport_config_default(&transport_cfg);
transport_cfg.port = kPJSUA_DEFAULT_PORT;
status = pjsua_transport_create(PJSIP_TRANSPORT_TCP, &transport_cfg, NULL);
if (status != PJ_SUCCESS) {
// Log Error
return;
}
/* Initialization is done, now start pjsua */
status = pjsua_start();
if (status != PJ_SUCCESS) {
// Log Error
return;
}
/* Register to SIP server by creating SIP account. */
pjsua_acc_config_default(&acc_cfg);
acc_cfg.id = pj_str("sip:username@host;transport=tcp");
acc_cfg.reg_uri = pj_str("sip:host;transport=tcp");
acc_cfg.cred_count = 1;
acc_cfg.cred_info[0].realm = pj_str("*");
acc_cfg.cred_info[0].scheme = pj_str("Digest");
acc_cfg.cred_info[0].data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
acc_cfg.cred_info[0].data = pj_str(sipPasscode);
acc_cfg.cred_info[0].username = pj_str(sipUsername);
status = pjsua_acc_add(&acc_cfg, PJ_SUCCESS, &acc_id);
Dirar Abu-Saymeh
+1 703 880 2225
dirar.abusaymeh@vectrafon.com