Closed Bug 2078358 Opened 1 month ago Closed 1 month ago

Crash in [@ mozilla::gl::GLContextEGL::Cast]

Categories

(Core :: Graphics: Canvas2D, defect)

defect

Tracking

()

RESOLVED FIXED
159 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr153 --- fixed
firefox157 --- wontfix
firefox158 --- wontfix
firefox159 --- fixed

People

(Reporter: clouseau-bot, Assigned: lsalzman)

References

(Blocks 1 open bug)

Details

(Keywords: crash)

Crash Data

Attachments

(2 external files)

Crash report: https://crash-stats.mozilla.org/report/index/1de29596-c757-4a20-af2f-7163e0261005

Crash Reason:

EXCEPTION_ACCESS_VIOLATION_READ at 0x0000000000000000

Top 10 frames:

0  xul.dll  mozilla::gl::SharedSurface_ANGLEShareHandle::LockProdImpl()  gfx/gl/SharedSurfaceANGLE.cpp:188
1  xul.dll  mozilla::layers::CanvasTranslator::ResolveExternalSnapshot(unsigned long long, m...  gfx/layers/ipc/CanvasTranslator.cpp:1883
2  xul.dll  mozilla::layers::RecordedResolveExternalSnapshot::PlayCanvasEvent(mozilla::layer...  gfx/layers/RecordedCanvasEventImpl.h:659
3  xul.dll  mozilla::layers::CanvasTranslator::HandleExtensionEvent(int)  gfx/layers/ipc/CanvasTranslator.cpp:973
4  xul.dll  mozilla::layers::CanvasTranslator::TranslateRecording()  gfx/layers/ipc/CanvasTranslator.cpp:804
5  xul.dll  mozilla::layers::CanvasTranslator::HandleCanvasTranslatorEvents()  gfx/layers/ipc/CanvasTranslator.cpp:893
6  xul.dll  mozilla::detail::RunnableMethodImpl<mozilla::net::BackgroundFileSaverStreamListe...  xpcom/threads/nsThreadUtils.h:1124
7  xul.dll  NS_ProcessNextEvent(nsIThread*, bool)  xpcom/threads/nsThreadUtils.cpp:471
8  xul.dll  mozilla::ipc::MessagePumpForNonMainThreads::Run(base::MessagePump::Delegate*)  ipc/glue/MessagePump.cpp:297
9  xul.dll  MessageLoop::RunHandler()  ipc/chromium/src/base/message_loop.cc:364

There are 2 crashes (from 1 installation) in nightly 159 with buildid 20261005080154.

In the last 30 days, Firefox has 13 crashes (from 6 installations) on nightly and 6 crashes (from 6 installations) on release with this signature.

This signature has been reported since build 20260315085700 (2026-03-15), 204 days before the build above.

This bug looks actionable because:

  • GLContextEGL::Cast dereferences a null GLContext in SharedSurface_ANGLEShareHandle::LockProdImpl when CanvasTranslator::ResolveExternalSnapshot begins reading a WebGL snapshot after its GL context is gone.

    1. CanvasTranslator::RecvSnapshotExternalCanvas stores a WebGL back-buffer SharedSurface in mExternalSnapshots for later resolution.
    2. That surface's mDesc.gl is a WeakPtr<GLContext>, so it becomes null if the WebGL context's GL context is destroyed before the snapshot is resolved.
    3. When the recorded RecordedResolveExternalSnapshot event plays, ResolveExternalSnapshot calls snapshot.mSharedSurface->BeginRead() with no check that the producing context is still alive.
    4. BeginRead calls LockProd, which calls LockProdImpl, which passes mDesc.gl to GLContextEGL::Cast; its gl->GetContextType() virtual call reads the vtable through the null pointer.

    The fault address 0x0 and the faulting instruction mov rax, qword [rdi] (a vtable load) fit a null gl, and frames 0-1 show this exact inlined path on the CanvasRenderer thread of the GPU process. The report does not record why the GL context was gone; context loss between snapshot and resolve is the likely trigger. Look first at ResolveExternalSnapshot (CanvasTranslator.cpp:1882-1883): check that mSharedSurface->mDesc.gl (or snapshot.mWebgl's GL context) is still alive before calling BeginRead()/EndRead(), or make LockProdImpl tolerate a null gl.

  • The failing code comes from c11e7594c36d (gh) (bug 1972649) by :lsalzman.

Code references:

:lsalzman, can you have a look please?

Filed automatically by Clouseau, which analyses nightly 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.

Flags: needinfo?(lsalzman)
Severity: -- → S3
Flags: needinfo?(lsalzman)

The owning GL context of a SharedSurface is held in a WeakPtr, so it may
go away while the SharedSurface is still referenced. Make the IsValid()
check detect this.

Assignee: nobody → lsalzman
Status: NEW → ASSIGNED
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 159 Branch

The patch landed in nightly and beta is affected.

:lsalzman, please make an uplift decision for beta:

  • For beta, nominate the patch for beta uplift approval if the fix should be included in this release, or set status-firefox158 to wontfix if the fix can wait for the next release.

See Requesting an Uplift for documentation on how to request an uplift.

For more information, please visit BugBot documentation.

Flags: needinfo?(lsalzman)

ESR153 might be nice, but I don't think the volume is high enough to worry about a late uplift to 158.

Flags: needinfo?(lsalzman)

firefox-esr153 Uplift Approval Request

  • User impact if declined/Reason for urgency: Potential crashing in WebGL
  • Code covered by automated testing?: yes
  • Fix verified in Nightly?: yes
  • Needs manual QE testing?: no
  • Steps to reproduce for manual QE testing:
  • Risk associated with taking this patch: low
  • Explanation of risk level: Adds a check to see if GL context is valid before using one of its shared surfaces
  • String changes made/needed?: None
  • Is Android affected?: yes
Attachment #9655622 - Flags: approval-mozilla-esr153?

The owning GL context of a SharedSurface is held in a WeakPtr, so it may
go away while the SharedSurface is still referenced. Make the IsValid()
check detect this.

Original Revision: https://phabricator.services.mozilla.com/D331421

Attachment #9655622 - Flags: approval-mozilla-esr153? → approval-mozilla-esr153+
QA Whiteboard: [qa-triage-done-c160/b159]
Duplicate of this bug: 2084327
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: