Closed Bug 1700508 Opened 5 years ago Closed 5 years ago

Perma Assertion failure: !(aSource == kCharsetFromChannel && !aChannelHadCharset) (If charset is from channel, channel must have had charset.), at /builds/worker/checkouts/gecko/parser/html/nsHtml5StreamParser.h:245

Categories

(Thunderbird :: Upstream Synchronization, defect, P5)

defect

Tracking

(thunderbird_esr78 unaffected)

RESOLVED FIXED
89 Branch
Tracking Status
thunderbird_esr78 --- unaffected

People

(Reporter: intermittent-bug-filer, Assigned: darktrojan)

References

(Regression)

Details

(Keywords: assertion, intermittent-failure)

Attachments

(1 file)

(In reply to Masatoshi Kimura [:emk] from comment #2)

I think this line should be changed to

  parser->SetDocumentCharset(encoding, charsetSource, charsetSource == kCharsetFromChannel);

.

nsSAXXMLReader is never supposed to combine with nsHtml5StreamParser, so I suspect the reason is elsewhere.

Sure.

Here is another hypothesis.

nsMessenger::SetDisplayCharset calls SetHintCharacterSetSource(kCharsetFromChannel):
https://searchfox.org/comm-central/rev/938bb1a03265a9e9c82ed0abcb7ec42c66fdbccf/mailnews/base/src/nsMessenger.cpp#279

So charsetSource may change to kCharsetFromChannel without updating channelHadCharset here:
https://searchfox.org/mozilla-central/rev/6c9ff2820d3aae683ec87c53c79e5108d54f3f76/dom/html/nsHTMLDocument.cpp#483

Should the channelHadCharset assignment just be moved down to after the tries have concluded?

I've been looking at this. We should look at fixing our channel implementations to return a charset. Hard-wiring it to UTF-8 almost works, as pointed out here libmime always converts to UTF-8. However if we just output the raw data, for example to view source, it might not be UTF-8. Could we set the channel charset only if libmime gets involved? I think that would prevent this assertion failure – nsHtml5StreamParser's not going to be involved in any other situation that I can think of.

Here's a Try run showing what happens if you hard-wire UTF-8 in the channels. Only the view source test is complaining.

https://treeherder.mozilla.org/jobs?repo=try-comm-central&group_state=expanded&revision=685fc2ef6c30cf85246764a796832d3ce5f742ad

(In reply to Magnus Melin [:mkmelin] from comment #8)

Should the channelHadCharset assignment just be moved down to after the tries have concluded?

No, if TryUserForcedCharset changes the charsetSource to something stronger than kCharsetFromChannel, charsetSource is not kCharsetFromChannel while channelHadCharset is true. channelHadCharset has been introduced to handle this exact situation.

Since the source is an internal component that always sets the encoding to UTF-8, I suggest changing the source value to kCharsetFromBuiltIn.

However if we just output the raw data, for example to view source, it might not be UTF-8.

Except kCharsetFromBuiltIn doesn't make sense for that case.

I don't think that case should be coming through here, so that's alright.

I just realised my Try run in comment 10 was opt when it should've been debug. I wondered why it went so well. :-/

Thanks to hsivonen for the suggestion.

Assignee: nobody → geoff
Status: NEW → ASSIGNED
Target Milestone: --- → 89 Branch

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/0aa11a1c79fa
Fix assertion failure in nsHtml5StreamParser.h. r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: