Closed Bug 1707924 Opened 3 years ago Closed 1 year ago

Background TaskQueues created after beginning shutdown will cause a hang

Categories

(Core :: XPCOM, defect)

defect

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: KrisWright, Assigned: KrisWright)

Details

Attachments

(2 obsolete files)

There is an order of events that causes a hang:

We could just change how to dispatch delayed runnable cancel tasks, but I think the best solution is to outright forbid the creation of new background TaskQueues after we have begun shutdown. Since this problem is specific to the way background task queue shut down, I don't want to change the behavior of any unrelated task queue who dispatch delayed runnables and shut down on their own. It also isn't a good idea to allow creation of background TaskQueue to dispatch with at a point when dispatch may not be possible (ie no thread to service it).

I discovered today an order of events that causes a hang:

We could just change how to dispatch delayed runnable cancel tasks, but I think the best solution is to outright forbid the creation of new background TaskQueues after we have begun shutdown. Since this problem is specific to the way background task queue shut down, I don't want to change the behavior of any unrelated task queue who dispatch delayed runnables and shut down in their own time.

(In reply to Kris Wright :KrisWright from comment #0)

I want to leave a note here for clarity that this is not a true tail dispatch, but the callsite will actually do a regular dispatch at the tail. This is done to guarantee a dispatch sync.

This assertion currently only happens on debug builds, but attempts to dispatch delayed runnables after we have started or finished cancelling all delayed runnables in a TaskQueue may be causing shutdown hangs.

Pushed by kwright@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c6213e0b8024
Disallow creation of new TaskQueues after we have begun threads shutdown r=xpcom-reviewers,nika
https://hg.mozilla.org/integration/autoland/rev/7fda47840322
Assert on DelayedRunnable dispatch on non debug builds. r=xpcom-reviewers,nika

There are some r+ patches which didn't land and no activity in this bug for 2 weeks.
:KrisWright, could you have a look please?
For more information, please visit auto_nag documentation.

Flags: needinfo?(nika)
Flags: needinfo?(kwright)

This bug is related to a few other bugs which are being updated.

Flags: needinfo?(nika)
Flags: needinfo?(kwright)

FWIW, just a note on gXPCOMThreadsShutDown in general: The condition gXPCOMThreadsShutDown == true is now equivalent to mozilla::AppShutdown::GetCurrentShutdownPhase() >= mozilla::ShutdownPhase::XPCOMShutdownThreads, meaning that we could remove this additional global if we want (and check for this condition from everywhere we want).

Attachment #9218678 - Attachment is obsolete: true
Attachment #9219311 - Attachment is obsolete: true

Do we still plan to do something here, or should we close this bug out?

Flags: needinfo?(kwright)

From my understanding this behavior shouldn't work during shutdown anymore. I think we're good to close it out.

Status: NEW → RESOLVED
Closed: 1 year ago
Flags: needinfo?(kwright)
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: