Closed Bug 1960121 Opened 1 year ago Closed 1 year ago

Crash in [@ mozilla::WMFCDMProxyCallback::AddRef]

Categories

(Core :: Audio/Video, defect)

Desktop
Windows
defect

Tracking

()

RESOLVED FIXED
140 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr128 --- disabled
firefox137 --- wontfix
firefox138 --- wontfix
firefox139 + fixed
firefox140 + fixed

People

(Reporter: aosmond, Assigned: alwu)

References

(Regression)

Details

(4 keywords, Whiteboard: [adv-main139+r])

Crash Data

Attachments

(2 external files)

Crash report: https://crash-stats.mozilla.org/report/index/da515645-b518-4413-bcf8-e91860250411

Reason:

EXCEPTION_ACCESS_VIOLATION_WRITE

Top 10 frames:

0  xul.dll  std::_Atomic_integral<unsigned long long, 8>::fetch_add(const unsigned long l...  /builds/worker/fetches/vs/VC/Tools/MSVC/14.39.33519/include/atomic:1619
0  xul.dll  mozilla::ThreadSafeAutoRefCnt::operator++()  xpcom/base/nsISupportsImpl.h:388
0  xul.dll  mozilla::WMFCDMProxyCallback::AddRef()  dom/media/eme/mediafoundation/WMFCDMProxyCallback.h:19
0  xul.dll  mozilla::RefPtrTraits<mozilla::WMFCDMProxyCallback>::AddRef(mozilla::WMFCDMPr...  mfbt/RefPtr.h:48
0  xul.dll  RefPtr<mozilla::WMFCDMProxyCallback>::ConstRemovingRefPtrTraits<mozilla::WMFC...  mfbt/RefPtr.h:408
0  xul.dll  RefPtr<mozilla::WMFCDMProxyCallback>::RefPtr(mozilla::WMFCDMProxyCallback*)  mfbt/RefPtr.h:108
0  xul.dll  mozilla::WMFCDMProxyCallback::OnSessionMessage(mozilla::MFCDMKeyMessage const&)  dom/media/eme/mediafoundation/WMFCDMProxyCallback.cpp:29
1  xul.dll  mozilla::MFCDMChild::RecvOnSessionKeyMessage(mozilla::MFCDMKeyMessage const&)  dom/media/ipc/MFCDMChild.cpp:441
2  xul.dll  mozilla::PMFCDMChild::OnMessageReceived(IPC::Message const&)  ipc/ipdl/PMFCDMChild.cpp:953
3  xul.dll  mozilla::PRemoteDecoderManagerChild::OnMessageReceived(IPC::Message const&)  ipc/ipdl/PRemoteDecoderManagerChild.cpp:577

MFCDMChild::Shutdown clears the pointer on one thread and then dispatches to the manager thread:
https://searchfox.org/mozilla-central/rev/1f65969e57c757146e3e548614b49d3a4168eeb8/dom/media/ipc/MFCDMChild.cpp#131

Meanwhile MFCDMChild IPDL messages are received on the manager thread:
https://searchfox.org/mozilla-central/rev/1f65969e57c757146e3e548614b49d3a4168eeb8/dom/media/ipc/MFCDMChild.cpp#441

It is possible IPDL messages could end up running on a dangling pointer instead of just the nullptr race from this crash report.

We should guard mProxyCallback with mMutex, or only clear/set it from the manager thread. If it is always not null otherwise, I would advise clearing it in ActorDestroy so that we know it can only be cleared after all outstanding IPDL messages have been processed. That way we can avoid needing checks in every IPDL message for mProxyCallback being valid.

Flags: needinfo?(alwu)

Set release status flags based on info from the regressing bug 1818790

I think it is pretty easy to fix, but want to double check that if we were to move clearing mProxyCallback to the manager thread, whether that could cause other state machine issues by violating some assumptions about receiving/processing messages after shutdown was initiated?

I'll mark this sec-moderate because it sounds like a theoretical race. I only see two crashes with this signature in the last 6 months. Feel free to increase it to sec-high if you are more concerned about it than that.

Assignee: nobody → alwu
Flags: needinfo?(alwu)

The severity field is not set for this bug.
:jimm, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(jmathies)

Set release status flags based on info from the regressing bug 1818790

Pushed by alwu@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d02d6a7f5f3c only use mProxyCallback on the manager thread. r=media-playback-reviewers,padenot
Group: media-core-security → core-security-release
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 140 Branch
Attachment #9488274 - Flags: approval-mozilla-beta?

firefox-beta Uplift Approval Request

  • User impact if declined: Crash
  • Code covered by automated testing: no
  • Fix verified in Nightly: yes
  • Needs manual QE test: no
  • Steps to reproduce for manual QE testing: n/a
  • Risk associated with taking this patch: Low, this is fixing an obvious object lifetime issue
  • Explanation of risk level: Classic problem well understood, classic fix
  • String changes made/needed: none
  • Is Android affected?: no
Attachment #9488274 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Whiteboard: [adv-main139+r]
QA Whiteboard: [sec] [qa-triage-done-c140/b139]
Flags: qe-verify-
Flags: needinfo?(jmathies)
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: