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 748107 - tsdemux: fix build error with clang
tsdemux: fix build error with clang
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Mac OS
: Normal normal
: NONE
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-04-18 14:39 UTC by Yujin Lee
Modified: 2016-08-08 17:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
tsdemux: fix build error with clang (1.00 KB, patch)
2015-04-18 15:20 UTC, Yujin Lee
committed Details | Review
tsdemux: prevent negative value for position of GstSegment (1.56 KB, patch)
2015-04-20 16:59 UTC, Yujin Lee
none Details | Review

Description Yujin Lee 2015-04-18 14:39:49 UTC
There is a build error when tsdemux is compiled with clang.

bash-3.2$ make
  CC       libgstmpegtsdemux_la-tsdemux.lo
tsdemux.c:2245:31: error: comparison of unsigned expression < 0 is always false [-Werror,-Wtautological-compare]
  if (demux->segment.position < 0)
      ~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
1 error generated.
make: *** [libgstmpegtsdemux_la-tsdemux.lo] Error 1
Comment 1 Yujin Lee 2015-04-18 15:20:41 UTC
Created attachment 301903 [details] [review]
tsdemux: fix build error with clang

This commit avoids a build error by clang with [-Werror,-Wtautological-compare] options.
Comment 2 Vincent Penquerc'h 2015-04-20 08:21:41 UTC
Review of attachment 301903 [details] [review]:

It seems to be that this will miss all the interesting cases (and be a noop anyway). I think this would be better:

if (GST_BUFFER_PTS (buffer) > stream->first_dts)
  demux->segment.position = GST_BUFFER_PTS (buffer) - stream->first_dts;
else
  demux->segment.position = 0;
Comment 3 Yujin Lee 2015-04-20 16:59:54 UTC
Created attachment 302015 [details] [review]
tsdemux: prevent negative value for position of GstSegment

tsdemux: prevent negative value for position of GstSegment

This is a new patch to prevent negative value for position of GstSegment.
Comment 4 Tim-Philipp Müller 2015-04-23 13:49:48 UTC
Looks like Luis "fixed" this already by just removing it as well..
Comment 5 Yujin Lee 2015-04-24 00:58:46 UTC
The patch by Luis seems to be intended to remove dead code because an unsigned int64 variable cannot have negative value. But this patch is intended to prevent the segment position from being assigned a negative value.
Of course, if the result of segment position calculation is always right, this patch will be useless.
Comment 6 Ilya Konstantinov 2015-04-25 13:22:42 UTC
(In reply to Tim-Philipp Müller from comment #4)
> Looks like Luis "fixed" this already by just removing it as well..

http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=f52cf2a7c4a03065eb435d9df390923783f4c715

(In reply to Yujin Lee from comment #5)
> But this patch is intended to prevent the segment position from being assigned a negative value.

In your version, it'll just be a noop. (We certainly don't mean to make the "negative" half of the position values invalid.)

(In reply to Vincent Penquerc'h from comment #2)
> if (GST_BUFFER_PTS (buffer) > stream->first_dts)
>   demux->segment.position = GST_BUFFER_PTS (buffer) - stream->first_dts;
> else
>   demux->segment.position = 0;

Something is seriously broken if that happens (as first_dts <= dts1 <= pts1 < dts2 <= pts2 ...).

If we believe such a scenario is likely, and want to be defensive, I wonder if we're better logging the error and dropping the buffer, instead of silently propagating the error in the form of a sudden position drop.

If such a scenario is unlikely, this bug can be closed.
Comment 7 Vincent Penquerc'h 2015-07-13 16:48:14 UTC
For the record, first_dts the well named was either a pts or dts. It looks like the code was changed since though. Iit's now called first_pts, which can now be a pts or dts.
Comment 8 Tim-Philipp Müller 2016-08-08 17:32:57 UTC
Is this still an issue with git master? It looks like the code is different now, I don't see any subtractions to guard against any more. Please re-open if it's still there and I missed it.