GNOME Bugzilla – Bug 697441
GstClock time values can jump in 32-bit applications.
Last modified: 2018-11-03 12:17:55 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.
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
We faced the same problem on 32bit arm linux. We could reproduce this problem usually within one day.
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.
-- 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.