Summary: | Crash in PageBanner::detachFromPage() when called from ~WebPage() | ||||||
---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Ada Chan <adachan> | ||||
Component: | Layout and Rendering | Assignee: | Ada Chan <adachan> | ||||
Status: | RESOLVED FIXED | ||||||
Severity: | Normal | CC: | bdakin, sam | ||||
Priority: | P2 | ||||||
Version: | 528+ (Nightly build) | ||||||
Hardware: | Unspecified | ||||||
OS: | Unspecified | ||||||
Attachments: |
|
Description
Ada Chan
2013-07-01 17:39:13 PDT
I think it would be just slightly better to return early in this function if there is no WebPage. Something like: void PageBanner::detachFromPage() { // Comment about how it is possible that the banner has already detached from the page by explicitly being set to null. if (!m_webPage) return; // We can hide the banner by removing the parent layer that hosts it. if ( m_webPage->corePage()) { if (m_type == Header) m_webPage->corePage()->addHeaderWithHeight(0); else if (m_type == Footer) m_webPage->corePage()->addFooterWithHeight(0); } m_type = NotSet; m_webPage = 0; } (In reply to comment #1) > I think it would be just slightly better to return early in this function if there is no WebPage. Something like: > > void PageBanner::detachFromPage() > { > // Comment about how it is possible that the banner has already detached from the page by explicitly being set to null. I'm actually not sure how it is possible that we get into the situation where m_webPage is 0. In the case of this crash, m_webPage is non-null, but m_webPage->corePage() is because by the time ~WebPage() is called, WebPage::close() has been called and WebPage::m_page has been set to null. > if (!m_webPage) > return; > > // We can hide the banner by removing the parent layer that hosts it. > if ( m_webPage->corePage()) { > if (m_type == Header) > m_webPage->corePage()->addHeaderWithHeight(0); > else if (m_type == Footer) > m_webPage->corePage()->addFooterWithHeight(0); > } > > m_type = NotSet; > m_webPage = 0; > } Created attachment 205857 [details]
Patch
Comment on attachment 205857 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=205857&action=review > Source/WebKit2/WebProcess/WebPage/mac/PageBannerMac.mm:84 > + if (!m_webPage) I think we should make this: if (!m_webPage || !m_webPage->corePage()) return; And you can put your comment up there too. Comment on attachment 205857 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=205857&action=review >> Source/WebKit2/WebProcess/WebPage/mac/PageBannerMac.mm:84 >> + if (!m_webPage) > > I think we should make this: > > if (!m_webPage || !m_webPage->corePage()) > return; > > And you can put your comment up there too. But don’t we want to set m_type to NotSet and m_webPage to 0 even if m_webPage->corePage() is 0? (In reply to comment #5) > (From update of attachment 205857 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=205857&action=review > > >> Source/WebKit2/WebProcess/WebPage/mac/PageBannerMac.mm:84 > >> + if (!m_webPage) > > > > I think we should make this: > > > > if (!m_webPage || !m_webPage->corePage()) > > return; > > > > And you can put your comment up there too. > > But don’t we want to set m_type to NotSet and m_webPage to 0 even if m_webPage->corePage() is 0? Oh right. Yes. I forgot that my theory that this was happening because PageBanner::detachFromPage() had already been called was false. In this case, I think your patch is fine as-is, Ada. Thanks Beth and Darin for your comments! Committed: https://trac.webkit.org/changeset/152316 |