Crash in [@ mozilla::CheckedInt<T>::value | mozilla::media::TimeUnit::operator<T>]
Categories
(Core :: Audio/Video, defect, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox-esr140 | --- | unaffected |
| firefox-esr153 | --- | fix-optional |
| firefox153 | --- | fix-optional |
| firefox154 | --- | wontfix |
| firefox155 | --- | fix-optional |
People
(Reporter: gsvelto, Unassigned, NeedInfo)
References
(Regression)
Details
(Keywords: crash, regression)
Crash Data
Crash report: https://crash-stats.mozilla.org/report/index/1522d439-1e76-454a-b7a4-0e5ff0260721
MOZ_CRASH Reason:
MOZ_RELEASE_ASSERT(mIsValid) (Invalid checked integer (division by zero or integer overflow))
Top 10 frames:
0 XUL MOZ_CrashSequence(void*, long) mfbt/Assertions.h:266
0 XUL mozilla::CheckedInt<long long>::value() const mfbt/CheckedInt.h:324
0 XUL mozilla::media::TimeUnit::operator<=(mozilla::media::TimeUnit const&) const dom/media/TimeUnits.cpp:235
1 XUL mozilla::media::Interval<mozilla::media::TimeUnit>::TouchesOnRight(mozilla::m... dom/media/Intervals.h:219
2 XUL mozilla::media::IntervalSet<mozilla::media::TimeUnit>::Add(mozilla::media::In... dom/media/Intervals.h:330
3 XUL mozilla::media::IntervalSet<mozilla::media::TimeUnit>::operator+=(mozilla::me... dom/media/Intervals.h:370
3 XUL mozilla::media::TimeIntervals::ToMicrosecondResolution() const dom/media/TimeUnits.h:325
4 XUL mozilla::dom::SourceBuffer::GetBuffered(mozilla::ErrorResult&) dom/media/mediasource/SourceBuffer.cpp:134
5 XUL mozilla::dom::SourceBuffer_Binding::get_buffered(JSContext*, JS::Handle<JSObj... dom/bindings/SourceBufferBinding.cpp:194
6 ? @0x000007d1304b6cdc
This crash appears to be a regression and is now rapidly rising in volume, however it might be hard to spot where it began. We had very sporadic crashes in the past, like once a week, with the first affected builid being 20260227092902 (this could be accidental though, as it's from the oldest crashes we have on file and will soon be purged from our servers). Things changes with the release of version 150.0.0. Crashes on desktop ramp up from once a week to several per day, once per day on mobile. This stays steady for a while then volume ramps up significantly in the past few days. We had 626 crashes in the past two weeks with 349 crash reports in the past three days alone, most of them from mobile users.
Looking at the comments and URLs these appear to be the websites that are most likely to trigger the issue:
Comment 1•3 months ago
|
||
This is likely a regression from bug 2014895, and it's an incomplete-fix problem rather than bad media data alone.
Mechanism
TimeUnit stores time as a CheckedInt<int64_t> mTicks over a base. The comparison operators guard validity only with a debug-only MOZ_ASSERT(IsValid() && aOther.IsValid()) and then dereference mTicks.value(), which carries a release assert:
So in release builds any invalid TimeUnit that reaches a comparison is a guaranteed MOZ_RELEASE_ASSERT(mIsValid) crash.
The invalid TimeUnit is produced by TimeUnit::ToBase(), which returns TimeUnit::Invalid() when the value converted to the target base overflows int64 (a time exceeding ~292,000 years in microseconds — reachable with the extreme/inconsistent timestamps these live-stream sites produce):
The crashing path from comment 0 is SourceBuffer::GetBuffered -> TimeIntervals::ToMicrosecondResolution(), which calls ToBase(USECS_PER_S) on each interval endpoint and stores the result without checking IsValid():
The resulting invalid endpoint is then compared during normalization in Interval::TouchesOnRight -> operator<=, which crashes:
Why it regressed
Bug 2014895 (landed 2026-02-12) introduced the return TimeUnit::Invalid() path in ToBase. It guarded the two callers it knew about — operator+ and operator- got && inBase.IsValid() — but every other ToBase consumer still uses the result directly, including TimeIntervals::ToMicrosecondResolution / TimeIntervals::ToBase, MediaSource::DurationChange (highestEndTime.ToBase(USECS_PER_S)), TrackBuffersManager, and MediaDecoderStateMachine. Before bug 2014895 the same overflow went through AssertedCast, which in release is a plain cast — a garbage-but-valid value, so comparisons did not assert. The fix traded silent UB for a hard crash on the unguarded call sites.
Timeline matches: first affected build is 20260227092902, right after the 2026-02-12 landing; it rode to release with 150 and has been ramping with exposure since (no second code change needed to explain the rise).
Volume
~630 crashes / 2 weeks, split roughly evenly between Firefox desktop and Fenix. Windows/macOS/Linux + Android; not hardware- or OS-specific. All content-process, during MSE playback on live-TV streams.
Suggested fix
Make ToBase clamp an out-of-range conversion to +/-Infinity (a valid TimeUnit all operators already handle) instead of returning Invalid(); there is precedent in FromSeconds (bug 1835075). This protects all call sites at once. Needs checking against the FLAC subtraction scenario from bug 2014895, which relied on Invalid() + non-zero aOutError to force the float fallback in operator±. The narrower alternative is to make the remaining ToBase consumers validity-aware like operator± already are.
Comment 2•3 months ago
|
||
:padenot, since you are the author of the regressor, bug 2014895, could you take a look? Also, could you set the severity field?
For more information, please visit BugBot documentation.
Updated•3 months ago
|
Comment 3•3 months ago
|
||
I am not sure why the other bug is still hidden, but for caution I am hiding this one, too.
Comment 4•3 months ago
|
||
Let's just unhide this for greater visibility. I was about to refile it myself. The other bug probably doesn't even need to be hidden, and this one is a release assert so even less so.
Comment 5•3 months ago
|
||
At least looking at the last week, 100% of these signatures have SourceBuffer_Binding::get_buffered in the stack.
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
Comment 8•1 month ago
|
||
Copying crash signatures from duplicate bugs.
Description
•