GNOME Bugzilla – Bug 770019
splitmuxsink crashes on 32-bit platform
Last modified: 2016-08-21 16:55:12 UTC
Created attachment 333444 [details] [review]
Patch to fix splitmuxsink crash on 32-bit platform
On 32-bit platform, Splitmuxsink will crash when the total amount of data approximate 4G bytes.
And it can be reproduced by running the following pipeline on 32-bit platform.
gst-launch-1.0 -v videotestsrc is-live=1 ! 'video/x-raw,format=I420,width=1280,height=720,framerate=25/1' ! x264enc bitrate=102400 ! h264parse ! splitmuxsink max-size-time=10000000000 location=video%05d.mp4
When the pipeline crashes, the following msg is output:
ERROR:gstsplitmuxsink.c:852:handle_gathered_gop: assertion failed:
(queued_bytes >= splitmux->mux_start_bytes)
The potential reason is that some variables(such as structure MqStreamCtx.in_bytes, struct _GstSplitMuxSink.muxed_out_bytes) used (in gstsplitmuxsink.c) to count the bytes number is of type gsize.
And on 32-bit platforms, gsize is 4-bytes wide. These variables will overrun as time goes by.
For example, inside function handle_mq_input() in gstsplitmuxsink.c,
at line 1125:
ctx->in_bytes += buf_info->buf_size;
ctx->in_bytes is continually increased by 'buf_size' every time a buf is received. Sooner or later, ctx->in_bytes will overrun and cause crashes.
The fix is quite straightforward.
Just replace some 'gsize' type by 'guint64' type, as described in the enclosed attachment.
And the fix has been tested and works well.
The patch looks correct. Can you please generate the patch using 'git format-patch' and attach it? It's easier to apply and manage correct attribution that way.
Created attachment 333729 [details] [review]
patch from 'git format-patch'
Patch generated by 'git format-patch'
Thanks, applied (with an updated commit msg for clarity)
Author: Jie Jiang <email@example.com>
Date: Sat Aug 20 16:59:30 2016 +0800
Fixed splitmuxsink 32-bit overflow bug
Extend the byte tracking counters to 64-bit on
all platforms, instead of using gsize, which overflows
Picked into 1.8 branch as well.