Closed Bug 222468 Opened 21 years ago Closed 21 years ago

Creating a mail filter causes Mozilla to crash [@ nsLayoutUtils::CompareTreePosition]

Categories

(MailNews Core :: Filters, defect, P1)

defect

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: pkwarren, Assigned: roc)

References

Details

(Keywords: crash, topcrash)

Crash Data

Attachments

(4 files)

Steps to reproduce:
1) Create a mail account.
2) Go to Tools->Message Filters.
3) Click "New..." button.

Mozilla crashes at this point on AIX and Linux. I have not had time to test a
Windows build yet.
Attached file Stack trace
This is a stack trace from a non-optimized, non-debug build. I don't have a
debug build handy so unfortunately there are no line numbers listed.
The stack trace seems to point to the checkin for Bug 217604 as the cause of
this problem.
This is not occuring on a build compiled on the morning of 2003/10/14. This is
occuring in yesterday's build.
this bug also seems to cause Bug 220629 and Bug 221676 (same stacktraces)
Summary: Creating a mail filter causes Mozilla to crash → Creating a mail filter causes Mozilla to crash [@ nsLayoutUtils::CompareTreePosition]
Mine, for sure
Assignee: sspitzer → roc
Priority: -- → P1
So I caught this in a debugger.  The crash happens because when we call

CompareTreePosition(aFrame->GetContent(), f->GetContent(), parentViewContent)

in nsLayoutUtils::FindSiblingViewFor, parentViewContent is in fact no an
ancestor of aFrame->GetContent().  At this point, aFrame is a nsMenuFrame

The ancestors of aFrame look like this:

nsMenuFrame < nsDeckFrame < nsBoxFrame < nsListItemFrame < nsListBoxBodyFrame

The problem pops up with nsListItemFrame...

(gdb) whats $foo
0x41948ba8 <_ZTV15nsListItemFrame+8>:   0x41452d3c
<_ZN15nsListItemFrame14QueryInterfaceERK4nsIDPPv>
(gdb) p $foo->GetContent()->GetParent()
$35 = (nsIContent *) 0x89e0210
(gdb) p $foo->GetParent()->GetContent()
$36 = (nsIContent *) 0x8a078e8

$foo->GetContent() is a "listitem"; it's parent is a "listbox".

$foo->GetParent()->GetContent() is a "listboxbody".  The "listbox" is the
content node for a frame ancestor of $foo much higher up in the frame hierarchy
(there are some frames that point to "listboxbody" and "listrows" in between). 
The problem is that the ListBoxBodyFrame is the ancestor with a view, so
aCommonAncestor is the "listboxbody", which is not an ancestor of the "listitem"
at all....
Blocks: 220629, 221676
Priority: P1 → --
OS: AIX → All
Priority: -- → P1
Hardware: Other → All
Attached file Debug stack trace
It sounds like the situation is already well understood, but I do have a stack
trace from a debug build available now so I figured I'd go ahead and post it.
The best thing to do is to make CompareTreePosition use aCommonAncestor as a
hint. If it turns out it's not an ancestor of aContent1 or aContent2, we can
just retry the function with aCommonAncestor == nsnull, which will always work.
I'll cook up a patch for this tonight.
IIRC, there's code somewhere that uses |aCommonAncestor| to prevent walking of
the top (i.e., as the null check for when we get to the root) and will walk off
the top and try to dereference content nodes if it's not actually an ancestor.
Attached patch fixSplinter Review
This should do the trick nicely.
Attachment #133470 - Flags: superreview?(bzbarsky)
Attachment #133470 - Flags: review?(bzbarsky)
Comment on attachment 133470 [details] [diff] [review]
fix

>+  for (c1 = aContent1; c1 && c1 != aCommonAncestor; c1 = c1->GetParent()) {
>     content1Ancestors.AppendElement(c);

s/c/c1/ in the AppendElement call?

>+  for (c2 = aContent2; c2 && c2 != aCommonAncestor; c2 = c2->GetParent()) {
>     content2Ancestors.AppendElement(c);

s/c/c2/

Looks good to me once it compiles, so r+sr=me, but please do build and test
this patch before landing it...
Attachment #133470 - Flags: superreview?(bzbarsky)
Attachment #133470 - Flags: superreview+
Attachment #133470 - Flags: review?(bzbarsky)
Attachment #133470 - Flags: review+
I built and tested the patch, and it fixes the crash. I checked in.
fixed, i tested this with a cvs trunk build, mail filter behave as usual, no
crash when clicking the New... Button (the deps of this bug were also fixed with
this, tested that)
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
verified with
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6a) Gecko/20031018
Status: RESOLVED → VERIFIED
Keywords: crash, topcrash
*** Bug 223527 has been marked as a duplicate of this bug. ***
Product: MailNews → Core
Product: Core → MailNews Core
Crash Signature: [@ nsLayoutUtils::CompareTreePosition]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: