Closed Bug 2084749 Opened 1 month ago Closed 8 days ago

Crash in [@ webrtc::SharedScreenCastStreamPrivate::OnStreamProcess]

Categories

(Core :: WebRTC, defect)

defect

Tracking

()

RESOLVED FIXED
163 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr153 --- unaffected
firefox158 --- wontfix
firefox159 --- wontfix
firefox160 --- wontfix
firefox161 --- fix-optional
firefox162 --- fixed
firefox163 --- fixed

People

(Reporter: clouseau-bot, Assigned: jgrulich)

References

(Blocks 1 open bug, Regression, )

Details

(Keywords: crash, regression)

Crash Data

Attachments

(2 external files)

Crash report: https://crash-stats.mozilla.org/report/index/7940b50f-b518-46f8-ad0b-1ce7e0261021

Crash Reason:

SIGSEGV / SEGV_MAPERR at 0x0000000000000000

Top 10 frames:

0  libxul.so  webrtc::SharedScreenCastStreamPrivate::OnStreamProcess(void*)  third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc
1  libpipewire-0.3.so.0
2  libpipewire-0.3.so.0
3  libpipewire-0.3.so.0
4  libpipewire-0.3.so.0
5  libspa-support.so
6  libpipewire-0.3.so.0
7  firefox-bin  set_alt_signal_stack_and_start(PthreadCreateParams*)  mozglue/interposers/pthread_create_interposer.cpp:81
8  libc.so.6
9  libc.so.6

There is 1 crash in nightly 160 with buildid 20261019073400.

In the last 30 days, Firefox has 52 crashes (from 15 installations) on release, 5 crashes (from 3 installations) on beta/DevEdition and 2 crashes (from 2 installations) on nightly with this signature.

This signature has been reported since build 20260921231603 (2026-09-21), 27 days before the build above.

This bug looks actionable because:

  • SharedScreenCastStreamPrivate::OnStreamProcess dereferences a null pw_ on the pw-data-loop thread while the DesktopCapture thread is destroying the PipeWire stream via pw_.reset() in StopAndCleanupStream.

    1. DesktopCaptureImpl::ShutdownOnThread destroys the capturer, and ~BaseCapturerPipeWire calls StopScreenCastStream -> StopAndCleanupStream.
    2. StopAndCleanupStream stops only pw_->main_loop with pw_thread_loop_stop, then calls pw_.reset() (line 773).
    3. std::unique_ptr::reset() stores null into pw_ first, then runs ~PipeWireThreadLoop, which is still inside pw_stream_disconnect(stream) (line 218) when the crash happens.
    4. The PipeWire data loop is still running and delivers the stream's process event, calling OnStreamProcess on pw-data-loop.
    5. OnStreamProcess evaluates pw_stream_dequeue_buffer(that->pw_->stream) (line 493) with pw_ == nullptr and loads from address 0x18, the offset of PipeWireThreadLoop::stream.

    The report shows both halves at once: thread 138 faults with mov rbx, [rax+0x18] at address 0x18, and thread 135 is in ~PipeWireThreadLoop at line 218 under StopAndCleanupStream line 773. All 59 reports of this signature fault at the same address. The unique_ptr<PipeWireThreadLoop> design that opens this window came in with the libwebrtc vendor d2e600f2f07c. The old code read a raw pw_stream_ that stayed valid until after pw_stream_disconnect. Look first at teardown order: disconnect the stream, or remove spa_stream_listener_, while pw_ is still set and release it afterwards, or make the stream callbacks tolerate a null pw_.

  • The failing code comes from d2e600f2f07c (gh) (bug 2064200) by :mjf.

Code references:

:mjf, 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?(mfroman)

Jan, is this something you'd be interested in looking at?

Flags: needinfo?(mfroman) → needinfo?(jgrulich)
Assignee: nobody → jgrulich
Flags: needinfo?(jgrulich)
Status: NEW → ASSIGNED

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

For more information, please visit BugBot documentation.

Flags: needinfo?(mfroman)
Severity: -- → S2
Flags: needinfo?(mfroman)

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

OnStreamProcess() runs on PipeWire's data loop thread, not on
main_loop, so stopping main_loop does not stop it. Since 46ce2a180c,
StopAndCleanupStream() calls pw_.reset(), which nulls pw_ before
~PipeWireThreadLoop() disconnects the stream. An in-flight
OnStreamProcess() then dereferences a null pw_ and crashes. It also
clears queue_ and latest_available_frame_ while ProcessBuffer() can
still repopulate them, which can leave latest_available_frame_
dangling.

Add PipeWireThreadLoop::DestroyStream(), which disconnects and
destroys the stream; pw_stream_disconnect() waits for the data loop
to finish. Call it from StopAndCleanupStream() before resetting the
frame state, and from ~PipeWireThreadLoop() before destroying the
renegotiate event.

Add a regression test that stops the stream while a buffer is being
processed.

This is a simple backport of an WebRTC upstream change.

Upstream commit: 1d3a072191f6c26c5c4f3a59187c0065d7855d06

Pushed by jgrulich@redhat.com: https://github.com/mozilla-firefox/firefox/commit/aee7638110ec https://hg.mozilla.org/integration/autoland/rev/6ce9c54228fa WebRTC backport: [Wayland] Fix race between StopAndCleanupStream() and OnStreamProcess() r=pehrsons
Status: ASSIGNED → RESOLVED
Closed: 8 days ago
Resolution: --- → FIXED
Target Milestone: --- → 163 Branch

The patch landed in nightly and beta is affected.

:jgrulich, 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-firefox162 to wontfix if the fix can wait for the next release.

Uplift requests can be submitted from Lando: D343929.

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

For more information, please visit BugBot documentation.

Flags: needinfo?(jgrulich)

firefox-beta Uplift Approval Request

  • User impact if declined/Reason for urgency: Any Linux user on Wayland who tears down a WebRTC screen share (getDisplayMedia: "Stop sharing", call hang-up, tab close, or navigating away) can hit this null-deref. It is a hard SIGSEGV in the content process, not a catchable error. The tab/page dies immediately (crash report + lost page), which for the common case means dropping out of a live video call mid-meeting.
  • Code covered by automated testing?: no
  • Fix verified in Nightly?: no
  • Needs manual QE testing?: no
  • Steps to reproduce for manual QE testing:
  • Risk associated with taking this patch: low
  • Explanation of risk level: This is confirmed to fix the issue in WebRTC upstream and the patch is simple WebRTC backport.
  • String changes made/needed?: None
  • Is Android affected?: no
Attachment #9688977 - Flags: approval-mozilla-beta?

OnStreamProcess() runs on PipeWire's data loop thread, not on
main_loop, so stopping main_loop does not stop it. Since 46ce2a180c,
StopAndCleanupStream() calls pw_.reset(), which nulls pw_ before
~PipeWireThreadLoop() disconnects the stream. An in-flight
OnStreamProcess() then dereferences a null pw_ and crashes. It also
clears queue_ and latest_available_frame_ while ProcessBuffer() can
still repopulate them, which can leave latest_available_frame_
dangling.

Add PipeWireThreadLoop::DestroyStream(), which disconnects and
destroys the stream; pw_stream_disconnect() waits for the data loop
to finish. Call it from StopAndCleanupStream() before resetting the
frame state, and from ~PipeWireThreadLoop() before destroying the
renegotiate event.

Add a regression test that stops the stream while a buffer is being
processed.

This is a simple backport of an WebRTC upstream change.

Upstream commit: 1d3a072191f6c26c5c4f3a59187c0065d7855d06

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

Flags: needinfo?(jgrulich)
Attachment #9688977 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: