<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>30839</bug_id>
          
          <creation_ts>2009-10-27 15:51:13 -0700</creation_ts>
          <short_desc>REGRESSION: crashes in WebCore::RedirectScheduler::timerFired(WebCore::Timer&lt;WebCore::RedirectScheduler&gt;*)</short_desc>
          <delta_ts>2009-10-28 17:22:27 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Page Loading</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://www.linkinpark.it/forum/index.php</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Simon Fraser (smfr)">simon.fraser</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>abarth</cc>
    
    <cc>beidson</cc>
    
    <cc>commit-queue</cc>
    
    <cc>darin</cc>
    
    <cc>hybrid.one</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>158398</commentid>
    <comment_count>0</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2009-10-27 15:51:13 -0700</bug_when>
    <thetext>Nameless on #webkit is reporting crashes here:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000092
Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   com.apple.WebCore                     0x0000000100dc289a WebCore::RedirectScheduler::timerFired(WebCore::Timer&lt;WebCore::RedirectScheduler&gt;*) + 42
1   com.apple.WebCore                     0x0000000100fc6767 WebCore::ThreadTimers::sharedTimerFiredInternal() + 151
2   com.apple.WebCore                     0x0000000100ed9e05 WebCore::timerFired(__CFRunLoopTimer*, void*) + 53
3   com.apple.CoreFoundation              0x00007fff85003a78 __CFRunLoopRun + 5480
4   com.apple.CoreFoundation              0x00007fff8500203f CFRunLoopRunSpecific + 575
5   com.apple.HIToolbox                   0x00007fff837ffc4e RunCurrentEventLoopInMode + 333
6   com.apple.HIToolbox                   0x00007fff837ffa53 ReceiveNextEventCommon + 310
7   com.apple.HIToolbox                   0x00007fff837ff90c BlockUntilNextEventMatchingListInMode + 59
8   com.apple.AppKit                      0x00007fff82804520 _DPSNextEvent + 718
9   com.apple.AppKit                      0x00007fff82803e89 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 155
10  com.apple.Safari                      0x000000010000bcf0 0x100000000 + 48368
11  com.apple.AppKit                      0x00007fff827c9a7d -[NSApplication run] + 395
12  com.apple.AppKit                      0x00007fff827c2798 NSApplicationMain + 364
13  com.apple.Safari                      0x0000000100001d0c 0x100000000 + 7436

(s)he says it happens at http://www.linkinpark.it/forum/index.php, in various places in those fora.

Regression from bug 30424?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>158400</commentid>
    <comment_count>1</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2009-10-27 15:52:49 -0700</bug_when>
    <thetext>It&apos;s not clear that bug 30424 affected this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>158401</commentid>
    <comment_count>2</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2009-10-27 15:53:41 -0700</bug_when>
    <thetext>Probably not a regression from https://bugs.webkit.org/show_bug.cgi?id=30424 - we&apos;ve had this crash in radar pretty much since Adam added the redirect scheduler.

(see &lt;rdar://problem/7313414&gt;)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>158404</commentid>
    <comment_count>3</comment_count>
    <who name="Nameless">hybrid.one</who>
    <bug_when>2009-10-27 16:04:04 -0700</bug_when>
    <thetext>I am running Version 4.0.3 (6531.9, r50124)
I&apos;ve updated the browser 3 times, but the problem persists.
The Segmentation Fault happens when browsing the phpbb3 forum, but it&apos;s general.
Sometimes happens when i&apos;m only browsing, others when i&apos;m replying to a post.
I don&apos;t really know</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>158406</commentid>
    <comment_count>4</comment_count>
    <who name="Nameless">hybrid.one</who>
    <bug_when>2009-10-27 16:08:54 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; I am running Version 4.0.3 (6531.9, r50124)
&gt; I&apos;ve updated the browser 3 times, but the problem persists.
&gt; The Segmentation Fault happens when browsing the phpbb3 forum, but it&apos;s
&gt; general.
&gt; Sometimes happens when i&apos;m only browsing, others when i&apos;m replying to a post.
&gt; I don&apos;t really know

Oh i forgot. i&apos;m running Snow Leopard</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>158416</commentid>
    <comment_count>5</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2009-10-27 16:51:14 -0700</bug_when>
    <thetext>I&apos;m on a debug build of r50166 and I simply can&apos;t reproduce this.

I haven&apos;t tried replying to a comment yet, but according to the reporter that doesn&apos;t actually reliably reproduce it for him, either.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>158432</commentid>
    <comment_count>6</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2009-10-27 17:28:11 -0700</bug_when>
    <thetext>The invalid address at 0x92 indicates we’re dereferencing a null pointer with an offset of 0x92. And defersLoading is at an offset of 0x92. So I’m pretty sure this crash means that RedirectScheduler::timerFired is being called when m_frame-&gt;page() is 0.

One thing we can do about this right away is to add a return statement for cases where page is 0 after the assertion. Then we can still look for this bug in debug builds, but possible render it harmless in release builds.

Another thing we can do is do the thought experiment about how m_frame-&gt;page() could become zero without telling the RedirectScheduler to stop its timer.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>158435</commentid>
    <comment_count>7</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2009-10-27 17:41:14 -0700</bug_when>
    <thetext>I see nothing that would guarantee that RedirectScheduleer::clear() is called on the frames in a page when a page is destroyed.

The Frame::pageDestroyed() function calls loader()-&gt;checkLoadComplete() on the parent frame but otherwise does nothing to stop the loader or clear the redirect scheduler.

There’s also CachedFrame::destroy(). My guess is that case already guarantees the loading has stopped somehow, including clearing the redirect scheduler, but I&apos;m not sure about that case.

The lowest level way to fix this would be to just check for 0 in the timerFired function. Moving up the food chain, we could add a call to RedirectScheduler::clear() in Frame::detachFromPage(). Or we could add one to Frame::pageDestroyed() if we satisfy ourselves it’s not needed in CachedFrame::destroy().

If we could figure out a clean existing or new higher level concept of when we should stop loading due to the page going away, including clearing the scheduled redirect, then we could just fix that to work properly.

Given we can’t reproduce the crash reliably, we may not be able to make a test case, but this is trivial to fix!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>158477</commentid>
    <comment_count>8</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2009-10-28 00:08:14 -0700</bug_when>
    <thetext>Huh...  I thought I commented on this bug already.  Anyway, I&apos;m looking into it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>158484</commentid>
    <comment_count>9</comment_count>
      <attachid>42004</attachid>
    <who name="Adam Barth">abarth</who>
    <bug_when>2009-10-28 01:08:31 -0700</bug_when>
    <thetext>Created attachment 42004
Patch v1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>158486</commentid>
    <comment_count>10</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2009-10-28 01:12:02 -0700</bug_when>
    <thetext>Adding the null check seems more robust than making sure some elaborate set of cancelations happens correctly.

How can I test this behavior?  Is there a good way to hold on to a Frame after it&apos;s page has died?  Nothing jumped out at me when I grepped the code base.  The most promising thing I saw was Database callbacks...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>158554</commentid>
    <comment_count>11</comment_count>
      <attachid>42004</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2009-10-28 07:39:39 -0700</bug_when>
    <thetext>Comment on attachment 42004
Patch v1

I would have put the Page* into a local variable. But Maciej has chided me about that and told me to just trust the compiler to optimize the common subexpression in a simple, inlined case like this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>158555</commentid>
    <comment_count>12</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2009-10-28 07:41:47 -0700</bug_when>
    <thetext>(In reply to comment #10)
&gt; How can I test this behavior?  Is there a good way to hold on to a Frame after
&gt; it&apos;s page has died?  Nothing jumped out at me when I grepped the code base. 
&gt; The most promising thing I saw was Database callbacks...

I really have no idea. We could try to read some of the code at &lt;http://www.linkinpark.it/forum/index.php&gt; for clues. For the most part, I know about these &quot;frame afterlife&quot; issues from crash traces.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>158666</commentid>
    <comment_count>13</comment_count>
      <attachid>42004</attachid>
    <who name="Adam Barth">abarth</who>
    <bug_when>2009-10-28 12:45:29 -0700</bug_when>
    <thetext>Comment on attachment 42004
Patch v1

Long term, we might want to consider adding some testing specific APIs to WebKit like &quot;please hold a reference to this Frame and keep it alive.&quot;

Issues like this are easier to test with unit tests.  Maybe we should consider unit tests in addition to LayoutTests?  I like the LayoutTest model, but there are a lot of branches for null pages.  It&apos;s sad if we don&apos;t have any way of testing them.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>158769</commentid>
    <comment_count>14</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2009-10-28 16:25:47 -0700</bug_when>
    <thetext>(In reply to comment #13)
&gt; I like the LayoutTest model, but there
&gt; are a lot of branches for null pages. It&apos;s sad if we don&apos;t have any way of
&gt; testing them.

We can probably crack the code and figure out how to test them. I’ll think about it. One of the easiest ways to find a way to trigger a condition is to stick in an assertion and then run the browser under the debugger for a while.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>158783</commentid>
    <comment_count>15</comment_count>
      <attachid>42004</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2009-10-28 17:22:23 -0700</bug_when>
    <thetext>Comment on attachment 42004
Patch v1

Clearing flags on attachment: 42004

Committed r50251: &lt;http://trac.webkit.org/changeset/50251&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>158784</commentid>
    <comment_count>16</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2009-10-28 17:22:27 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>42004</attachid>
            <date>2009-10-28 01:08:31 -0700</date>
            <delta_ts>2009-10-28 17:22:22 -0700</delta_ts>
            <desc>Patch v1</desc>
            <filename>bug-30839-20091028010830.patch</filename>
            <type>text/plain</type>
            <size>1160</size>
            <attacher name="Adam Barth">abarth</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1dlYkNvcmUvQ2hhbmdlTG9nIGIvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXgg
MzZiZDUyYy4uNWY1MjY1MSAxMDA2NDQKLS0tIGEvV2ViQ29yZS9DaGFuZ2VMb2cKKysrIGIvV2Vi
Q29yZS9DaGFuZ2VMb2cKQEAgLTEsMyArMSwxNSBAQAorMjAwOS0xMC0yOCAgQWRhbSBCYXJ0aCAg
PGFiYXJ0aEB3ZWJraXQub3JnPgorCisgICAgICAgIFJldmlld2VkIGJ5IE5PQk9EWSAoT09QUyEp
LgorCisgICAgICAgIFJFR1JFU1NJT046IGNyYXNoZXMgaW4gV2ViQ29yZTo6UmVkaXJlY3RTY2hl
ZHVsZXI6OnRpbWVyRmlyZWQoV2ViQ29yZTo6VGltZXI8V2ViQ29yZTo6Um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