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)
Core
Cycle Collector
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.
| Reporter | ||
Comment 1•12 years ago
|
||
(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.
| Reporter | ||
Comment 2•12 years ago
|
||
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.
Comment 3•12 years ago
|
||
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. ;)
Comment 4•12 years ago
|
||
In particular, templating this stuff using IsBaseOf should be quite trivial.
Updated•10 years ago
|
Group: core-security → dom-core-security
| Reporter | ||
Comment 6•10 years ago
|
||
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.
Updated•3 years ago
|
Severity: normal → S3
| Reporter | ||
Updated•3 years ago
|
| Reporter | ||
Updated•3 years ago
|
Component: XPCOM → Cycle Collector
You need to log in
before you can comment on or make changes to this bug.
Description
•