Open Bug 1905445 Opened 11 days ago Updated 13 hours ago

Provide a safer alternative for some CheckedUnsafePtr use cases

Categories

(Core :: Storage: Quota Manager, task, P2)

task

Tracking

()

ASSIGNED

People

(Reporter: janv, Assigned: janv)

References

(Blocks 1 open bug)

Details

Attachments

(6 files)

We have many cases where we use CheckedUnsafePtr just to make sure that we get notified (by an assertion) that an object is being destroyed before it was removed from a global hash table or an array. Ordinary replacement of CheckedUnsafePtr with RefPtr would make it hard to find out where we miss an unregisteration in a global hash table/array (global tracking would keep the object alive forever). I think we can create a safer alternative to CheckedUnsafePtr which would preserve the checks/assertions for a missing unregistration.
This can lead to elimination of CheckedUnsafePtr for good.

Blocks: 1905612

This is a new version of D215351 which addresses some initial design comments.
A thread safe version of RefCountedSharedObject should be able to avoid a
static mutex and use std::atomic.
The new design is not limited to always trigger a diagnostic assertion. It
allows to do custom checks and cleanup when the holder becomes the last one
holding a strong ref to the object.

You need to log in before you can comment on or make changes to this bug.