Memory allocation problem - PJSIP 1.12 / iOS 5.0 - device & simulator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Loki,

Well, the code snippet looks OK so the crash is likely to be caused by
something else. If you can make a very small program to reproduce the
issue, it will be great. Or at least tell us what you did before
calling the function sip_login().

Regards,
Ming

On Fri, Jan 27, 2012 at 8:50 AM, loki der quaeler <quaeler at gmail.com> wrote:
> Hello -
>
> I'm seeing memory allocation issues in iOS (5.0) with PJSIP 1.12; I see this in both the simulator and the device. I do not see this in the 1.8 compiles we've been using for some time now.
>
>
> I compiled PJSIP 1.12 with the default CFLAGS, LDFLAGS and ARCH (CFLAGS="-O2 -Wno-unused-label", LDFLAGS="-O2", ARCH="-arch armv7") for the device libraries and a slight modification of those to get the compile to work for the simulator of (CFLAGS="-O2 -m32 -miphoneos-version-min=3.0", LDFLAGS="-O2 -m32").
>
>
>
> The issue occurs identically on both device and simulator; stepping through the debugger i can watch it happen. In this code sitting on top of PJSIP:
>
> ? ? ? ? ? ? ? ?pj_status_t sip_login(char *sip_url, char *id_url, char *username, char *password, pjsua_acc_id *acc_id_ref)
> ? ? ? ? ? ? ? ?{
> ? ? ? ? ? ? ? ? ? ? ? ?pjsua_acc_config cfg;
>
> ? ? ? ? ? ? ? ? ? ? ? ?pjsua_acc_config_default(&cfg);
> ? ? ? ? ? ? ? ? ? ? ? ?cfg.id = pj_str(id_url);
> ? ? ? ? ? ? ? ? ? ? ? ?cfg.reg_uri = pj_str(sip_url);
> ? ? ? ? ? ? ? ? ? ? ? ?cfg.cred_count = 1;
> ? ? ? ? ? ? ? ? ? ? ? ?cfg.cred_info[0].realm = pj_str("*");
> ? ? ? ? ? ? ? ? ? ? ? ?cfg.cred_info[0].scheme = pj_str("digest");
> ? ? ? ? ? ? ? ? ? ? ? ?cfg.cred_info[0].username = pj_str(username);
> ? ? ? ? ? ? ? ? ? ? ? ?cfg.cred_info[0].data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
> ? ? ? ? ? ? ? ? ? ? ? ?cfg.cred_info[0].data = pj_str(password);
>
> ? ? ? ? ? ? ? ? ? ? ? ?return pjsua_acc_add(&cfg, PJ_TRUE, acc_id_ref);
> ? ? ? ? ? ? ? ?}
>
> prior to calling pjsua_acc_config_default(?), both password and acc_id_ref are populated correctly and point to a believable location in memory space. After stepping over pjsua_acc_config_default(?):
> ? ? ? ?- acc_id_ref suddenly points to 0x0 in memory space
> ? ? ? ?- password suddenly points to 0x1 in memory space
>
>
> If i modify this code to malloc cfg ahead of time like this:
>
> ? ? ? ? ? ? ? ?pj_status_t sip_login(char *sip_url, char *id_url, char *username, char *password, pjsua_acc_id *acc_id_ref)
> ? ? ? ? ? ? ? ?{
> ? ? ? ? ? ? ? ? ? ? ? ?pjsua_acc_config *cfg = (pjsua_acc_config *)malloc(sizeof(pjsua_acc_config));
>
> ? ? ? ? ? ? ? ? ? ? ? ?pjsua_acc_config_default(cfg);
> ? ? ? ? ? ? ? ? ? ? ? ?cfg->id = pj_str(id_url);
> ? ? ? ? ? ? ? ? ? ? ? ?cfg->reg_uri = pj_str(sip_url);
> ? ? ? ? ? ? ? ? ? ? ? ?cfg->cred_count = 1;
> ? ? ? ? ? ? ? ? ? ? ? ?cfg->cred_info[0].realm = pj_str("*");
> ? ? ? ? ? ? ? ? ? ? ? ?cfg->cred_info[0].scheme = pj_str("digest");
> ? ? ? ? ? ? ? ? ? ? ? ?cfg->cred_info[0].username = pj_str(username);
> ? ? ? ? ? ? ? ? ? ? ? ?cfg->cred_info[0].data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
> ? ? ? ? ? ? ? ? ? ? ? ?cfg->cred_info[0].data = pj_str(password);
>
> ? ? ? ? ? ? ? ? ? ? ? ?return pjsua_acc_add(cfg, PJ_TRUE, acc_id_ref);
> ? ? ? ? ? ? ? ?}
>
> then i am merely whacking a mole and i now see another problem of rancid memory crop up shortly thereafter in the application lifecycle, during a callback in code:
>
> ? ? ? ? ? ? ? ?static void on_transport_state(pjsip_transport *tp,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? pjsip_transport_state state,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const pjsip_transport_state_info *info)
> ? ? ? ? ? ? ? ?{
> ? ? ? ? ? ? ? ? ? ?char host_port[128];
>
> ? ? ? ? ? ? ? ? ? ?pj_ansi_snprintf(host_port, sizeof(host_port), "[%.*s:%d]",
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (int)tp->remote_name.host.slen,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? tp->remote_name.host.ptr,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? tp->remote_name.port);
> ? ? ? ? ? ? ? ?...
>
> where tp shows up with an address in memory of 0x2
>
>
> Has anyone heard of something like this occurring / does anyone have any ideas?
>
> (Thanks much!)
>
>
> _______________________________________________
> Visit our blog: http://blog.pjsip.org
>
> pjsip mailing list
> pjsip at lists.pjsip.org
> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org



[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux