Opened 11 months ago

Closed 3 months ago

#8005 closed defect (fixed)

Assertion fails when reading rtp mpegts streaming using SDP file

Reported by: maf Owned by:
Priority: important Component: avformat
Version: git-master Keywords: sdp mpegts crash abort regression
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Summary of the bug:
You get assertion failure when you try to open a RTP mpegts stream using SDP file.

The problem is that function handle_packet() in avformat/mpegts.c is calling avio_tell(). This is incorrect when it is called from avpriv_mpegts_parse_packet(). In this case the "pb" is not the actual input stream. It is the SDP file!

How to reproduce:

ffplay version N-94212-g98b122cdb9 Copyright (c) 2003-2019 the FFmpeg developers

  built with gcc 9.1.1 (GCC) 20190621
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfi
g --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libb
luray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enab
le-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --e
nable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable
-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 -
-enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enab
le-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --en
able-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --en
able-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --e
nable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 30.100 / 56. 30.100
  libavcodec     58. 53.101 / 58. 53.101
  libavformat    58. 28.101 / 58. 28.101
  libavdevice    58.  7.100 / 58.  7.100
  libavfilter     7. 56.101 /  7. 56.101
  libswscale      5.  4.101 /  5.  4.101
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
[udp @ 00000000004ec100] 'circular_buffer_size' option was set but it is not sup
ported on this build (pthread support is required)
[udp @ 00000000004ec200] 'circular_buffer_size' option was set but it is not sup
ported on this build (pthread support is required)
Assertion pos >= 188 failed at src/libavformat/mpegts.c:2653

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

Change History (9)

comment:1 Changed 9 months ago by cehoyos

  • Keywords crash abort added; rtp assertion removed
  • Priority changed from normal to important

If this issue is still reproducible with current FFmpeg git head, please provide the complete, uncut console output together with the command line you tested.

comment:2 Changed 4 months ago by Balling

  • Status changed from new to open

Is this fixed?

comment:3 Changed 4 months ago by cehoyos

  • Resolution set to needs_more_info
  • Status changed from open to closed

comment:4 Changed 4 months ago by maf

  • Resolution needs_more_info deleted
  • Status changed from closed to reopened

Reproduced with latest version e931119...

ffplay rtp_test.sdp -protocol_whitelist "file,rtp,udp"

ffplay version git-2020-01-24-e931119 Copyright (c) 2003-2020 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20200122
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfi
g --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libb
luray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enab
le-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --e
nable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable
-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 -
-enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enab
le-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --en
able-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcode
c --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 -
-enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 38.100 / 56. 38.100
  libavcodec     58. 66.100 / 58. 66.100
  libavformat    58. 35.104 / 58. 35.104
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 71.100 /  7. 71.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
[udp @ 00000000005cc140] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[udp @ 00000000005cc240] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[udp @ 00000000005cc340] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[udp @ 00000000005cc400] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
Assertion pos >= 188 failed at src/libavformat/mpegts.c:2721f=0/0

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
    nan    :  0.000 fd=   0 aq=    0KB vq=    0KB sq=    0B f=0/0

The SDP file might look like this.

v=0
c=IN IP4 192.168.1.150
m=video 20000 RTP/AVP 33
a=rtpmap:33 MP2T/90000
a=control:mpegts-transport

See the original post. Function handle_packet() in avformat/mpegts.c is calling avio_tell() on ts->stream->pb. But that is not the TS stream! That is the SDP file. The stream is not available to handle_packet at all as it is called from avpriv_mpegts_parse_packet where the packet comes as an argument.

comment:5 Changed 4 months ago by cehoyos

(I cannot reproduce)
Can you reproduce the issue if you provide the source stream with FFmpeg?
Can you reproduce the issue if you remove all lines from the sdp file except c and m?
Can you reproduce the issue with address 127.0.0.1?

comment:6 Changed 4 months ago by maf

Minimal SDP file

c=IN IP4 127.0.0.1
m=video 20000 RTP/AVP 33

Sorry I forgot to mention that the stream must be running. The ffplay needs to parse some TS packets out of the stream and call avpriv_mpegts_parse_packet.

I produce the stream by:

ffmpeg -re -stream_loop -1 -i test.mp4 -vcodec copy -an -f rtp_mpegts rtp://127.0.0.1:20000

The test.mp4 should be h264 stream that is then sent over Mpeg2 TS.

comment:7 Changed 4 months ago by cehoyos

  • Keywords regression added
  • Reproduced by developer set
  • Status changed from reopened to open

Regression since 0f2f65bd583576ef8c12eea6088c84d4468f5804, reproducible for example with the following command line and above minimal sdp file:

$ ffmpeg -re -f lavfi -i testsrc2 -f rtp_mpegts rtp://127.0.0.1:20000

comment:8 Changed 4 months ago by maf

Commit 0f2f65bd583576ef8c12eea6088c84d4468f5804 added the assert which makes the problem visible. But the problem itself can be traced back to 4c6b49bf74f3a4ae3b198d487b7d3b5b64226778
Function handle_packet should be given the stream position as a parameter and call the tell(stream->pb) outside.

comment:9 Changed 3 months ago by cehoyos

  • Resolution set to fixed
  • Status changed from open to closed
Note: See TracTickets for help on using tickets.