[asterisk-bugs] [JIRA] (ASTERISK-21046) res_xmpp refcount issue

Matt Jordan (JIRA) noreply at issues.asterisk.org
Thu Feb 14 06:35:58 CST 2013


    [ https://issues.asterisk.org/jira/browse/ASTERISK-21046?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=202935#comment-202935 ] 

Matt Jordan commented on ASTERISK-21046:
----------------------------------------

There's a memory leak here, but not an object ref leak.

Your ref count log shows a large number of (+1) references to the object, but you'll note that the overall ref count on the object never increases:

{noformat}
0xa38281c +1   res_xmpp.c:3432:xmpp_client_reconnect () [@1]
0xa38281c +1   res_xmpp.c:3432:xmpp_client_reconnect () [@1]
0xa38281c +1   res_xmpp.c:3432:xmpp_client_reconnect () [@1]
0xa38281c +1   res_xmpp.c:3432:xmpp_client_reconnect () [@1]
0xa38281c +1   res_xmpp.c:3432:xmpp_client_reconnect () [@1]
0xa38281c +1   res_xmpp.c:3432:xmpp_client_reconnect () [@1]
0xa38281c +1   res_xmpp.c:3432:xmpp_client_reconnect () [@1]
0xa38281c +1   res_xmpp.c:3432:xmpp_client_reconnect () [@1]
{noformat}

That's because this particular variable is being managed by {{RAII_VAR}}, which will automatically call {{ao2_cleanup}} when the variable loses scope in {{xmpp_client_reconnect}}. {{ao2_cleanup}} is defined in {{astobj2.h}}, so you'll need to enable ref count debugging there in order to see the ref count drops.

Your log shows that the ref count drops to 0 when the module is unloaded:

{noformat}
0xa38281c -1   res_xmpp.c:4263:unload_module () [@1] 
{noformat}

There is a memory leak, however, here:

{code}
	if (!client->filter && !(client->filter = iks_filter_new())) {
		ast_log(LOG_ERROR, "Could not create IKS filter for client connection '%s'\n", client->name);
		return -1;
	}

        ...

	if (res == IKS_NET_NOCONN) {
		ast_log(LOG_ERROR, "No XMPP connection available when trying to connect client '%s'\n", client->name);
		return -1;
	} else if (res == IKS_NET_NODNS) {
		ast_log(LOG_ERROR, "No DNS available for XMPP connection when trying to connect client '%s'\n", client->name);
		return -1;
	}

{code}

We should be calling {{iks_filter_delete(client->filter);}} on the off nominal paths. Otherwise we'll continue to leak the filters on each subsequent connect attempt.
                
> res_xmpp refcount issue
> -----------------------
>
>                 Key: ASTERISK-21046
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-21046
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Resources/res_xmpp
>    Affects Versions: 11.2.1
>         Environment: i386 Linux
>            Reporter: marcelloceschia
>            Severity: Critical
>         Attachments: res_xmpp-refcount-issue.txt
>
>
> xmpp_client_reconnect does not release obj reference

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira



More information about the asterisk-bugs mailing list