[asterisk-bugs] [JIRA] (ASTERISK-27299) Asterisk Hangs with Bad file descriptor on read()

Richard Mudgett (JIRA) noreply at issues.asterisk.org
Mon Dec 18 10:40:07 CST 2017


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

Richard Mudgett edited comment on ASTERISK-27299 at 12/18/17 10:38 AM:
-----------------------------------------------------------------------

I found a place that will close the FD twice. Asterisk 13.16.0 support rtcp-mux feature so rtcp use the same UDP port of rtp. But in res_rtp_asterisk.c function ast_rtp_destroy, we don't check if rtcp->s == rtp->s and close it twice, if in heavy load, free the FD twice will lead the Bad file descriptor issue. I will fix it in my production platform, and patch it to the gerrit. Thanks all the people watching this.

look at this code.
{noformat}
	/* Close our own socket so we no longer get packets */
	if (rtp->s > -1) {
		close(rtp->s);
	}

	/* Destroy RTCP if it was being used */
	if (rtp->rtcp) {
		/*
		 * It is not possible for there to be an active RTCP scheduler
		 * entry at this point since it holds a reference to the
		 * RTP instance while it's active.
		 */
		close(rtp->rtcp->s);
		ast_free(rtp->rtcp->local_addr_str);
		ast_free(rtp->rtcp);
	}
{noformat}



was (Author: aaron):
I found a place that will close the FD twice. Asterisk 13.16.0 support rtcp-mux feature so rtcp use the same UDP port of rtp. But in res_rtp_asterisk.c function ast_rtp_destroy, we don't check if rtcp->s == rtp->s and close it twice, if in heavy load, free the FD twice will lead the Bad file descriptor issue. I will fix it in my production platform, and patch it to the gerrit. Thanks all the people watching this.

look at this code.

	/* Close our own socket so we no longer get packets */
	if (rtp->s > -1) {
		close(rtp->s);
	}

	/* Destroy RTCP if it was being used */
	if (rtp->rtcp) {
		/*
		 * It is not possible for there to be an active RTCP scheduler
		 * entry at this point since it holds a reference to the
		 * RTP instance while it's active.
		 */
		close(rtp->rtcp->s);
		ast_free(rtp->rtcp->local_addr_str);
		ast_free(rtp->rtcp);
	}

> Asterisk Hangs with Bad file descriptor on read()
> -------------------------------------------------
>
>                 Key: ASTERISK-27299
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-27299
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Bridges/bridge_native_rtp
>    Affects Versions: 13.17.1
>         Environment: Ubuntu 16.04 with asterisk 13.17.1 
>            Reporter: Abhay Gupta
>            Assignee: Unassigned
>         Attachments: 11.log, 12.log, 3858.threads.log, latestGDB, modules.conf.sample, output2.txt, sip-3-0002949d.log, taskprocessSterl.txt
>
>
> Asterisk stops responding and only have errors of alertpipe 
> {noformat}
> Sep 26 15:36:05] WARNING[3133] bridge_channel.c: Weird.  No frame from bridge for Local/agentmanual at asterisk-00013cae;1 to process?
> [Sep 26 15:36:05] WARNING[3133] alertpipe.c: read() failed: Bad file descriptor
> [Sep 26 15:36:05] WARNING[3133] bridge_channel.c: Weird.  No frame from bridge for Local/agentmanual at asterisk-00013cae;1 to process?
> [Sep 26 15:36:05] WARNING[3133] alertpipe.c: read() failed: Bad file descriptor
> [Sep 26 15:36:05] WARNING[3133] bridge_channel.c: Weird.  No frame from bridge for Local/agentmanual at asterisk-00013cae;1 to process?
> [Sep 26 15:36:05] WARNING[3133] alertpipe.c: read() failed: Bad file descriptor
> [Sep 26 15:36:05] WARNING[3133] bridge_channel.c: Weird.  No frame from bridge for Local/agentmanual at asterisk-00013cae;1 to process?
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list