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 752014 - bayer2rgb: odd width causes segmentation fault
bayer2rgb: odd width causes segmentation fault
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-07-06 12:49 UTC by Dimitrios Katsaros
Modified: 2018-11-03 13:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Backtrace (7.47 KB, text/plain)
2015-07-06 15:48 UTC, Dimitrios Katsaros
  Details
Last ~100 lines of debug messages before segmentation fault (24.90 KB, text/plain)
2015-07-06 15:57 UTC, Dimitrios Katsaros
  Details
fix crash using non existent caps structure (850 bytes, patch)
2015-07-14 10:36 UTC, Vincent Penquerc'h
rejected Details | Review
bayer: fix stride inconsistencies for odd widths (2.19 KB, patch)
2016-01-08 21:49 UTC, Tim-Philipp Müller
committed Details | Review

Description Dimitrios Katsaros 2015-07-06 12:49:16 UTC
I am trying to develop a component that uses the x-bayer format. After trying to debug a segmentation fault I reached this pipeline:

gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-bayer ! bayer2rgb ! ximagesink

The pipeline Starts normally, then the ximagesink causes a renegotiation to happen to maximize the framesize. That causes a segmentation fault. I cannot determine if the problem is the bayer2rgb component or the v4l2src.
Comment 1 Thiago Sousa Santos 2015-07-06 13:08:17 UTC
Thanks for taking the time to report this.
Without a stack trace from the crash it's very hard to determine what caused it.
Can you get us a stack trace? Please see https://wiki.gnome.org/Community/GettingInTouch/Bugzilla/GettingTraces for more information on how to do so. When pasting a stack trace in this bug report, please reset the status of this bug report from NEEDINFO to its previous status. Thanks in advance!

a GST_DEBUG=6 showing the issue might also be helpful in debugging.
Comment 2 Dimitrios Katsaros 2015-07-06 15:48:42 UTC
Created attachment 306930 [details]
Backtrace
Comment 3 Dimitrios Katsaros 2015-07-06 15:57:30 UTC
Created attachment 306931 [details]
Last ~100 lines of debug messages before segmentation fault
Comment 4 Dimitrios Katsaros 2015-07-06 16:02:41 UTC
I have added the Backtrace for the segmentation fault and the last 100 lines of debug messages before the segmenetation. The debug was too large and exceeded the file limits of bugzilla, if needed I can post the entire dump on a file sharing site. I have installed the debug sumbols for orc, however, gdb does not seem to resolve the symbols for the orc call inside the tmp-orc.c file that is generated. I generated the file, however there are only orc calls in it.
Comment 5 Vincent Penquerc'h 2015-07-14 10:36:40 UTC
Created attachment 307399 [details] [review]
fix crash using non existent caps structure

I don't think this fixes that issue (unless you have asserts off), but I got another crash trying to repro this issue. It works "fine" with your original command line (pipeline errors out) but crashes in transform_caps if I use xvimagesink instead of ximagesink.
I'm not pushing it right away because I'm not quite sure whether the new test is sufficient. I don't think we could get ANY here, due to the template caps, but I'm not 100% confident.
Comment 6 Dimitrios Katsaros 2015-07-15 13:30:50 UTC
I tested the patch out of curiosity and it doesn't fix the segmentation fault I have been dealing with.
Comment 7 Nicolas Dufresne (ndufresne) 2015-08-06 21:40:15 UTC
To reproduce, without v4l2:

gst-launch-1.0 videotestsrc ! rgb2bayer ! bayer2rgb ! ximagesink

Resize the window, it crashes.
Comment 8 Nicolas Dufresne (ndufresne) 2015-08-06 21:56:33 UTC
It crashes if width is odd.
Comment 9 Nicolas Dufresne (ndufresne) 2015-08-06 22:06:03 UTC
I didn't two unrelated fixes, but one need to figure-out how to fix odd width support.

commit 6bd93bd7e5b68294bcb305cd01355477f804b316
Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Date:   Thu Aug 6 18:04:58 2015 -0400

    bayer2rgb: Read stride from the video info

commit 7d6fd42726a9e1f2705ee21bbc756cdd16460750
Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Date:   Thu Aug 6 18:04:41 2015 -0400

    bayer2rgb: Protect against failing map
Comment 10 Tim-Philipp Müller 2016-01-08 21:20:14 UTC
Two observations:

1) Doesn't happen with ORC_CODE=backup

2) Happens when passing a less than 8-aligned dest pointer to the orc merge functions. The unit size calculation seems to use width * height * 4, so strides and rows will always be 8-aligned if width is even.
Comment 11 Tim-Philipp Müller 2016-01-08 21:29:57 UTC
Simpler way to reproduce:

gst-launch-1.0 -f videotestsrc num-buffers=1 ! video/x-raw,width=319,height=240 ! rgb2bayer ! bayer2rgb ! fakesink

(There also seem to be some stride/size inconsistencies between the elements on the bayer side of things.)
Comment 12 Tim-Philipp Müller 2016-01-08 21:49:03 UTC
Created attachment 318549 [details] [review]
bayer: fix stride inconsistencies for odd widths

(Doesn't fix this bug, just cleans up an inconsistency in the codebase. The bug here appears to be about strides/offsets on the RGB video buffer side of things, not the Bayer buffer.)

Consistently use GST_ROUND_UP_4(width) as stride for
bayer buffers. Bayer data will usually come in widths
that are multiples of 4 anyway, so hopefully this
should not have any adverse impact on anyone in
practice.
    
Before, bayer2rgb required input buffers to are sized
accordingly, but then didn't actually round up when
calculating row offsets. rgb2bayer didn't use a rounded
stride nor buffer size.
Comment 13 cJ-gnome 2016-09-08 18:41:23 UTC
Hi,

It's not exactly the same bug but in the same file, somehow when running something like this:

  gst-launch-1.0 --no-fault filesrc location=/home/cJ/pouet.raw ! video/x-bayer,format=rggb,width=4096,height=2048,framerate=30/1 ! bayer2rgb ! video/x-raw,format=RGBx ! fakesink

I get:

  WARNING **: bayer2rgb0: size 4096 is not a multiple of unit size 8388608

This is with bayer2rgb v1.8.2.
Comment 14 Vincent Penquerc'h 2016-10-13 14:06:21 UTC
Do you have a test file replacing filesrc with videotestsrc works, so it's liekly particular to the file.
Comment 15 Tim-Philipp Müller 2016-10-13 14:16:10 UTC
> It's not exactly the same bug but in the same file, somehow when running
> something like this:
> 
>   gst-launch-1.0 --no-fault filesrc location=/home/cJ/pouet.raw !
> video/x-bayer,format=rggb,width=4096,height=2048,framerate=30/1 ! bayer2rgb
> ! video/x-raw,format=RGBx ! fakesink
> 
> I get:
> 
>   WARNING **: bayer2rgb0: size 4096 is not a multiple of unit size 8388608
> 
> This is with bayer2rgb v1.8.2.

This is not related and not expected to work. You need to teach videoparse bayer formats and then use that.
Comment 16 Sebastian Dröge (slomo) 2016-10-20 10:47:16 UTC
Comment on attachment 307399 [details] [review]
fix crash using non existent caps structure

This should be fixed at the basetransform level. Most calls already prevent this, at least one doesn't.
Comment 17 Sebastian Dröge (slomo) 2016-11-01 17:36:05 UTC
Attachment 318549 [details] pushed as d42177c - bayer: fix stride inconsistencies for odd widths
Comment 18 Sebastian Dröge (slomo) 2016-11-01 17:36:25 UTC
More left to do here
Comment 19 Zeeshan Ali 2018-05-04 08:54:57 UTC
Reducing priority since the crash has been fixed(?).
Comment 20 GStreamer system administrator 2018-11-03 13:37:05 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/268.