Evaluate using std::unique_ptr instead of mozilla::StaticAutoPtr
Categories
(Core :: XPCOM, task)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox147 | --- | fixed |
People
(Reporter: sergesanspaille, Assigned: sergesanspaille)
References
(Depends on 1 open bug, Blocks 1 open bug)
Details
Attachments
(1 file)
StaticAutoPtr is equivalent to std::unique_ptr as the latter has a constexpr default constructor
| Assignee | ||
Updated•4 months ago
|
Comment 2•4 months ago
|
||
(In reply to [:sergesanspaille] from comment #0)
StaticAutoPtris equivalent tostd::unique_ptras the latter has aconstexprdefault constructor
This is not true, as std::unique_ptr has a destructor, which StaticAutoPtr does not. If you are converting to std::unique_ptr, you need to make a NeverDestroyed<std::unique_ptr> to disable the static destructor so we don't introduce new static destructors.
Static destructors like this waste memory by adding new entries, and can cause weird bugs in code which doesn't fast-exit, as they'll run as the process exits.
I do not think that a straight replacement of StaticAutoPtr with std::unique_ptr is a good idea, in fact I would prefer to do the opposite, and convert more static std::unique_ptr instances to remove the static destructors.
| Assignee | ||
Comment 3•4 months ago
|
||
In particular make it clear that it behaves differently from
std::unique_ptr in termes of destructor.
Updated•4 months ago
|
| Assignee | ||
Comment 4•4 months ago
|
||
Indeed! I updated the internal documentation and cancelled the associated child bugs.
Comment 6•4 months ago
|
||
| bugherder | ||
Description
•