After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 793419 - pnm: seg fault with non power of 4 strides in pnmenc
pnm: seg fault with non power of 4 strides in pnmenc
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other All
: Normal normal
: 1.13.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2018-02-13 10:29 UTC by Dimitrios Katsaros
Modified: 2018-02-14 08:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Example video frame that does not countain padding (2.99 MB, application/octet-stream)
2018-02-13 10:29 UTC, Dimitrios Katsaros
  Details
Patch to fix segmentation fault (6.17 KB, patch)
2018-02-13 10:31 UTC, Dimitrios Katsaros
committed Details | Review

Description Dimitrios Katsaros 2018-02-13 10:29:16 UTC
Created attachment 368303 [details]
Example video frame that does not countain padding

I have found a segmentation fault with pnmenc caused due to the input frames not being handled as videobuffers. The stride of the input was calculated using the videoinfo collected from the caps. This defaults to the stride being a power of 4. If the input frames do not contain padding and do not have a width that is a multiplier of 4, the pnmenc would segment.

I am attaching an example videoframe and a pipe to verify the patch:

gst-launch-1.0 filesrc location= 1022x1024_rgb24_no_padding ! rawvideoparse format=rgb width=1022 height=1024 plane-strides='<3066>' ! pnmenc ! filesink location=dump.pnm
Comment 1 Dimitrios Katsaros 2018-02-13 10:31:09 UTC
Created attachment 368304 [details] [review]
Patch to fix segmentation fault
Comment 2 Sebastian Dröge (slomo) 2018-02-13 14:13:47 UTC
Review of attachment 368304 [details] [review]:

::: gst/pnm/gstpnmenc.c
@@ +266,3 @@
       o_rowstride = pnmenc->info.width;
     }
+    i_rowstride = GST_VIDEO_FRAME_PLANE_STRIDE (&in_frame, 0);

How did this ever work? :) input_state is a GstVideoCodecState*, not a GstVideoFrame*!
Comment 3 Sebastian Dröge (slomo) 2018-02-13 14:14:53 UTC
Comment on attachment 368304 [details] [review]
Patch to fix segmentation fault

Does not apply to latest GIT master
Comment 4 Nicolas Dufresne (ndufresne) 2018-02-13 14:16:36 UTC
Review of attachment 368304 [details] [review]:

Does pnmenc advertise VideoMeta support ?

If no, then we should also fix rawvideoparse. This patch remains a good idea, and then we should advertise VideoMeta. If yes, then this what we need kindred. I'll review more attentively soon
Comment 5 Dimitrios Katsaros 2018-02-13 15:32:41 UTC

(In reply to Nicolas Dufresne (stormer) from comment #4)
> Review of attachment 368304 [details] [review] [review]:
> 
> Does pnmenc advertise VideoMeta support ?
> 
> If no, then we should also fix rawvideoparse. This patch remains a good
> idea, and then we should advertise VideoMeta. If yes, then this what we need
> kindred. I'll review more attentively soon

I am not sure how VideoMeta support is advertised, but the underlying element is a GstVideoEncoder. If the videometa support is not being advertised then there is a chance that other video encoders are broken as well.

> Does not apply to latest GIT master

This is odd. I tried cloning bad and applying the patch and it seems to apply just fine. Can you share what is breaking on your end so I can try to fix it?
Comment 6 Nicolas Dufresne (ndufresne) 2018-02-13 16:28:10 UTC
(In reply to Dimitrios Katsaros from comment #5)
> 
> (In reply to Nicolas Dufresne (stormer) from comment #4)
> > Review of attachment 368304 [details] [review] [review] [review]:
> > 
> > Does pnmenc advertise VideoMeta support ?
> > 
> > If no, then we should also fix rawvideoparse. This patch remains a good
> > idea, and then we should advertise VideoMeta. If yes, then this what we need
> > kindred. I'll review more attentively soon
> 
> I am not sure how VideoMeta support is advertised, but the underlying
> element is a GstVideoEncoder. If the videometa support is not being
> advertised then there is a chance that other video encoders are broken as
> well.

It's not being advertise atm. We need to implement propose_allocation() virtual, and add to the query meta API. But not a blocker from merging this change.
Comment 7 Sebastian Dröge (slomo) 2018-02-14 08:20:09 UTC
commit 3cf4a70dbc7af93eaf4198cfd20683ff61206405
Author: Dimitrios Katsaros <patcherwork@gmail.com>
Date:   Tue Feb 13 11:16:29 2018 +0100

    pnm: Fixed segfault in pnmenc
    
    The pnmenc was not mapping the input buffers as video buffers. Because
    of this, the video frame stride was not being set based on frame but
    based on the caps, which make the assumption that the strides are a
    power of 4. For input that is not a power of 4, this would lead to a
    SIGSEGV.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=793419