3

I am currently getting a segfault when trying to receive RTCP in RECVONLY sessions in oRTP. RTCP works fine when receiving in a SENDRECV session but won't work in RECVONLY sessions.

This is my code. The segfault comes from the function on line 42: err=rtp_session_recv_with_ts(session,buffer,160,ts,&have_more); This is in the while loop that receives the file.

However, this only occurs on line 32

rtp_session_enable_rtcp(session,TRUE); is set to TRUE.

If I disable RTCP by setting it to FALSE, then the RECVONLY session works.

#include <ortp/ortp.h>
#include <bctoolbox/vfs.h>
#include <signal.h>
#include <stdlib.h>

int cond=1;

void stop_handler(int signum)
{
    cond=0;
}

int main(int argc, char*argv[])
{
    RtpSession *session;
    unsigned char buffer[160];
    int err;
    uint32_t ts=0;
    int stream_received=0;
    FILE *outfile;
    int local_port;
    int have_more;
    int i;
    local_port=atoi(argv[2]);
    outfile=fopen(argv[1],"wb");

    //initialization of the session
    ortp_init();
    ortp_scheduler_init();
    ortp_set_log_level_mask(NULL, ORTP_DEBUG|ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR);
    signal(SIGINT,stop_handler);
    session=rtp_session_new(RTP_SESSION_RECVONLY);
    rtp_session_enable_rtcp(session,TRUE);
    rtp_session_set_scheduling_mode(session,1);
    rtp_session_set_blocking_mode(session,1);
    rtp_session_set_local_addr(session,"0.0.0.0",local_port,local_port+1);
    rtp_session_set_payload_type(session,0);

    //receiving of incoming file
    while(cond)
    {
        have_more=1;
        while (have_more){
            err=rtp_session_recv_with_ts(session,buffer,160,ts,&have_more);
            if (err>0) stream_received=1;
            /* this is to avoid to write to disk some silence before the first RTP packet is returned*/
            if ((stream_received) && (err>0)) {
                size_t ret = fwrite(buffer,1,err,outfile);
            }
        }
        ts+=160;
    }

    rtp_session_destroy(session);
    ortp_exit();
    ortp_global_stats_display();
    return 0;
}

Using gdb to debug, I get this backtrace of the segfault.

Thread 1 "err" received signal SIGSEGV, Segmentation fault.
0x00007ffff7bd0a53 in concatb (mp=mp@entry=0x606ec0, newm=newm@entry=0x0)
    at /usr/src/debug/ortp-1.0.1-18/src/str_utils.c:337
337     while(newm->b_cont!=NULL) newm=newm->b_cont;
(gdb) bt
#0  0x00007ffff7bd0a53 in concatb (mp=mp@entry=0x606ec0, newm=newm@entry=0x0)
    at /usr/src/debug/ortp-1.0.1-18/src/str_utils.c:337

#1  0x00007ffff7bc4ada in append_sdes (full=1 '\001', m=0x606ec0, session=0x602750)
    at /usr/src/debug/ortp-1.0.1-18/src/rtcp.c:397

#2  rtp_session_create_and_send_rtcp_packet (session=session@entry=0x602750, full=full@entry=1 '\001')
    at /usr/src/debug/ortp-1.0.1-18/src/rtcp.c:460

#3  0x00007ffff7bc4d3e in rtp_session_send_regular_rtcp_packet_and_reschedule (
    session=session@entry=0x602750, tc=607522024) at /usr/src/debug/ortp-1.0.1-18/src/rtcp.c:569

#4  0x00007ffff7bc4ebd in rtp_session_run_rtcp_send_scheduler (session=session@entry=0x602750)
    at /usr/src/debug/ortp-1.0.1-18/src/rtcp.c:604

#5  0x00007ffff7bc5085 in rtp_session_rtcp_process_recv (session=session@entry=0x602750)
    at /usr/src/debug/ortp-1.0.1-18/src/rtcp.c:620

#6  0x00007ffff7bca985 in rtp_session_recvm_with_ts (session=session@entry=0x602750, 
    user_ts=user_ts@entry=30880) at /usr/src/debug/ortp-1.0.1-18/src/rtpsession.c:1287

#7  0x00007ffff7bcab24 in rtp_session_recv_with_ts (session=0x602750, 
    buffer=0x7fffffffdf90 "\226ˢT\277\274\350/։c\276e\257\377\377\377\377\376\177\357\377\377\377\277\372\377\377\377\377\377\377\377\356?r\337\301h\225s`\020HvHfJv\312\062\364\332\333\036\364\332fͽL\002\220d\"\206\354b\006\003\060\241cHV21\243Z!\v\r\202\271\214x0\004Pc$\306<\306\006;\270i\352\206l\030`\244@\244\303\071\253\070\"T\356\002\017\004\"8e\377\062\260\225\376\245bG\310\320H", len=160, ts=30880, have_more=0x7fffffffdf8c)
    at /usr/src/debug/ortp-1.0.1-18/src/rtpsession.c:1364

#8  0x0000000000400d15 in main ()

From the backtrace, it look as if there is an issue in the library file str_utils.c, but I'm not sure if I'm just forgetting initialize something when setting up a RECVONLY session.

Overall, it looks as though the receiver function on line 42 does not work with RTCP in a RECVONLY session. There are no issues if RTCP is disabled.

2
  • Please extend your question to feature a minimal reproducible example. Also, please try to pinpoint the location of the error to a specific line (e.g. by compiling with debug flags and using a debugger). Apr 24, 2017 at 16:19
  • Just noting that I'm getting this too, same conditions, same workaround. Debian libortp13 package, version 1:1.0.2-1. Jul 13, 2021 at 23:22

0

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.