Closed Bug 1229458 Opened 9 years ago Closed 9 years ago

"Assertion failure: !IsReadonly() (shared StringBuffer in SizeOfIncludingThisMustBeUnshared)" with <object id>

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
critical

Tracking

()

RESOLVED FIXED
mozilla45
Tracking Status
firefox45 --- fixed

People

(Reporter: jruderman, Assigned: n.nethercote)

References

Details

(Keywords: assertion, testcase)

Attachments

(3 files)

Attached file testcase
1. Load the testcase
2. Quickly click "Measure" in about:memory

Assertion failure: !IsReadonly() (shared StringBuffer in SizeOfIncludingThisMustBeUnshared), at xpcom/string/nsSubstring.cpp:323

This assertion was upgraded to fatal in bug 1225365.
Attached file stack
Yeah, nsStringHashKey::SizeOfExcludingThis shouldn't be assuming its string is unshared.  It even has a comment about how it shouldn't be assuming it...

Looks like a regression from bug 1046281 and affects some of the other hashkeys too.
Blocks: 1046281
Assignee: nobody → continuation
Honestly, I'm not really sure of the value of ever using SizeOfIncludingThisMustBeUnshared() instead of SizeOfIncludingThisIfUnshared().
What do you think about just ditching MustBeUnshared() for IfUnshared(), Nick?
Flags: needinfo?(n.nethercote)
The former landed in bug 671299, and the latter in bug 712835.
> What do you think about just ditching MustBeUnshared() for IfUnshared(), Nick?

Yeah, good idea. It's just adding unnecessary brittleness.
Flags: needinfo?(n.nethercote)
Assignee: continuation → n.nethercote
The patch changes all uses of SizeOfIncludingThisMustBeUnshared() to
SizeOfIncludingThisIfUnshared(). This incurs the (tiny) cost of an unnecessary
IsReadonly() check for guaranteed-unshared strings, but avoids the possible
assertion failures that would occur when MustBeUnshared() was used incorrectly
on shared strings, which is an easy mistake to make.
Attachment #8694444 - Flags: review?(continuation)
Comment on attachment 8694444 [details] [diff] [review]
Remove SizeOfIncludingThisMustBeUnshared() from string classes

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

Thanks for fixing this.

::: xpcom/string/nsTSubstring.cpp
@@ +1005,5 @@
>      mozilla::MallocSizeOf aMallocSizeOf) const
>  {
>    if (mFlags & F_SHARED) {
>      return nsStringBuffer::FromData(mData)->
> +           SizeOfIncludingThisIfUnshared(aMallocSizeOf);

This new indentation looks weird to me. Maybe more like the old one?
Attachment #8694444 - Flags: review?(continuation) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/d746378ad672eda7c9f33a0e93e08291bff5f5e3
Bug 1229458 - Remove SizeOfIncludingThisMustBeUnshared() from string classes. r=mccr8.
https://hg.mozilla.org/mozilla-central/rev/d746378ad672
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: