Closed Bug 834769 Opened 11 years ago Closed 11 years ago

Change the "destroyed" state value for RefCounted

Categories

(Core :: MFBT, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla21

People

(Reporter: glandium, Assigned: glandium)

References

Details

Attachments

(1 file, 1 obsolete file)

The current value is -0xdead, and when looking in a debugger, it can be confusing, because as a negative value, it will should up as -57005, and as hexadecimal, as 0xffff2153. This got me confused for a few in bug 834459 because i have had conflated values of ref count in the past because of a bug in the custom linker. If it had showed up as 0xffffdead, that would have been more obvious.
Attachment #706454 - Flags: review?(jwalden+bmo)
Assignee: nobody → mh+mozilla
Comment on attachment 706454 [details] [diff] [review]
Change the "destroyed" state value for RefCounted

Review of attachment 706454 [details] [diff] [review]:
-----------------------------------------------------------------

::: mfbt/RefPtr.h
@@ +46,5 @@
>      friend class RefPtr<T>;
>  
>    public:
>      RefCounted() : refCnt(0) { }
> +    ~RefCounted() { MOZ_ASSERT(refCnt == 0xffffdead); }

btw, you should probably make RefCounted's ctor and dtor protected. It doesn't make sense for someone to directly allocate or delete a RefCounted. Plus, RefCounted's dtor is not virtual, so derived classes' dtors would not be called (though a debug build would hit this assert).
Comment on attachment 706454 [details] [diff] [review]
Change the "destroyed" state value for RefCounted

Review of attachment 706454 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good.  Good call on protecting the ctor/dtor, indeed.
Attachment #706454 - Flags: review?(jwalden+bmo) → review+
Backed out. -Werror is making the tree red because of 0xffffdead being unsigned.
https://hg.mozilla.org/integration/mozilla-inbound/rev/954fc89373b8
Attachment #707571 - Flags: review?(jwalden+bmo)
Attachment #706454 - Attachment is obsolete: true
Attachment #707571 - Flags: review?(jwalden+bmo) → review+
https://hg.mozilla.org/mozilla-central/rev/799de1cf584b
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla21
Depends on: 837297
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: