Opened 11 years ago
Closed 11 years ago
#2911 closed defect (fixed)
Handle initial chunk size packet of RTMP connections
Reported by: | skyride | Owned by: | |
---|---|---|---|
Priority: | important | Component: | avformat |
Version: | git-master | Keywords: | rtmp crash SISEGV |
Cc: | arkanis | Blocked By: | |
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
Version of FFMpeg:
skyride@ns308725:~/ffmpeg_sources/ffmpeg$ ffmpeg --version
ffmpeg version git-2013-08-28-129f506 Copyright (c) 2000-2013 the FFmpeg developers
built on Aug 28 2013 17:22:50 with gcc 4.7 (Debian 4.7.2-5)
configuration: --prefix=/home/skyride/ffmpeg_build --extra-cflags=-I/home/skyride/ffmpeg_build/include --extra-ldflags=-L/home/skyride/ffmpeg_build/lib --bindir=/home/skyride/bin --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab
libavutil 52. 42.100 / 52. 42.100
libavcodec 55. 29.100 / 55. 29.100
libavformat 55. 14.102 / 55. 14.102
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 82.102 / 3. 82.102
libswscale 2. 5.100 / 2. 5.100
libswresample 0. 17.103 / 0. 17.103
libpostproc 52. 3.100 / 52. 3.100
Summary of the bug:
A segmentation fault occurs when trying to open FFmpeg in listen mode for an RTMP stream, and initiating a connection.
How to reproduce:
ffmpeg -rtmp_listen 1 -re -i rtmp://skyride.org/app/asd -vcodec copy -acodec copy rtmp://live-fra.twitch.tv/app/MY_STREAM_KEY
The program then runs, and when I attempt to open a connection I receive the following message: "[rtmp @ 0x1b70ea0] Unable to read command string
Segmentation fault"
Attachments (3)
Change History (13)
follow-up: 2 comment:1 by , 11 years ago
comment:2 by , 11 years ago
Replying to skyride:
Also to confirm, this occurs regardless of the output stream.
If network output is not needed, please provide a command line using file or pipe protocol that allows to reproduce the problem.
comment:4 by , 11 years ago
Please add backtrace etc. for crashes as explained on http://ffmpeg.org/bugreports.html
comment:5 by , 11 years ago
Resolution: | → needs_more_info |
---|---|
Status: | new → closed |
Please reopen this ticket if you can add the missing information.
comment:6 by , 11 years ago
I also stumbled across the bug described by skyride. I think I found the cause and patched it (see below).
The bug occurred while I was trying to convert an RTMP stream to an HTTP stream. The RTMP stream is created with Open Broadcaster Software (https://obsproject.com/). The bug does not occur when ffmpeg is used as RTMP client!
Minimal setup to reproduce the bug:
- Run ffmpeg as RTMP server: ./ffmpeg -listen 1 -i rtmp://192.168.17.2/test/app -c copy -y test.mp4
- Open OBS and Stream data to the ffmpeg RTMP server
- Set Options -> Broadcast Options -> Streaming-Platform to "Custom"
- Set server to "rtmp://192.168.17.2/test/app"
- Start streaming
Of course you should use your own IP. The used OBS version is v0.613b 32bit (Windows only). I tested ffmpeg v2.2.1 (on Windows and Linux) and the current master branch (e89f3d0ed21259a714a8bd5d05d95af5b1e0f73f on Linux). ffmpeg was compiled without librtmp so the native RTMP implementation is probably the error source.
I'll attach detailed ffmpeg and gdb output of these test cases.
Bug cause and how to fix it:
The error message "Unable to read command string" lead me to the read_connect() function in libavformat/rtmpproto.c. I think the code expects the first packet to be an invocation (type RTMP_PT_INVOKE) but OBS first sends an RTMP_PT_CHUNK_SIZE packet to increase the chunk size from 128 bytes to 4096 bytes.
The attached patch adds code to check for an initial chunk size packet and sets the RTMPContexts chunk size accordingly. I tried to replicate the coding style as much as possible.
I'm also not sure if I should post the bug on the development mailing list. I hope it's ok here since the ticket already exists.
by , 11 years ago
Attachment: | 0001-avformat-rtmpproto-Added-handling-of-an-initial-RTMP.patch added |
---|
Patch to handle an initial chunk size packet
comment:7 by , 11 years ago
Resolution: | needs_more_info |
---|---|
Status: | closed → reopened |
Summary: | Seg Fault → Handle initial chunk size packet of RTMP connections |
comment:8 by , 11 years ago
Cc: | added |
---|---|
Component: | undetermined → avformat |
Keywords: | rtmp crash SISEGV added |
Priority: | normal → important |
Version: | unspecified → git-master |
Patches get more attention and can be reviewed on the ffmpeg-devel mailing list, please send the patch there.
follow-up: 10 comment:9 by , 11 years ago
The patch has been accepted into the 2.2. and master branches, see http://ffmpeg.org/pipermail/ffmpeg-devel/2014-April/156655.html.
This should solve the bug. Can the ticket be closed?
comment:10 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Replying to arkanis:
The patch has been accepted into the 2.2. and master branches, see http://ffmpeg.org/pipermail/ffmpeg-devel/2014-April/156655.html.
This should solve the bug. Can the ticket be closed?
Thank you for working on this issue!
Also to confirm, this occurs regardless of the output stream.