Closed
Bug 331040
Opened 19 years ago
Closed 19 years ago
Crash when removing parent iframe in onbeforunload handler
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
VERIFIED
FIXED
People
(Reporter: martijn.martijn, Assigned: feng.qian.moz)
References
Details
(5 keywords)
Attachments
(4 files, 3 obsolete files)
(deleted),
text/html
|
Details | |
(deleted),
text/plain
|
Details | |
(deleted),
text/html
|
Details | |
(deleted),
patch
|
bryner
:
review+
bzbarsky
:
superreview+
darin.moz
:
approval-branch-1.8.1+
dveditz
:
approval1.8.0.4+
|
Details | Diff | Splinter Review |
See upcoming testcase which crashes current Mozilla trunk build.
Doesn't crash in 2005-08-11 build, crashes in 2005-08-13 build. I think a regression from bug 296639.
Also crashes in Firefox1.5.0.1.
Reporter | ||
Comment 1•19 years ago
|
||
The testcase crashes on load for me.
Talkback ID: TB16568299Y
Reporter | ||
Comment 2•19 years ago
|
||
Reporter | ||
Comment 3•19 years ago
|
||
I guess this is more or less the same issue (it has the same regression range).
I'm being redirected to google with this testcase, which should not happen. You need to allow popup windows.
Basically the source of the opened window consists of this:
<script>
window.onbeforeunload=function() {window.close();}
window.location="http://google.com";
</script>
Updated•19 years ago
|
Flags: blocking1.8.1+
Flags: blocking1.8.0.3?
Comment 4•19 years ago
|
||
Does it help to hold a kungfudeathgrip to |this| through the PermitUnload method? It's not quite clear to me why we didn't have that all alongl we should have....
Updated•19 years ago
|
Flags: blocking1.8.0.3? → blocking1.8.0.3+
Assignee | ||
Comment 5•19 years ago
|
||
Attachment #216860 -
Flags: review?
Updated•19 years ago
|
Attachment #216860 -
Flags: superreview?(bzbarsky)
Attachment #216860 -
Flags: review?(bryner)
Attachment #216860 -
Flags: review?
Comment 7•19 years ago
|
||
Comment on attachment 216860 [details] [diff] [review]
patch
>Index: nsDocShell.cpp
>===================================================================
>RCS file: /cvsroot/mozilla/docshell/base/nsDocShell.cpp,v
>retrieving revision 1.782
>diff -u -u -8 -p -r1.782 nsDocShell.cpp
>--- nsDocShell.cpp 24 Mar 2006 19:38:16 -0000 1.782
>+++ nsDocShell.cpp 31 Mar 2006 20:11:51 -0000
>@@ -6478,16 +6478,21 @@ nsDocShell::InternalLoad(nsIURI * aURI,
> if (shEntry)
> shEntry->SetTitle(mTitle);
> }
>
> return NS_OK;
> }
> }
>
>+ // mContentViewer->PermitUnload can destroy |this| docShell, which
>+ // causes the next call of CanSavePresentation to crash. Temporarily
>+ // hold |this| to prevent crash happen. (bug#331040)
>+ nsCOMPtr<nsIDocShell> holder(NS_STATIC_CAST(nsIDocShell*, this));
>+
So actually I told you wrong, you don't need the NS_STATIC_CAST here, just write:
nsCOMPtr<nsIDocShell> holder(this);
then fix up the second sentence of the comment a bit, maybe "Hold onto |this| until we return, to prevent a crash from happening."
r=me with that change.
Attachment #216860 -
Flags: review?(bryner) → review+
Comment 8•19 years ago
|
||
I should be able to get to this on Sunday. I still think that we might need a better kungFuDeathGrip in nsDocumentViewer as well, but I'll check on that.
Assignee | ||
Comment 9•19 years ago
|
||
Attachment #216881 -
Flags: review?
Assignee | ||
Updated•19 years ago
|
Attachment #216860 -
Attachment is obsolete: true
Attachment #216860 -
Flags: superreview?(bzbarsky)
Assignee | ||
Updated•19 years ago
|
Attachment #216881 -
Flags: review? → review?(bryner)
Updated•19 years ago
|
Attachment #216881 -
Flags: review?(bryner) → review+
Updated•19 years ago
|
Attachment #216881 -
Flags: superreview?(bzbarsky)
Comment 10•19 years ago
|
||
Comment on attachment 216881 [details] [diff] [review]
revised patch
This is necessary, but not sufficient. For example, the stack Martijn posted shows him crashing inside DocumentViewerImpl::PermitUnload where we have an existing kungFuDeathGrip that doesn't extend to cover all member access after possible destruction... Adding the death grip in docshell may or may not help with that crash; better to fix both spots.
Also, I think we generally name stack nsCOMPtrs that are supposed to keep |this| alive kungFuDeathGrip (just so it's clear what they're doing).
That will fix the crashes. We probably want to have a followup bug (or also roll it into this patch?) on the fact that the load happens in totally the wrong window here. I suspect the right thing will at least require that nsDSURIContentListener::OnStartURIOpen abort if mDocShell is null. I think that should be enough, since destroying a docshell will cancel any existing in-progress loads...
Attachment #216881 -
Flags: superreview?(bzbarsky) → superreview-
Assignee | ||
Comment 11•19 years ago
|
||
Hold back my previous patch, I only reproduced the crash and fixed it on Linux. Now I reproduced the crash on Windows, and see the same backtrace as Martijn's, it is clearly different from Linux.
(In reply to comment #10)
> (From update of attachment 216881 [details] [diff] [review] [edit])
> This is necessary, but not sufficient. For example, the stack Martijn posted
> shows him crashing inside DocumentViewerImpl::PermitUnload where we have an
> existing kungFuDeathGrip that doesn't extend to cover all member access after
> possible destruction... Adding the death grip in docshell may or may not help
> with that crash; better to fix both spots.
>
> Also, I think we generally name stack nsCOMPtrs that are supposed to keep
> |this| alive kungFuDeathGrip (just so it's clear what they're doing).
>
> That will fix the crashes. We probably want to have a followup bug (or also
> roll it into this patch?) on the fact that the load happens in totally the
> wrong window here. I suspect the right thing will at least require that
> nsDSURIContentListener::OnStartURIOpen abort if mDocShell is null. I think
> that should be enough, since destroying a docshell will cancel any existing
> in-progress loads...
>
Assignee | ||
Comment 12•19 years ago
|
||
On Linux, Firefox is able to finish PermitUnload, crashes in CanSavePresentation. Its behavior is slightly different from Windows.
I am not familiar with nsDSURIContentListener::OnStartURIOpen, probably it is better to open another bug.
The nsDocShell::CreateAboutBlankContentViewer() method has a similar pattern of calling mContentViewer->PermitUnload as in nsDocShell::InternalLoad, it might be possible to crash Firefox. But Brain and I didn't come up with a test case to verify that.
Attachment #216881 -
Attachment is obsolete: true
Attachment #217227 -
Flags: superreview?(bzbarsky)
Attachment #217227 -
Flags: review?
Assignee | ||
Updated•19 years ago
|
Attachment #217227 -
Flags: review? → review?(bryner)
Comment 13•19 years ago
|
||
I'd add the kungFuDeathGrip in CreateAboutBlankContentViewer, just to be safe...
Assignee | ||
Comment 14•19 years ago
|
||
Added kungFuDeathGrip(this) in CreateAboutBlankContentViewer.
Attachment #217227 -
Attachment is obsolete: true
Attachment #217305 -
Flags: superreview?(bzbarsky)
Attachment #217305 -
Flags: review?
Attachment #217227 -
Flags: superreview?(bzbarsky)
Attachment #217227 -
Flags: review?(bryner)
Assignee | ||
Updated•19 years ago
|
Attachment #217305 -
Flags: review? → review?(bryner)
Comment 15•19 years ago
|
||
Comment on attachment 217305 [details] [diff] [review]
revised patch (3)
Seems reasonable. Please make sure to file a followup bug on the loads happening in the wrong window -- that's a major problem that we might want to fix on branches too....
Attachment #217305 -
Flags: superreview?(bzbarsky) → superreview+
Updated•19 years ago
|
Attachment #217305 -
Flags: review?(bryner) → review+
Assignee | ||
Comment 16•19 years ago
|
||
(In reply to comment #15)
> (From update of attachment 217305 [details] [diff] [review] [edit])
> Seems reasonable. Please make sure to file a followup bug on the loads
> happening in the wrong window -- that's a major problem that we might want to
> fix on branches too....
>
Who can kindly help me commit the patch, I don't have cvs write access.
Boris, can you file the followup bug with some descriptions? I am new and not sure if I fully understood the problem.
Reporter | ||
Comment 17•19 years ago
|
||
(In reply to comment #16)
> Boris, can you file the followup bug with some descriptions? I am new and not
> sure if I fully understood the problem.
I think Boris meant the issue I described in comment 3, I filed bug 332901 for that.
I can check the patch in as soon as I'm finished building.
Reporter | ||
Comment 18•19 years ago
|
||
Checking in docshell/base/nsDocShell.cpp;
/cvsroot/mozilla/docshell/base/nsDocShell.cpp,v <-- nsDocShell.cpp
new revision: 1.785; previous revision: 1.784
done
Checking in layout/base/nsDocumentViewer.cpp;
/cvsroot/mozilla/layout/base/nsDocumentViewer.cpp,v <-- nsDocumentViewer.cpp
new revision: 1.478; previous revision: 1.477
done
Checked into trunk.
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Comment 19•19 years ago
|
||
Comment on attachment 217305 [details] [diff] [review]
revised patch (3)
I think we want this for FF2 as well. This should also be considered for FF 1.5.0.3.
Attachment #217305 -
Flags: approval1.8.0.3?
Attachment #217305 -
Flags: approval-branch-1.8.1+
Verified FIXED using build 2006-04-06-09 on SeaMonkey trunk using Windows XP. No crash for either testcase, and with popups enabled, the 2nd testcase didn't redirect to http://www.google.com
Status: RESOLVED → VERIFIED
Comment 22•19 years ago
|
||
Comment on attachment 217305 [details] [diff] [review]
revised patch (3)
approved for 1.8.0 branch, a=dveditz for drivers
Attachment #217305 -
Flags: approval1.8.0.3? → approval1.8.0.3+
Assignee | ||
Comment 23•19 years ago
|
||
Dan,
I have not write permission to CVS tree yet, can you or Martjin Wargers help me check in the patch to 1.8.0.3?
Thanks,
Feng
(In reply to comment #18)
> Checking in docshell/base/nsDocShell.cpp;
> /cvsroot/mozilla/docshell/base/nsDocShell.cpp,v <-- nsDocShell.cpp
> new revision: 1.785; previous revision: 1.784
> done
> Checking in layout/base/nsDocumentViewer.cpp;
> /cvsroot/mozilla/layout/base/nsDocumentViewer.cpp,v <-- nsDocumentViewer.cpp
> new revision: 1.478; previous revision: 1.477
> done
>
> Checked into trunk.
>
(In reply to comment #22)
> (From update of attachment 217305 [details] [diff] [review] [edit])
> approved for 1.8.0 branch, a=dveditz for drivers
>
Reporter | ||
Comment 24•19 years ago
|
||
(In reply to comment #23)
> I have not write permission to CVS tree yet, can you or Martjin Wargers help me
> check in the patch to 1.8.0.3?
Sorry, I don't have a 1.8.0.3 tree.
Comment 25•19 years ago
|
||
Checked in on the 1.8.0 branch.
mozilla/layout/base/nsDocumentViewer.cpp 1.442.4.7.2.1
mozilla/docshell/base/nsDocShell.cpp 1.719.2.21.2.6
Keywords: fixed1.8.0.4
Comment 26•19 years ago
|
||
this is not fixed in Firefox 1.5.0.4rc3 builds. The second testcase redirects to google.
Keywords: fixed1.8.0.4
Comment 27•19 years ago
|
||
Tracy, the redirect to google issue is bug 332901, not this bug. Please see comment 17.
This bug is just about the crash, like the summary says.
Keywords: fixed1.8.0.4
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•