Closed Bug 321781 Opened 19 years ago Closed 19 years ago

###!!! ASSERTION: More UnblockOnload() calls than BlockOnload() calls; dropping call: 'Not Reached', file d:/mozbuild1/mozilla/content/base/src/nsDocument.cpp, line 5188

Categories

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

defect

Tracking

()

RESOLVED FIXED
mozilla1.9alpha1

People

(Reporter: mrbkap, Assigned: mrbkap)

References

()

Details

(Keywords: assertion, Whiteboard: [patch])

Attachments

(9 files, 4 obsolete files)

24 bytes, text/javascript
Details
109 bytes, text/javascript
Details
173 bytes, text/javascript
Details
342 bytes, text/html
Details
24 bytes, text/html
Details
114 bytes, text/html
Details
161 bytes, text/html
Details
312 bytes, text/html
Details
31.88 KB, patch
mrbkap
: review+
mrbkap
: superreview+
Details | Diff | Splinter Review
STEPS TO REPRODUCE: *) Go to the URL in the URL field in a build with e4x enabled. *) Click on link 0 and the "test" button. ACTUAL RESULTS: We assert. EXPECTED RESULTS: No assertion.
Between Christmas and New Year's i started seeing this same assertion when I try to load messages in the mail message pane. Every time I click on a message, I get ###!!! ASSERTION: More UnblockOnload() calls than BlockOnload() calls; dropping call: 'Not Reached', file d:/mozbuild1/mozilla/content/base/src/nsDocument.cpp, line 5188 and the message fails to load. Given the date Blake filed this bug, it could be caused by the same thing.
stack trace leading up to the assertion: nsDocument::UnblockOnload(int 1) line 5189 nsDocument::EndLoad() line 2246 nsHTMLDocument::EndLoad() line 1021 nsHTMLDocument::DocumentWriteTerminationFunc(nsISupports * 0x04e7b258) line 974 nsJSContext::ScriptEvaluated(int 1) line 2054 + 17 bytes nsJSContext::CallEventHandler(JSObject * 0x03de5aa8, JSObject * 0x03fd2860, unsigned int 1, long * 0x0012d24c, long * 0x0012d248) line 1456 nsJSEventListener::HandleEvent(nsJSEventListener * const 0x0370f5b0, nsIDOMEvent * 0x04e8f530) line 186 + 54 bytes nsEventListenerManager::HandleEventSubType(nsListenerStruct * 0x0370f680, nsIDOMEventListener * 0x0370f5b0, nsIDOMEvent * 0x04e8f530, nsIDOMEventTarget * 0x04e73f10, unsigned int 8, unsigned int 7) line 1684 + 16 bytes nsEventListenerManager::HandleEvent(nsEventListenerManager * const 0x0370f268, nsPresContext * 0x034df8b0, nsEvent * 0x0012d6b0, nsIDOMEvent * * 0x0012d654, nsIDOMEventTarget * 0x04e73f10, unsigned int 7, nsEventStatus * 0x0012d6d0) line 1791 nsXULElement::HandleDOMEvent(nsPresContext * 0x034df8b0, nsEvent * 0x0012d6b0, nsIDOMEvent * * 0x0012d654, unsigned int 7, nsEventStatus * 0x0012d6d0) line 1865 nsTreeSelection::FireOnSelectHandler() line 789 nsTreeSelection::Select(nsTreeSelection * const 0x04320b18, int 46) line 378
Scott, you're probably (thought not certainly) seeing a different issue. It's worth tracking in a separate bug, possibly depending on this one...
This seems to be fallout from bug 319123 -- we're calling EndLoad twice from document.close -- once from Parse() and once from Terminate. So we set the termination func twice, and then call EndLoad() for real twice. The second call is what asserts.
Assignee: general → mrbkap
Blocks: 319123
Blocks: 321782
I think it's worth thinking about how to fix both this and bug 321782 at once.... They seem pretty related.
Status: NEW → ASSIGNED
OS: Windows XP → All
Priority: -- → P2
Hardware: PC → All
Target Milestone: --- → mozilla1.9alpha
Attached patch Possible fix (obsolete) — Splinter Review
This basically backs out the change from bug 319123 in favor of a different fix for the leak. This fix is basically to inform the parser that the root context (the one that wrote out the external script) is really the final context and ensures that we call DidBuildModel after we're done parsing that context. The only scary part of this patch is that if we ever use the wrong parser key (somehow executing the same script element, nested in itself), then we'll do the wrong thing and misplace the document.written text. Perhaps we should move key generation onto the parser or have |NS_IMETHOD_(void *) EnsureUniqueKey(void *aBaseKey)| to avoid this problem?
Attachment #207750 - Flags: review?(jst)
Comment on attachment 207750 [details] [diff] [review] Possible fix >- ResumeParse(PR_FALSE, PR_FALSE, PR_FALSE); >+ >+ if (pc == mParserContext) { >+ ResumeParse(PR_FALSE, PR_FALSE, PR_FALSE); >+ } Note to self: Add a comment that if pc != mParserContext, then pc is not the active context and ResumeParse will do the wrong thing.
Attached patch Revised potential fix (obsolete) — Splinter Review
The first fix was missing two mParserContext->pc fixes in Parse. This fixes that and also remembers to include nsParser.h in the diff.
Attachment #207750 - Attachment is obsolete: true
Attachment #208003 - Flags: review?(jst)
Attachment #207750 - Flags: review?(jst)
Blocks: 319713
Attached patch More fixed fix (obsolete) — Splinter Review
This needs to be tested pretty hard. I took this opportunity to rename mIsWriting and added a large comment explaining it. I'll attach the testcase that I'm using as a stress test in a sec.
Attachment #208003 - Attachment is obsolete: true
Attachment #208142 - Flags: superreview?(jst)
Attachment #208142 - Flags: review?(bugmail)
Attachment #208003 - Flags: review?(jst)
Attached file stress test
Whiteboard: [patch]
Comment on attachment 208142 [details] [diff] [review] More fixed fix This breaks calling document.write() to create a "new" document after document.close() has been called to terminate an earlier document.write() that created a "new" document. sr-
Attachment #208142 - Flags: superreview?(jst) → superreview-
Attached patch Closer... (obsolete) — Splinter Review
This patch fixes jst's concern, but sicking came up with another problem that I don't think we got right even before my patch. Hoping he'll attach a testcase. Note: I need to study my patch a bit more to make sure I fully understand why and how it works.
Attachment #208142 - Attachment is obsolete: true
Attachment #208302 - Flags: superreview?(jst)
Attachment #208302 - Flags: review?(bugmail)
Attached file testcase2
So with above patch, what do we do for this testcase where the document.close() is called from an asynchronously loaded script?
With my patch, I see "one two" and the throbber stops spinning.
Comment on attachment 208302 [details] [diff] [review] Closer... >Index: content/html/document/src/nsHTMLDocument.h >+ // mWriteState tracks the status of this document if the document is being >+ // entirely created by script. In the normal load case, mWriteState will be >+ // eNotWriting. Once document.open has been called (either implicitly or >+ // explicitly), mWriteState will be eDocumentOpened. When document.close has >+ // been called, mWriteState will become eDocumentClosed, indicating that we Shouldn't that be "mWriteState will become ePendingClose". And please write when we transition into eDocumentClosed. >+ // might still be writing, but that we shouldn't process any further close() >+ // calls. >+ enum WritingState { eNotWriting, eDocumentOpened, ePendingClose, eDocumentClosed }; >+ WritingState mWriteState; You could make this enum { ... } mWriteState; >Index: content/html/document/src/nsHTMLContentSink.cpp >+HTMLContentSink::PreEvaluateScript(nsIScriptElement *aElement) > { This argument seems unused, nuke it. r=me if you don't make any more changes to document.write.... ever!
Attachment #208302 - Flags: review?(bugmail) → review+
Comment on attachment 208302 [details] [diff] [review] Closer... sr=jst
Attachment #208302 - Flags: superreview?(jst) → superreview+
Attached patch Final patchSplinter Review
This is the final patch I'm about to check in. The only substantive change is that I call mPendingScripts.RemoveElement(GenerateParserKey()) in nsHTMLDocument::Close now, so subsequent writes from that script will reset the document.
Attachment #208302 - Attachment is obsolete: true
Attachment #209416 - Flags: superreview+
Attachment #209416 - Flags: review+
Fix checked into trunk.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Depends on: 341551
Flags: in-testsuite?
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: