[Asterisk-code-review] Crash during "pjsip show channelstats" execution (...asterisk[16])
Salah Ahmed
asteriskteam at digium.com
Fri Oct 18 03:21:38 CDT 2019
Salah Ahmed has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/13073
Change subject: Crash during "pjsip show channelstats" execution
......................................................................
Crash during "pjsip show channelstats" execution
During execution "pjsip show channelstats" cli command by an
external module asterisk crashed. It seems this is a separate
thread running to fetch and print rtp stats. The crash happened on
the ao2_lock method, just before it going to read the rtp stats on
a rtp instance. According to gdb backtrace log, it seems the
session media was already cleaned up at that moment.
ASTERISK-28578
Change-Id: Ib7c7f39996d942984394782296bb99aae67862e5
---
M channels/pjsip/cli_commands.c
1 file changed, 6 insertions(+), 7 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/73/13073/1
diff --git a/channels/pjsip/cli_commands.c b/channels/pjsip/cli_commands.c
index 7e932da..fcff6d0 100644
--- a/channels/pjsip/cli_commands.c
+++ b/channels/pjsip/cli_commands.c
@@ -341,14 +341,14 @@
struct ast_sip_cli_context *context = arg;
const struct ast_channel_snapshot *snapshot = obj;
struct ast_channel *channel = ast_channel_get_by_name(snapshot->name);
- struct ast_sip_channel_pvt *cpvt = channel ? ast_channel_tech_pvt(channel) : NULL;
+ struct ast_sip_channel_pvt *cpvt = NULL;
struct ast_sip_session *session;
struct ast_sip_session_media *media;
- struct ast_rtp_instance *rtp;
struct ast_rtp_instance_stats stats;
char *print_name = NULL;
char *print_time = alloca(32);
char codec_in_use[7];
+ int stats_res = -1;
ast_assert(context->output_buffer != NULL);
@@ -359,7 +359,8 @@
ast_channel_lock(channel);
- session = cpvt->session;
+ cpvt = ast_channel_tech_pvt(channel);
+ session = cpvt ? cpvt->session : NULL;
if (!session) {
ast_str_append(&context->output_buffer, 0, " %s not valid\n", snapshot->name);
ast_channel_unlock(channel);
@@ -375,14 +376,13 @@
return 0;
}
- rtp = ao2_bump(media->rtp);
-
codec_in_use[0] = '\0';
if (ast_channel_rawreadformat(channel)) {
ast_copy_string(codec_in_use, ast_format_get_name(ast_channel_rawreadformat(channel)), sizeof(codec_in_use));
}
+ stats_res = ast_rtp_instance_get_stats(media->rtp, &stats, AST_RTP_INSTANCE_STAT_ALL);
ast_channel_unlock(channel);
print_name = ast_strdupa(snapshot->name);
@@ -391,7 +391,7 @@
ast_format_duration_hh_mm_ss(ast_tvnow().tv_sec - snapshot->creationtime.tv_sec, print_time, 32);
- if (ast_rtp_instance_get_stats(rtp, &stats, AST_RTP_INSTANCE_STAT_ALL)) {
+ if (stats_res == -1) {
ast_str_append(&context->output_buffer, 0, "%s direct media\n", snapshot->name);
} else {
ast_str_append(&context->output_buffer, 0,
@@ -416,7 +416,6 @@
);
}
- ao2_cleanup(rtp);
ao2_cleanup(channel);
return 0;
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/13073
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: Ib7c7f39996d942984394782296bb99aae67862e5
Gerrit-Change-Number: 13073
Gerrit-PatchSet: 1
Gerrit-Owner: Salah Ahmed <txrubel at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20191018/1d3735fc/attachment.html>
More information about the asterisk-code-review
mailing list