Closed Bug 2084355 Opened 1 month ago Closed 19 days ago

Crash in [@ mozilla::MustConsumeMicroTask::~MustConsumeMicroTask]

Categories

(Core :: JavaScript Engine, defect, P3)

defect

Tracking

()

RESOLVED FIXED
162 Branch
Tracking Status
firefox-esr153 --- wontfix
firefox158 --- wontfix
firefox159 --- wontfix
firefox160 --- wontfix
firefox161 --- wontfix
firefox162 --- fixed

People

(Reporter: clouseau-bot, Assigned: mgaudet)

References

(Blocks 1 open bug)

Details

(Keywords: crash)

Crash Data

Attachments

(1 external file)

Crash report: https://crash-stats.mozilla.org/report/index/e4b56f5a-0948-408f-8dec-d995e0261020

MOZ_CRASH Reason:

MOZ_CRASH(Didn't consume MicroTask)

Top 10 frames:

0  xul.dll  mozilla::MustConsumeMicroTask::~MustConsumeMicroTask()  xpcom/base/CycleCollectedJSContext.h:148
1  xul.dll  mozilla::SuppressedMicroTaskList::~SuppressedMicroTaskList()  xpcom/base/CycleCollectedJSContext.cpp:755
2  xul.dll  mozilla::SuppressedMicroTaskList::~SuppressedMicroTaskList()  xpcom/base/CycleCollectedJSContext.cpp:752
3  xul.dll  mozilla::RunMicroTask(JSContext*, mozilla::CycleCollectedJSContext*, JS::Mutable...  xpcom/base/CycleCollectedJSContext.cpp:770
4  xul.dll  mozilla::CycleCollectedJSContext::PerformMicroTaskCheckPoint(bool)  xpcom/base/CycleCollectedJSContext.cpp:1295
5  xul.dll  JS::AutoDebuggerJobQueueInterruption::runJobs()  js/src/builtin/Promise.cpp:8677
6  xul.dll  js::DebugAPI::slowPathOnNewGlobalObject(JSContext*, JS::Handle<js::GlobalObject ...  js/src/debugger/Debugger.cpp:3012
7  xul.dll  JS_FireOnNewGlobalObject(JSContext*, JS::Handle<JSObject *>)  js/src/jsapi.cpp:1940
8  xul.dll  xpc::CreateSandboxObject(JSContext*, JS::MutableHandle<JS::Value>, nsISupports*,...  js/xpconnect/src/Sandbox.cpp:1556
9  xul.dll  nsXPCComponents_utils_Sandbox::CallOrConstruct(nsIXPConnectWrappedNative*, JSCon...  js/xpconnect/src/Sandbox.cpp:2208

There are 2 crashes (from 1 installation) in nightly 160 with buildid 20261019215902.

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

This signature has been reported since build 20251202094558 (2025-12-02), 322 days before the build above.

This bug looks actionable because:

  • A SuppressedMicroTaskList is destroyed while it still holds unconsumed MustConsumeMicroTask entries, so MOZ_CRASH("Didn't consume MicroTask") fires in ~MustConsumeMicroTask at CycleCollectedJSContext.h:150.

    1. A SuppressedMicroTaskList that still holds suppressed tasks is in the microtask queue while CycleCollectedJSContext::mSuppressedMicroTaskList no longer points to it, and no sync operation is active.
    2. PerformMicroTaskCheckPoint calls IsSuppressed(job) only when IsInSyncOperation() || mSuppressedMicroTaskList (CycleCollectedJSContext.cpp:1262), so SuppressedMicroTaskList::Suppressed(), the only code that hands the stored tasks back to the queue and clears the vector, is skipped.
    3. The job is passed to RunMicroTask (cpp:1295). MaybeConsumeAsOwnedRunnable takes the queue's reference, and the list's Run() is a no-op (CycleCollectedJSContext.h:252-255).
    4. The RefPtr<MicroTaskRunnable> goes out of scope at cpp:770. With no other owner, ~SuppressedMicroTaskList destroys mSuppressedMicroTaskRunnables, whose remaining entries are unconsumed and crash. The checks that would catch this (cpp:733, cpp:754) are debug-only MOZ_ASSERTs.

    Frames #0-#4 match this chain exactly. The crash fires inside ~SuppressedMicroTaskList reached from the RefPtr release in RunMicroTask, so the list was non-empty when its last reference dropped. The checkpoint here runs under JS::AutoDebuggerJobQueueInterruption::runJobs, triggered by a Debugger onNewGlobalObject hook while ExtensionPolicyService::CheckContentScripts creates a sandbox. How the list lost the context's reference is not shown by this report. One plausible route: PerformMicroTaskCheckPoint re-enqueues mSuppressedMicroTaskList at the end of every checkpoint, nested debugger checkpoints included (cpp:1313, whose comment notes nothing prevents duplicates), and SavedMicroTaskQueue::~SavedMicroTaskQueue moves it back into the restored queue. A stale duplicate list reaching Suppressed() while a newer list is current would then run mContext->mSuppressedMicroTaskList = nullptr (cpp:744) against the wrong list. Look first at whether a list can reach RunMicroTask without being drained: either drain or release-assert at the cpp:1262 gate for any SuppressedMicroTaskList job, and make Suppressed() only null the context pointer when it equals this.

  • The failing code comes from ba06cca1f77c (gh) (bug 1990842) by :mgaudet.

Code references:

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

Since nightly and release are affected, beta will likely be affected too.
For more information, please visit BugBot documentation.

Severity: -- → S3
Priority: -- → P3

This kind of issue has been around for a while; pre-SM owned microtask
I believe it would have been just duplicate promise handler runs.

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

There is an r+ patch which didn't land and no activity in this bug for 1 week.
:mgaudet, could you have a look please?
If you still have some work to do, you can add an action "Plan Changes" in Phabricator.
For more information, please visit BugBot documentation.

Flags: needinfo?(mgaudet)
Pushed by mgaudet@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/8a278d32949d https://hg.mozilla.org/integration/autoland/rev/5b11351833a1 Avoid re-enquing suppressed microtasks when the debugger has stashed the queue r=smaug
Status: ASSIGNED → RESOLVED
Closed: 19 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch

Since nightly and release are affected, beta will likely be affected too.
For more information, please visit BugBot documentation.

Flags: needinfo?(mgaudet)

The patch landed in nightly and beta is affected.

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

Uplift requests can be submitted from Lando: D336189.

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

For more information, please visit BugBot documentation.

Flags: needinfo?(mgaudet)
Flags: needinfo?(mgaudet) → in-testsuite+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: