Closed Bug 936728 Opened 12 years ago Closed 3 years ago

Call ClearWeakReferences() during unlinking for cycle collected nsSupportsWeakReference classes

Categories

(Core :: Cycle Collector, defect)

defect

Tracking

()

RESOLVED DUPLICATE of bug 1535617

People

(Reporter: mccr8, Unassigned)

Details

bz figured out this happens some times in bug 933447. An unlinked object won't go away immediately, so potentially something can use a weak reference to the object and see the unlinked object, which would be bad. This probably isn't too terrible nowadays, but it is better to be safe. One way to do this would be to create a templated helper thing that turns into ClearWeakReferences() for classes that are a subclass of nsSupportsWeakReference, and nothing otherwise, and somehow shove that into the UNLINK boilerplate. Then nobody can forget to do this.
(In reply to Boris Zbarsky [:bz] from comment #12) > So Olli had some thoughts on IRC about making do_QueryReferent return null > for referents with a refcount of 0, I think. That would provide a less > whack-a-molish fix for the problem.
I kind of like the idea of doing ClearWeakReference in Unlink, because then we don't have to worry about incomplete unlinking giving an object a refcount of > 0.
Yeah, the idea of comment 0 should be pretty simple to do. The one exception is FragmentOrElement subclasses, which don't use nsSupportsWeakReference. But we can explicitly clear stuff out in FragmentOrElement's unlink; wouldn't be the first (or even fifth) weird custom thing in there. ;)
In particular, templating this stuff using IsBaseOf should be quite trivial.
Group: core-security → dom-core-security
Andrew: still relevant?
Flags: needinfo?(continuation)
Yeah, probably. I don't think it really needs to be a hidden bug, though, as I've never seen any evidence that this happens.
Group: dom-core-security
Flags: needinfo?(continuation)
Keywords: sec-moderate
Severity: normal → S3
Status: NEW → RESOLVED
Closed: 3 years ago
Duplicate of bug: 1535617
Resolution: --- → DUPLICATE
Component: XPCOM → Cycle Collector
You need to log in before you can comment on or make changes to this bug.