Closed Bug 1834640 Opened 1 years ago Closed 1 years ago

nsSocketTransportService doesn't properly shutdown during xpcom-shutdown-threads

Categories

(Core :: Networking, defect, P2)

defect

Tracking

()

RESOLVED FIXED
115 Branch
Tracking Status
firefox-esr102 --- unaffected
firefox113 --- wontfix
firefox114 --- wontfix
firefox115 --- fixed

People

(Reporter: nika, Assigned: nika)

References

(Regression)

Details

(Keywords: regression, Whiteboard: [necko-triaged])

Attachments

(2 files)

In bug 1818998, nsSocketTransportService was changed to call Shutdown(true) instead of ShutdownThreads() during xpcom-shutdown-threads. This combined with the new implementation of the method meant that the observer notification would only wait for the thread to actually exit in content processes, where the socket runnable is not used.

This meant that the thread would not run it's proper shutdown stages early enough leading to the possibility for dispatch errors from IPC such as those which caused bug 1828389 to be backed out. The thread would only end up exiting during ShutdownNonMainThreads cleanup, which is too late.

While looking at the relevant code, I noticed the unannotated mutex, and added
some annotations to it. The minor changes I had to do to keep the tree
building after the annotations shouldn't be actual threadsafety issues, as
most of it is either dead code, or exclusively called from the only mutating
thread.

This also cleans up some of the unnecessary flags & memebrs which were held
during the changes in bug 1818998. mSelf was unncessary as the runnable
reference will be keeping the instance alive for the same lifetime, and
mSocketThreadShutDown was redundant with !mInitialized.

This change will also fix a potential issue where the socket thread was not
being shut down when switching the browser into an offline state from
profile-change-net-teardown, which could've lead to thread leaks when the
browser is returned to an online state. The restore codepath, however, has
been dead for a long time so this is unlikely to be a real issue in practice.

Depends on D178867

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

Severity: -- → S3
Status: NEW → ASSIGNED
Priority: -- → P2
Whiteboard: [necko-triaged]
Pushed by nlayzell@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f762e1cce59c Part 1: Add threadsafety annotations to nsSocketTransportService, r=jesup,necko-reviewers https://hg.mozilla.org/integration/autoland/rev/3e4914be9f30 Part 2: Properly shutdown nsSocketTransportService during xpcom-shutdown-threads, r=jesup,necko-reviewers
Status: ASSIGNED → RESOLVED
Closed: 1 years ago
Resolution: --- → FIXED
Target Milestone: --- → 115 Branch
Regressions: 1835430
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: