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 697441 - GstClock time values can jump in 32-bit applications.
GstClock time values can jump in 32-bit applications.
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
1.0.5
Other Windows
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2013-04-06 16:12 UTC by Michael Rubinstein
Modified: 2018-11-03 12:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gstclock: fix race in gst_clock_adjust_unlocked (1.36 KB, patch)
2015-07-17 13:13 UTC, Branislav Katreniak
none Details | Review

Description Michael Rubinstein 2013-04-06 16:12:07 UTC
Rare clock jumps of around 4.3 seconds were seen in a 32-bit Windows application.  GStreamer and the app were built with MinGW/GCC, so the problem probably applies to any 32-bit environment.

The reader/writer locks in gstclock.c guarantee consistent calibration values.  However, they don't make load/stores of "last_time" atomic.

Here's where I think the problem occurs:

The value of time is close to a value that would carry from the low word to the high.  Say 0x00000000 FFFFFFFF.

A thread is executing:
  priv->last_time = MAX (ret, priv->last_time);
It has read the FFFFFFFF

Another thread interrupts the first and updates last_time to
0x00000001 00000000

The first thread resumes and reads the high word yielding 
0x00000001 FFFFFFFF
which it stores in last_time.
Note FFFFFFFF is around 4.3 seconds in ns.

My fix is to use GST_OBJECT_LOCK/UNLOCK in place of read_seqbegin/read_seqretry.  This has no measurable performance impact in my application.  It seems to fix the problem, but since the problem occurs rarely, more testing is needed.
Comment 1 Sebastian Dröge (slomo) 2013-04-06 17:06:07 UTC
Or using atomic ops to set that, but those are usually limited to 32 bit operations. Sounds like a possible cause for this bug though
Comment 2 Branislav Katreniak 2015-07-17 13:05:24 UTC
We faced the same problem on 32bit arm linux. We could reproduce this problem usually within one day.
Comment 3 Branislav Katreniak 2015-07-17 13:13:17 UTC
Created attachment 307618 [details] [review]
gstclock: fix race in gst_clock_adjust_unlocked

Our fix for this issue. It is not lock free, but correctness is more important than speed.
Comment 4 GStreamer system administrator 2018-11-03 12:17:55 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/gstreamer/issues/37.