Closed Bug 1412726 Opened 3 years ago Closed 2 years ago

Clean up XPCOM singleton constructor refcount handling

Categories

(Core :: XPCOM, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla59
Tracking Status
firefox59 --- fixed

People

(Reporter: kmag, Assigned: kmag)

References

Details

Attachments

(1 file)

This is a follow-up to bug 1409249. There are a lot of places where our factory singleton constructors either don't correctly handle their returned references being released by the component manager, or do handle it, but in ways that are not obvious.

This patch handles a few places where we can sometimes wind up with dangling singleton pointers, adds some explanatory comments and sanity check assertions, and replaces some uses of manual refcounting with StaticRefPtr and ClearOnShutdown.

There are still some places where we may wind up with odd behavior if the first QI for a getService call fails, and we wind up destroying the first instance of a service that we create, and re-creating a new one later.
Comment on attachment 8923230 [details]
Bug 1412726: Clean up XPCOM singleton constructor refcount handling.

https://reviewboard.mozilla.org/r/194390/#review216276

Sorry for taking so long to review this.  This all seems very reasonable.
Attachment #8923230 - Flags: review?(nfroyd) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/8357c080dccbe4c6aaba3d9e012b3262f45ff7f6
Bug 1412726: Clean up XPCOM singleton constructor refcount handling. r=froydnj
https://hg.mozilla.org/mozilla-central/rev/8357c080dccb
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla59
Depends on: 1432391
You need to log in before you can comment on or make changes to this bug.