<?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>15055</bug_id>
          
          <creation_ts>2007-08-22 17:08:40 -0700</creation_ts>
          <short_desc>Divide by 0 in ProgressTracker::incrementProgress</short_desc>
          <delta_ts>2007-12-10 15:54:58 -0800</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>523.x (Safari 3)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></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="Brett Wilson (Google)">brettw</reporter>
          <assigned_to name="Brett Wilson (Google)">brettw</assigned_to>
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1675</commentid>
    <comment_count>0</comment_count>
    <who name="Brett Wilson (Google)">brettw</who>
    <bug_when>2007-08-22 17:08:40 -0700</bug_when>
    <thetext>int numPendingOrLoadingRequests =
    m_originatingProgressFrame-&gt;loader()-&gt;numPendingOrLoadingRequests(true);
estimatedBytesForPendingRequests = progressItemDefaultEstimatedLength *
    numPendingOrLoadingRequests;
remainingBytes = ((m_totalPageAndResourceBytesToLoad +
    estimatedBytesForPendingRequests) - m_totalBytesReceived);

percentOfRemainingBytes = (double)bytesReceived / (double)remainingBytes;

The problem here is that remainingBytes can be 0 depending on the (not very reliable) estimatedBytesForPendingRequests. This should be an easy fix.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>907</commentid>
    <comment_count>1</comment_count>
      <attachid>16204</attachid>
    <who name="Brett Wilson (Google)">brettw</who>
    <bug_when>2007-09-05 09:01:29 -0700</bug_when>
    <thetext>Created attachment 16204
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>337</commentid>
    <comment_count>2</comment_count>
      <attachid>16204</attachid>
    <who name="Oliver Hunt">oliver</who>
    <bug_when>2007-09-18 13:55:43 -0700</bug_when>
    <thetext>Comment on attachment 16204
Patch

There should be an ASSERTION in the else block to check that remainingBytes is not &lt;0</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57000</commentid>
    <comment_count>3</comment_count>
    <who name="Brett Wilson (Google)">brettw</who>
    <bug_when>2007-09-25 10:09:26 -0700</bug_when>
    <thetext>Why should there be an assertion? Won&apos;t that just look like a crash in release mode as well?

From what I understand, the whole point is that the &quot;remaining bytes&quot; is an estimate and not necessarily reality. As far as the math here goes, you might as well be using rand(). It doesn&apos;t make sense to assert that rand() is any particular value. Unless you are going to assert that the remaining bytes is guaranteed accurate, it doesn&apos;t make sense to add an assertion here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57403</commentid>
    <comment_count>4</comment_count>
      <attachid>16204</attachid>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2007-09-29 20:22:07 -0700</bug_when>
    <thetext>Comment on attachment 16204
Patch

The fix looks good to me (I can understand why the remainingBytes estimate could be wrong, since resources might not specify their length). But do you have a test case that can trigger this? I believe it could be done as an http test. r- to consider providing a test case, but if that is not practical just reflag for review and I&apos;ll approve it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>63537</commentid>
    <comment_count>5</comment_count>
      <attachid>16204</attachid>
    <who name="Brett Wilson (Google)">brettw</who>
    <bug_when>2007-12-06 14:52:45 -0800</bug_when>
    <thetext>Comment on attachment 16204
Patch

I don&apos;t think it&apos;s possible to write a test very easily. I think this would depend on the reported length from the server being wrong (maybe possible to test) and also that the packets arrive and WebKit does processing such that the size of the amount received is exactly the same as the predicted amount, without being complete.

Feel free to suggest a way if you know. I don&apos;t know any PHP and I&apos;ve never written an HTTP test, so there could be something I don&apos;t know.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>63539</commentid>
    <comment_count>6</comment_count>
      <attachid>16204</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2007-12-06 14:55:45 -0800</bug_when>
    <thetext>Comment on attachment 16204
Patch

We already have regression tests for things like this: The regression test engine runs a local copy of Apache, and we write server-side scripts to deliver data and delay as appropriate.

For example:

    LayoutTests/http/tests/incremental/slow-utf8-html.pl
    LayoutTests/http/tests/incremental/split-hex-entities.pl

Is this situation enough different from those that making a test is impractical?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>63574</commentid>
    <comment_count>7</comment_count>
      <attachid>16204</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2007-12-07 01:16:20 -0800</bug_when>
    <thetext>Comment on attachment 16204
Patch

OK, you wore me down. Usually we do require tests, but since this is obviously correct and you&apos;re not inspired to make a test, r=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>63872</commentid>
    <comment_count>8</comment_count>
    <who name="Andrew Wellington">andrew</who>
    <bug_when>2007-12-10 15:54:58 -0800</bug_when>
    <thetext>Committed in r28593</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>16204</attachid>
            <date>2007-09-05 09:01:29 -0700</date>
            <delta_ts>2007-12-07 01:16:20 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>zero.diff</filename>
            <type>text/plain</type>
            <size>1583</size>
            <attacher name="Brett Wilson (Google)">brettw</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYkNvcmUvQ2hhbmdlTG9nCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFdlYkNvcmUvQ2hhbmdlT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nVlKTsKICAgICBlc3RpbWF0ZWRCeXRlc0ZvclBlbmRpbmdSZXF1ZXN0cyA9IHByb2dyZXNzSXRl
bURlZmF1bHRFc3RpbWF0ZWRMZW5ndGggKiBudW1QZW5kaW5nT3JMb2FkaW5nUmVxdWVzdHM7CiAg
ICAgcmVtYWluaW5nQnl0ZXMgPSAoKG1fdG90YWxQYWdlQW5kUmVzb3VyY2VCeXRlc1RvTG9hZCAr
IGVzdGltYXRlZEJ5dGVzRm9yUGVuZGluZ1JlcXVlc3RzKSAtIG1fdG90YWxCeXRlc1JlY2VpdmVk
KTsKLSAgICBwZXJjZW50T2ZSZW1haW5pbmdCeXRlcyA9IChkb3VibGUpYnl0ZXNSZWNlaXZlZCAv
IChkb3VibGUpcmVtYWluaW5nQnl0ZXM7CisgICAgaWYgKHJlbWFpbmluZ0J5dGVzID4gMCkgIC8v
IFByZXZlbnQgZGl2aWRlIGJ5IDAuCisgICAgICAgIHBlcmNlbnRPZlJlbWFpbmluZ0J5dGVzID0g
KGRvdWJsZSlieXRlc1JlY2VpdmVkIC8gKGRvdWJsZSlyZW1haW5pbmdCeXRlczsKKyAgICBlbHNl
CisgICAgICAgIHBlcmNlbnRPZlJlbWFpbmluZ0J5dGVzID0gMS4wOwogICAgIAogICAgIC8vIFRy
ZWF0IHRoZSBmaXJzdCBsYXlvdXQgYXMgdGhlIGhhbGYtd2F5IHBvaW50LgogICAgIGRvdWJsZSBt
YXhQcm9ncmVzc1ZhbHVlID0gbV9vcmlnaW5hdGluZ1Byb2dyZXNzRnJhbWUtPmxvYWRlcigpLT5m
aXJzdExheW91dERvbmUoKSA/IGZpbmFsUHJvZ3Jlc3NWYWx1ZSA6IC41Owo=
</data>
<flag name="review"
          id="6813"
          type_id="1"
          status="+"
          setter="darin"
    />
          </attachment>
      

    </bug>

</bugzilla>