Assertion failure: mMainThreadTrackCount > 0 || mMainThreadPortCount > 0, at /builds/worker/checkouts/gecko/dom/media/MediaTrackGraph.cpp:2092
Categories
(Core :: Audio/Video: Playback, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox-esr115 | --- | unaffected |
| firefox121 | --- | wontfix |
| firefox122 | --- | wontfix |
| firefox123 | --- | verified |
People
(Reporter: tsmith, Assigned: karlt)
References
(Blocks 1 open bug, Regression)
Details
(5 keywords, Whiteboard: [bugmon:bisected,confirmed])
Attachments
(1 file, 3 external files)
|
418 bytes,
text/html
|
Details |
Found while fuzzing m-c 20231103-db8c28afe588 (--enable-debug --enable-fuzzing)
To reproduce via Grizzly Replay:
$ pip install fuzzfetch grizzly-framework
$ python -m fuzzfetch -d --fuzzing -n firefox
$ python -m grizzly.replay.bugzilla ./firefox/firefox <bugid>
Assertion failure: mMainThreadTrackCount > 0 || mMainThreadPortCount > 0, at /builds/worker/checkouts/gecko/dom/media/MediaTrackGraph.cpp:2092
#0 0x7f0396297041 in mozilla::MediaTrackGraphImpl::AppendMessage(mozilla::UniquePtr<mozilla::MediaTrack::ControlMessageInterface, mozilla::DefaultDelete<mozilla::MediaTrack::ControlMessageInterface>>) /builds/worker/checkouts/gecko/dom/media/MediaTrackGraph.cpp:2092:3
#1 0x7f0396294784 in QueueControlMessageWithNoShutdown<(lambda at /builds/worker/checkouts/gecko/dom/media/MediaTrackGraph.cpp:1719:7)> /builds/worker/checkouts/gecko/dom/media/MediaTrackGraphImpl.h:202:5
#2 0x7f0396294784 in mozilla::MediaTrackGraphImpl::Observe(nsISupports*, char const*, char16_t const*) /builds/worker/checkouts/gecko/dom/media/MediaTrackGraph.cpp:1718:3
#3 0x7f0396294b63 in non-virtual thunk to mozilla::MediaTrackGraphImpl::Observe(nsISupports*, char const*, char16_t const*) /builds/worker/checkouts/gecko/dom/media/MediaTrackGraph.cpp
#4 0x7f03923ac92a in NotifyObservers /builds/worker/checkouts/gecko/xpcom/ds/nsObserverList.cpp:71:19
#5 0x7f03923ac92a in nsObserverService::NotifyObservers(nsISupports*, char const*, char16_t const*) /builds/worker/checkouts/gecko/xpcom/ds/nsObserverService.cpp:288:19
#6 0x7f03940b5734 in mozilla::dom::Document::DoNotifyPossibleTitleChange() /builds/worker/checkouts/gecko/dom/base/Document.cpp:9313:10
#7 0x7f0394160f49 in operator()<> /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1164:18
#8 0x7f0394160f49 in __invoke_impl<void, (lambda at /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1163:9)> /builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/invoke.h:60:14
#9 0x7f0394160f49 in __invoke<(lambda at /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1163:9)> /builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/invoke.h:95:14
#10 0x7f0394160f49 in __apply_impl<(lambda at /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1163:9), std::tuple<> &> /builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/tuple:1678:14
#11 0x7f0394160f49 in apply<(lambda at /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1163:9), std::tuple<> &> /builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/tuple:1687:14
#12 0x7f0394160f49 in apply<mozilla::dom::Document, void (mozilla::dom::Document::*)()> /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1162:12
#13 0x7f0394160f49 in mozilla::detail::RunnableMethodImpl<mozilla::dom::Document*, void (mozilla::dom::Document::*)(), false, (mozilla::RunnableKind)0>::Run() /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1213:13
#14 0x7f039244a337 in mozilla::RunnableTask::Run() /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:568:16
#15 0x7f039243faa6 in mozilla::TaskController::DoExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:895:26
#16 0x7f039243e287 in mozilla::TaskController::ExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:718:15
#17 0x7f039243e705 in mozilla::TaskController::ProcessPendingMTTask(bool) /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:504:36
#18 0x7f039244e2d6 in operator() /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:222:37
#19 0x7f039244e2d6 in mozilla::detail::RunnableFunction<mozilla::TaskController::TaskController()::$_0>::Run() /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.h:548:5
#20 0x7f0392463642 in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:1199:16
#21 0x7f039246a78d in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:480:10
#22 0x7f039313dac5 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /builds/worker/checkouts/gecko/ipc/glue/MessagePump.cpp:85:21
#23 0x7f0393057591 in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:363:3
#24 0x7f0393057591 in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:345:3
#25 0x7f0397984248 in nsBaseAppShell::Run() /builds/worker/checkouts/gecko/widget/nsBaseAppShell.cpp:148:27
#26 0x7f0397a41218 in nsAppShell::Run() /builds/worker/checkouts/gecko/widget/gtk/nsAppShell.cpp:470:33
#27 0x7f0399874bbb in XRE_RunAppShell() /builds/worker/checkouts/gecko/toolkit/xre/nsEmbedFunctions.cpp:721:20
#28 0x7f039313e9a6 in mozilla::ipc::MessagePumpForChildProcess::Run(base::MessagePump::Delegate*) /builds/worker/checkouts/gecko/ipc/glue/MessagePump.cpp:235:9
#29 0x7f0393057591 in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:363:3
#30 0x7f0393057591 in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:345:3
#31 0x7f0399874422 in XRE_InitChildProcess(int, char**, XREChildData const*) /builds/worker/checkouts/gecko/toolkit/xre/nsEmbedFunctions.cpp:656:34
#32 0x55d3d1e52156 in content_process_main /builds/worker/checkouts/gecko/browser/app/../../ipc/contentproc/plugin-container.cpp:57:28
#33 0x55d3d1e52156 in main /builds/worker/checkouts/gecko/browser/app/nsBrowserApp.cpp:375:18
#34 0x7f03a6a29d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#35 0x7f03a6a29e3f in __libc_start_main csu/../csu/libc-start.c:392:3
#36 0x55d3d1e27e88 in _start (/home/user/workspace/browsers/m-c-20240102161658-fuzzing-debug/firefox-bin+0x58e88) (BuildId: 507e52af05b747dbd8efbe2c70d2b11980ccc847)
Comment 1•2 years ago
|
||
Verified bug as reproducible on mozilla-central 20240103050624-cc67c788cded.
The bug appears to have been introduced in the following build range:
Start: d4349b4d125e0f15795e18bd8ffa2990396b020e (20231027055145)
End: 6e09ac4a4c291480d5951adca6d1659a46f571b2 (20231027085616)
Pushlog: https://hg.mozilla.org/integration/autoland/pushloghtml?fromchange=d4349b4d125e0f15795e18bd8ffa2990396b020e&tochange=6e09ac4a4c291480d5951adca6d1659a46f571b2
Comment 2•2 years ago
|
||
:karlt could this be bug 1860954 based on the above regression range?
| Assignee | ||
Comment 3•2 years ago
|
||
This is definitely related to https://hg.mozilla.org/integration/autoland/rev/899c4a0b9085b8781713f9fd29a5fdd91b55ade1#l3.64, thanks.
Comment 4•2 years ago
|
||
Set release status flags based on info from the regressing bug 1860954
Updated•2 years ago
|
Comment 5•2 years ago
|
||
Successfully recorded a pernosco session. A link to the pernosco session will be added here shortly.
| Comment hidden (obsolete) |
| Assignee | ||
Comment 9•2 years ago
|
||
There is a leak until content process shutdown here, which existed prior to changes for bug 1860954. The leak is up to one MediaTrackGraph per window, which is triggered in an edge case scenario that is unlikely to occur on production sites because it is not supported and so not useful to content.
I'd still like to fix this on m-c, because such an assertion failure might plausibly be more serious if there were other flaws. The flaw identified here, however, doesn't cause too much trouble because the observer service is keeping the graph alive.
| Assignee | ||
Updated•2 years ago
|
| Assignee | ||
Comment 10•2 years ago
|
||
A MediaTrackGraph starts the graph thread on the first message. It shuts down the graph thread when the graph thread sees that there are no tracks and no messages.
If a MediaTrackGraph is created and the graph thread is never started, then the MediaTrackGraph leaks due to its self ref and the driver's ref. A threaded driver (at least) has a thread, which blocks shut down in nsThreadManager::ShutdownNonMainThreads().
This situation occurs here because HTMLMediaElement::CaptureStreamInternal() returns early because the graph of mTracksCapture, which is used when the media element is playing a decoded media resource, does not match the graph created in MozCaptureStreamUntilEnded().
That leak has existed for a long time. https://hg.mozilla.org/integration/autoland/rev/899c4a0b9085b8781713f9fd29a5fdd91b55ade1#l3.73 added a graph message, which asserts that the graph has a track (or port).
| Assignee | ||
Comment 11•2 years ago
|
||
The assertion can be resolved by adding the document-title-changed observer in AddTrack() instead of in the constructor, to match removal in RemoveTrack(), but the testcase cannot be landed until the leak is addressed.
MozCaptureStreamUntilEnded() does not need a graph of a particular sample rate (thanks, Andreas). It can use the graph of mTracksCapture, if that already exists, and a graph of default sample rate need only be created if a track will be added to the graph.
| Assignee | ||
Comment 12•2 years ago
|
||
| Assignee | ||
Comment 13•2 years ago
|
||
If the graph leaks because it does not shut down its driver, then an nsThread
can be leaked and block shutdown at nsThreadManager::ShutdownNonMainThreads().
The shutdown blocker has better debug messages to identify the source of the
blockage than ShutdownNonMainThreads(), so I'd like to remove
MediaTrackGraph's code that removes it's shutdown blocker after a timeout.
This new assert is intended to give some visibility into how many problems
such removal might cause.
Depends on D198769
| Assignee | ||
Comment 14•2 years ago
|
||
The graph of the MediaElementAudioSourceNode will be used for tracks for
decoded media resource output.
Similarly for mozCaptureStreamUntilEnded().
The MediaTrackGraph of default sample rate is now constructed only if required
and when a track on the graph will be created, to address a MediaTrackGraph
leak, and so allows landing a crashtest.
Tab audio capture still expects the default graph.
See also https://bugzilla.mozilla.org/show_bug.cgi?id=1633436
Depends on D198770
Comment 15•2 years ago
|
||
Comment 16•2 years ago
|
||
Comment 17•2 years ago
|
||
Comment 18•2 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/e783caa35243
https://hg.mozilla.org/mozilla-central/rev/d55f0de1728b
https://hg.mozilla.org/mozilla-central/rev/9b3c08820aaa
Comment 19•2 years ago
|
||
Verified bug as fixed on rev mozilla-central 20240118095536-842adcf822fc.
Removing bugmon keyword as no further action possible. Please review the bug and re-add the keyword for further analysis.
Description
•