Closed
Bug 75305
Opened 24 years ago
Closed 24 years ago
Doing Undo and Redo crashes browser
Categories
(Core :: DOM: Editor, defect, P1)
Tracking
()
VERIFIED
FIXED
mozilla0.9.1
People
(Reporter: shrir, Assigned: kinmoz)
Details
(Keywords: crash, Whiteboard: waiting for tree to check in fix)
Attachments
(5 files)
seen on windows 0409...very unstable today..
Steps:
Launch composer
Open the attachment
Highlight (left to right) with mouse..the contents of a row and press CTRL + X
Observe that the row becomes empty
Now, do Edit|Undo and immediately after that,do Edit|Redo
BOOM ! Crashes...
| Reporter | ||
Comment 1•24 years ago
|
||
| Reporter | ||
Comment 2•24 years ago
|
||
windoze(NT) only...linux and mac are fine
| Reporter | ||
Comment 3•24 years ago
|
||
cc: kin
| Reporter | ||
Comment 4•24 years ago
|
||
happens in my 04/05 build too
I just attatched a stack trace that shows that it's crashing in layout while
painting a text frame (nsTextFrame::PaintAsciiText()). Somehow
the content node's text fragment and it's frame's mContentLength are out of
sync. The text fragment contains no text (null pointer) and mContentLength is
greater than zero so they are indexing into a null pointer. Here's the code
snippet that's causing the crash:
// See if the text ends in a newline
if ((textLength > 0) && (text[textLength - 1] == '\n')) {
| Assignee | ||
Comment 10•24 years ago
|
||
I just attatched a file containing some stack traces that may be helpful in
understanding why we crash.
The root of the crash is what I believe to be a race condition between the
processing of Reflow and Paint events generated by layout methods.
The only real difference between the original "Cut" operation and the "Redo" of
the cut operation is the fact that we call nsEditor::BeginUpdateViewBatch() and
nsEditor::EndUpdateViewBatch() during the original "Cut".
Begin/EndUpdateViewBatch() are editor convenience routines that turn Selection,
ViewManager, and Reflow batching on/off. The idea is that we want to prevent the
user from seeing all the intermediate steps/edits neccessary to accomplish what
they asked us to do.
It's also important to note that closing ViewManager update and Layout Reflow
batches, force synchronous processing of pending events, so the editor uses this
fact to ensure that reflows always happen before any view updates.
In the "Redo" case, we don't call BeginUpdateViewBatch(), so an async reflow
request is posted as the result of our inserting/removing of nodes from the DOM
tree, also, the manipulation of selection during these operations and the
removal of text nodes from the DOM tree trigger frame Invalidations that send
async Paint requests.
When we return to the event loop we will now either process the reflow request
(PLEvent) or process the pending PAINT event sitting in the native event queue.
If the PAINT event is processed first (as is for this bug) we crash because the
frame tree is in a state that is out of sync with the content tree, because a
reflow did not happen to sync things up.
Having said all this, it's pretty easy to fix this particular bug by wrapping
both Undo() and Redo() calls in the editor with Begin/EndUpdateViewBatch(). My
concern is that this bug could probably be reproduced by mimic'ing what the
editor does with DOM calls from JS ... so I think it is still worth the time
from some people in layout to look into this race condition.
Status: NEW → ASSIGNED
Priority: -- → P1
| Assignee | ||
Comment 11•24 years ago
|
||
Comment 12•24 years ago
|
||
this patch looks good. it smells good. it trastes good.
mmmmmmmmmm, patch.
r=jfrancis
Comment 13•24 years ago
|
||
| Assignee | ||
Comment 14•24 years ago
|
||
I'll bet money that both those bugs Daniel mentioned are due to the same race
condition. Perhaps we should reopen those bugs and point them to the steps in
this bug since it's quite easy to reproduce.
| Assignee | ||
Comment 15•24 years ago
|
||
I just attatched an HTML file to bug 73291 that uses JS and DOM calls to
recreate the crash we see here.
http://bugzilla.mozilla.org/showattachment.cgi?attach_id=31505
Comment 16•24 years ago
|
||
So this is our Bandaid for the crash, right? Do we have open bugs to get the
layout guys to fix this the real way?
nsAutoUpdateViewBatch: it might be better to assert that you have an editor in
the ctor, rather than the 2 if checks, since, if you have one in the ctor, mEd
will always be non-null in the dtor (tho it could be a bad pointer).
| Assignee | ||
Comment 17•24 years ago
|
||
Bug 73291 covers the real problem. It also has a JS test case that I whipped up
to demonstrate that this isn't an editor specific problem.
In regards to your ASSERTION comment, I can add one, but I still need to leave
the 2 'if' statements in to ensure we don't try to call through a bad pointer.
:-)
Comment 18•24 years ago
|
||
kin: i think having a non-null nsEditor needs to be guaranteed by the caller
(who, it seems, often pass 'this'). This is not an interface class.
Updated•24 years ago
|
Whiteboard: FIX IN HAND → waiting for tree to check in fix
| Assignee | ||
Comment 19•24 years ago
|
||
Fix checked into trunk:
mozilla/editor/base/nsPlaintextEditor.cpp revision 1.10
mozilla/editor/base/nsEditorUtils.h revision 1.17
Should appear in QA builds after 8am today.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Comment 20•24 years ago
|
||
Shrir, is this fixed for you now?
| Reporter | ||
Comment 21•24 years ago
|
||
Oh yeah, this is fixed on 0529 trunk. VERIFIED
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•