Crash in [@ mozilla::CheckedInt<T>::value | mozilla::MultS64xU32]
Categories
(Core :: Audio/Video, defect, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox161 | --- | affected |
People
(Reporter: clouseau-bot, Unassigned, NeedInfo)
References
(Blocks 1 open bug)
Details
(Keywords: crash)
Crash Data
Crash report: https://crash-stats.mozilla.org/report/index/526d2dfb-f3db-4cc4-9b83-c7ddc0261116
MOZ_CRASH Reason:
MOZ_RELEASE_ASSERT(mIsValid) (Invalid checked integer (division by zero or integer overflow))
Top 10 frames:
0 libxul.so mozilla::MultS64xU32(mozilla::CheckedInt<long> const&, long) dom/media/TimeUnits.cpp:44
1 libxul.so mozilla::media::TimeUnit::operator<=(mozilla::media::TimeUnit const&) const dom/media/TimeUnits.cpp:231
2 libxul.so mozilla::media::TimeUnit::operator>(mozilla::media::TimeUnit const&) const dom/media/TimeUnits.cpp:216
3 libxul.so mozilla::SampleIterator::Seek(mozilla::media::TimeUnit const&, mozilla::SampleIt... dom/media/mp4/SampleIterator.cpp:403
4 libxul.so mozilla::MP4TrackDemuxer::Seek(mozilla::media::TimeUnit const&) dom/media/mp4/MP4Demuxer.cpp:381
5 libxul.so mozilla::detail::ProxyFunctionRunnable<mozilla::MediaFormatReader::DemuxerProxy:... xpcom/threads/MozPromise.h:1888
6 libxul.so mozilla::TaskQueue::Runner::Run() xpcom/threads/TaskQueue.cpp:300
7 libxul.so nsThreadPool::Run() xpcom/threads/nsThreadPool.cpp:442
8 libxul.so NS_ProcessNextEvent(nsIThread*, bool) xpcom/threads/nsThreadUtils.cpp:471
9 libxul.so mozilla::ipc::MessagePumpForNonMainThreads::Run(base::MessagePump::Delegate*) ipc/glue/MessagePump.cpp:297
There is 1 crash in beta 161.0b3 with buildid 20261113104103.
In the last 30 days, Fenix has 8 crashes (from 8 installations) on release and 2 crashes (from 2 installations) on beta with this signature.
This signature has been reported since build 20241204215713 (2024-12-04), 708 days before the build above.
This bug looks actionable because:
-
MultS64xU32aborts onCheckedInt64::value()inTimeUnits.cpp:44whenSampleIterator::Seekcompares a sample start time and the seek target with different bases, and one of them holds an invalid (overflowed) tick count.- The fragmented-MP4 parser likely stores a sample start as
startCts + emptyOffset(MoofParser.cpp:1017): each operand passesMvhd::ToTimeUnit's validity check, but the sum is not checked. - When the media and movie timescales are equal,
TimeUnit::operator+returnsTimeUnit(mTicks + aOther.mTicks, mBase), so a largetfdt-derived time can overflow into an invalidCheckedIntkept in the sample index. MP4TrackDemuxer::SeekcallsSampleIterator::Seek, which evaluatessample->mCompositionRange.start > aTimethroughTimeUnit::operator<=.- With different bases, the
IsPosInf()/IsNegInf()guards return false for an invalid value, soMultS64xU32(mTicks, aOther.mBase)runs anda.value()hitsMOZ_RELEASE_ASSERT(mIsValid).
The crash reason (
Invalid checked integer), frame #1 at line 231 (the left-hand value, i.e. the sample start) and the MP4 seek frames fit this chain. The report does not show which overflow produced the invalid value, and with inlining the invalid operand could instead be the seek target. The comparison code from bug 1909614 also reached.value()on an invalid tick count before, throughReduced(), so the condition is older than this signature name. Look first at uncheckedTimeUnitarithmetic when buildingmCompositionRangeinMoof::ParseTrun, and at comparisons that never checkIsValid()in release builds. - The fragmented-MP4 parser likely stores a sample start as
-
The failing code comes from 557afaf1731b (bug 1909614) by :karlt.
Impact
A content process crashes; the tabs it hosts show a crash page. The MOZ_ASSERT(IsValid() && aOther.IsValid()) in TimeUnit::operator<= is debug-only, so release builds go straight on to the MOZ_RELEASE_ASSERT in CheckedInt::value(), which every build has.
Possible fixes
- In
Moof::ParseTrun, check thatstartCts + emptyOffsetandendCts + emptyOffsetareIsValid()and reject thetrun(returnErr) if not, as is already done fordecodeTime. - Make
SampleIterator::Seek(andGetNextKeyframeTimecallers) skip or stop on samples whosemCompositionRange.startis invalid, and reject an invalidaTimeinMP4TrackDemuxer::Seek. - Possibly make the
TimeUnitcomparison operators handle invalid operands deterministically instead of relying on a debug-onlyMOZ_ASSERT(IsValid()).
How to confirm
Build a fragmented MP4 whose mdhd and mvhd timescales are equal, with a tfdt decode time near INT64_MAX and a positive edit-list empty offset. Seek in it and watch for the release assert in MultS64xU32. Alternatively, add a diagnostic in Moof::ParseTrun that logs when mCompositionRange.start is invalid.
Code references:
:karlt, can you have a look please?
Filed automatically by Clouseau with an LLM, from a submitted crash report: not an independent Mozilla discovery
Filed automatically by Clouseau, which analyses beta and Developer Edition crashes with an LLM. Nothing above was written or checked by a human. Please close it as INVALID if it is wrong — that is useful feedback, not a nuisance.
This is not an independent Mozilla discovery: the crash is known here only because somebody submitted the crash report linked at the top. If this duplicates an existing report, please resolve THIS bug as the duplicate and leave the credit with the earlier reporter.
Comment 1•2 days ago
|
||
| gecko-triage | ||
Analysis
This is a content process crash on a release assert, during a seek in the MP4 demuxer. It is not the same defect as bug 2056822. That bug has the same assert, but on the MSE SourceBuffer::GetBuffered path, where TimeUnit::ToBase returns an invalid value. The seek stack here does not call ToBase.
Confirmed in the code: TimeUnit::operator<= checks validity only with a MOZ_ASSERT in TimeUnits.cpp. When the two bases differ, an invalid operand passes the infinity checks and reaches MultS64xU32. Its value() call then fails MOZ_RELEASE_ASSERT(mIsValid). So the crash needs an invalid TimeUnit and two different bases.
The source of the invalid value is not known yet. Comment 0 suggests the unchecked startCts + emptyOffset sum in Moof::ParseTrun (MoofParser.cpp). That sum can overflow. But the Moof constructor sorts and compares those times right after the parse, and that also aborts in release builds. So an overflow there probably crashes during the parse, not during the seek.
A plain (not fragmented) MP4 cannot give an invalid sample start. The other possible operand is the seek target aTime, but no producer of an invalid seek target is known.
One gap is confirmed. MP4Demuxer.cpp checks HasValidTime() only with MOZ_DIAGNOSTIC_ASSERT, so a sample with an invalid time can leave the MP4 demuxer in release builds. The WebM, Ogg, MP3, FLAC and Wave demuxers reject such samples. Also, the crash signature is a shared bucket: most reports with this signature have MSE stacks, and only a few have the SampleIterator::Seek stack.
No regressor is known. The signature exists since build 20241204 and also shows on ESR 140.
Fix direction
- In
Moof::ParseTrun, reject thetrunwhen a decode time or a composition time is invalid. - In the MP4 demuxer, replace the
HasValidTime()diagnostic asserts with errors, as the other demuxers do. - In
MP4TrackDemuxer::Seek, reject an invalidaTimebefore the comparison. - To find which operand is invalid, separate release asserts on the seek target and on the sample start in
SampleIterator::Seekcan split the signature.
Gtests in dom/media/gtest/TestTimeUnit.cpp and dom/media/gtest/TestMP4Demuxer.cpp can cover a comparison and a seek with an invalid time. The bug also waits for the needinfo on Karl from comment 0.
If you'd like to provide feedback on this comment, please use the 👍 or 👎 reaction.
Description
•