Closed Bug 401613 Opened 17 years ago Closed 17 years ago

Intermittent XML parsing errors with this valid SVG file

Categories

(Core :: SVG, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla1.9beta2

People

(Reporter: longsonr, Assigned: peterv)

References

Details

(Keywords: regression, testcase)

Attachments

(4 files, 4 obsolete files)

Attached image testcase (deleted) —
      No description provided.
Attached file same as testcase without namespaces (deleted) —
If the xmlns parts are removed the file loads as an XML file.
If you make the file small enough by hacking out sections that also makes it load.
It loads OK in firefox 2.0 but since that does not have incremental XML I guess that's not surprising.
I don't see an xml error here with the svg version, but if it's a incremental XML thing this could timing dependent.

FWIW, the person who wrote the original needs to fix their SVG as they're trying to use "-1" and "1" as the values of flags of the path "A" command, when the allowed values are "0" and "1".
It is timing dependent as I get different parse errors each time I refresh the page.

Google found it for me :-) I don't know who the original author is although investigating the source of the jpegs might lead to an answer I suppose.
Attached image example parse error (deleted) —
I tried this on another computer and I can't get it to break there so maybe it's

a) Vista only, or
b) requires a fast computer to break
I've been getting intermittent XML Parsing Error that disappear on refresh etc. for ages. Never reliably reproducible though. Perhaps if you can consistently reproduce the problem you could dig into it a bit?
Jonathan, can you try taking the attachment and use cut/paste to make it bigger. Just take everything in the <svg> tags and paste that back into the document. If you make it big enough (try 5x as big) it fails for me on my Windows XP computer too.
Yeah, making it even just twice the size makes it much more reproducible.
Flags: blocking1.9?
Keywords: regression, testcase
Putting a breakpoint here catches the error:

http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/parser/htmlparser/src/nsExpatDriver.cpp&rev=3.105&mark=807-809#796

I need to continue with my reviews right now, but I can help with this a bit later.
Summary: get xml parse errors from valid SVG file → Intermittent XML parsing errors with this valid SVG file
I see the following assertion before go things south:

###!!! ASSERTION: Inconsistent expat suspension state.: 'status != XML_STATUS_SUSPENDED || (mInternalState == NS_ERROR_HTMLPARSER_BLOCK || mInternalState == NS_ERROR_HTMLPARSER_INTERRUPTED)', file c:/home/moz/trunk/debug/parser/htmlparser/src/../../../../mozilla/parser/htmlparser/src/nsExpatDriver.cpp, line 1008
I added the blocking bug 401146 because this error is being throw on several of our talos testing boxes - causing constantly burning trees (see qm-mini-xp01 and qm-mini-xp04 on MozillaTest tinderbox).  I would rather not push burning trees to the Firefox tinderbox page so this is blocking moving talos machines to production.
Attached patch wallpaper patch (obsolete) (deleted) — Splinter Review
If I add back the "wallpaper" that was removed in the development of the bug 18333 patch, I can't reproduce the XML parse error.  Not sure how we're getting into this state, though.
I think processing the long d attributes takes so long that the parser returns XML_STATUS_SUSPENDED as per this comment in nsParser.cpp.

This capability is currently used in CNavDTD and nsHTMLContentSink. The
nsHTMLContentSink is notified by CNavDTD when a chunk of tokens is going to be
processed and when each token is processed. The nsHTML content sink records
the time when the chunk has started processing and will return
NS_ERROR_HTMLPARSER_INTERRUPTED if the token processing time has exceeded a
threshold called max tokenizing processing time. This allows the content sink
to limit how much data is processed in a single chunk which in turn gates how
much time is spent away from the event loop. Processing smaller chunks of data
also reduces the time spent in subsequent reflows.
Peter, is the attached patch the right thing to do?
Assignee: nobody → peterv
Flags: blocking1.9? → blocking1.9+
Priority: -- → P2
OS: Windows Vista → All
Hardware: PC → All
(In reply to comment #17)
> Peter, is the attached patch the right thing to do?

Nope, we need to find the root cause. I can't reproduce it, but the problem is probably an EndElement call clobbering mInternalState. Need to be careful to handle this without dropping errors.
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla1.9 M10
If you make the file bigger using cut/paste to duplicate everything within the <svg> tags several times it seems to be easier to reproduce.
Attached patch v1 (obsolete) (deleted) — Splinter Review
I've been able to reproduce this once. Could you guys try this patch and let me know if it seems to fix the problem for you?
Attachment #286866 - Attachment is obsolete: true
Your patch fixes things for me Peter.
Attached patch v1.1 (obsolete) (deleted) — Splinter Review
The issue is that after blocking Expat from the start element handler it can still call at least the end element and the end namespace declaration handlers for empty elements (http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/parser/expat/lib/expat.h&rev=1.11#763). When that happens the end element handler shouldn't clobber mInternalState. I thought I could assert mInternalState != NS_ERROR_HTMLPARSER_BLOCK in HandleEndElement/HandleEndNamespaceDecl, but it looks like at least nsCrossSiteListenerProxy::HandleStartElement returns NS_ERROR_HTMLPARSER_BLOCK.
Attachment #288012 - Attachment is obsolete: true
Attachment #288353 - Flags: superreview?(bzbarsky)
Attachment #288353 - Flags: review?(bzbarsky)
If we think that it's reasonable to disallow blocking from HandleStartElement, we should do it.  In the case of nsCrossSiteListenerProxy, it should be using NS_ERROR_HTMLPARSER_STOPPARSING anyway, no?  The only issue is that as far as I can see nsExpatDriver doesnt treat that return value as meaning "terminate now".  I think it should.  Of course your patch changes it so that it does!  So want to go ahead and change the proxy to return STOPPARSING and then add that assert?



If it's not much extra code to allow blocking from HandleStartElement I think we should allow it. I would be surprised if we'd never end up needing that.
So basically, if peters patch already does allow it, I think we should check it in. If not, we should at least add assertions and warnings to the relevant headers.
Well, whatever we do here we should change the proxy to terminate the parser, not just pause it, right?
Ah, indeed.  But in that case nsExpatDriver should probably not clobber a STOPPARSING error could with BLOCK_PARSER either (which is what I think it's doing right now), right?
So maybe we should just return early in HandleEndElement and HandleEndNamespaceDecl if mInternalState == NS_ERROR_HTMLPARSER_STOPPARSING? And change the nsCrossSiteListenerProxy to return NS_ERROR_HTMLPARSER_STOPPARSING.
That would make sense to me.  Should we also stop expat if a callback returns STOPPARSING?
Comment on attachment 288353 [details] [diff] [review]
v1.1

Pending that update.  The rest of this looks reasonable to me.
Attachment #288353 - Flags: superreview?(bzbarsky)
Attachment #288353 - Flags: superreview-
Attachment #288353 - Flags: review?(bzbarsky)
Attachment #288353 - Flags: review-
Attached patch v1.2 (obsolete) (deleted) — Splinter Review
Attachment #288353 - Attachment is obsolete: true
Attachment #289171 - Flags: superreview?(bzbarsky)
Attachment #289171 - Flags: review?(bzbarsky)
Attached patch v1.2 (deleted) — Splinter Review
That wasn't the right patch :-/.
Attachment #289171 - Attachment is obsolete: true
Attachment #289172 - Flags: superreview?(bzbarsky)
Attachment #289172 - Flags: review?(bzbarsky)
Attachment #289171 - Flags: superreview?(bzbarsky)
Attachment #289171 - Flags: review?(bzbarsky)
Comment on attachment 289172 [details] [diff] [review]
v1.2

Looks reasonable.  Do we want to also call Terminate() if we get back STOPPARSING?
Attachment #289172 - Flags: superreview?(bzbarsky)
Attachment #289172 - Flags: superreview+
Attachment #289172 - Flags: review?(bzbarsky)
Attachment #289172 - Flags: review+
(In reply to comment #36)
> (From update of attachment 289172 [details] [diff] [review])
> Looks reasonable.  Do we want to also call Terminate() if we get back
> STOPPARSING?

nsParser calls Terminate if it gets back STOPPARSING from ConsumeToken, so I don't think there's a need to do it in nsExpatDriver.

Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Ah, ok.  Very good!
Depends on: 396226
Flags: in-testsuite?
Depends on: 404419
Depends on: 418391
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: