<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Laughing Meme &#187; bug</title>
	<atom:link href="http://laughingmeme.org/tag/bug/feed/" rel="self" type="application/rss+xml" />
	<link>http://laughingmeme.org</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 29 Jan 2012 21:54:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>I&#8217;m sure Boris Zbarsky is a wonderful person</title>
		<link>http://laughingmeme.org/2006/01/09/im-sure-boris-zbarsky-is-a-wonderful-person/</link>
		<comments>http://laughingmeme.org/2006/01/09/im-sure-boris-zbarsky-is-a-wonderful-person/#comments</comments>
		<pubDate>Mon, 09 Jan 2006 20:25:00 +0000</pubDate>
		<dc:creator>Kellan</dc:creator>
				<category><![CDATA[Aside]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[dom]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[opensource]]></category>

		<guid isPermaLink="false">http://lm.quxx.info/?p=3182</guid>
		<description><![CDATA[But could someone maybe distract him long enough (a night on the town?) to get the damn phantom text nodes in Firefox fixed?]]></description>
			<content:encoded><![CDATA[<p>But could someone maybe distract him long enough (a night on the town?) to get the damn phantom text nodes in Firefox fixed?</p>
<p><a href='https://bugzilla.mozilla.org/show_bug.cgi?id=26179'>https://bugzilla.mozilla.org/show_bug.cgi?id=26179</a></p>]]></content:encoded>
			<wfw:commentRss>http://laughingmeme.org/2006/01/09/im-sure-boris-zbarsky-is-a-wonderful-person/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bug 26179 &#8211; Mozilla reports existence of phantom text nodes in the DOM</title>
		<link>http://laughingmeme.org/2005/11/11/bug-26179-mozilla-reports-existence-of-phantom-text-nodes-in-the-dom/</link>
		<comments>http://laughingmeme.org/2005/11/11/bug-26179-mozilla-reports-existence-of-phantom-text-nodes-in-the-dom/#comments</comments>
		<pubDate>Fri, 11 Nov 2005 08:51:00 +0000</pubDate>
		<dc:creator>Kellan</dc:creator>
				<category><![CDATA[Aside]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[dom]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[opensource]]></category>

		<guid isPermaLink="false">http://lm.quxx.info/?p=3103</guid>
		<description><![CDATA[this bug has been open for 4 years, and it makes a good chunk of the DOM useless]]></description>
			<content:encoded><![CDATA[<p>this bug has been open for 4 years, and it makes a good chunk of the DOM useless</p>
<p><a href='https://bugzilla.mozilla.org/show_bug.cgi?id=26179'>https://bugzilla.mozilla.org/show_bug.cgi?id=26179</a></p>]]></content:encoded>
			<wfw:commentRss>http://laughingmeme.org/2005/11/11/bug-26179-mozilla-reports-existence-of-phantom-text-nodes-in-the-dom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Map Anomalies</title>
		<link>http://laughingmeme.org/2005/03/11/google-map-anomalies/</link>
		<comments>http://laughingmeme.org/2005/03/11/google-map-anomalies/#comments</comments>
		<pubDate>Fri, 11 Mar 2005 17:33:53 +0000</pubDate>
		<dc:creator>Kellan</dc:creator>
				<category><![CDATA[bug]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[maps]]></category>
		<category><![CDATA[providence]]></category>

		<guid isPermaLink="false">http://lm.quxx.info/?p=1032</guid>
		<description><![CDATA[Google Maps is very cool, on so many levels, its hard to know where to start (definitely the long wake), but it does have some odd quirks. Check out this map of the booming metropolis of Roger Williams National Park between Pawtucket and Cranston. (hint for those who haven&#8217;t lived in the Ocean State, Rhode [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://google.com/maps">Google Maps</a> is very cool, on so many levels, its hard to know where to start (definitely the <a href="http://www.sauria.com/blog/2005/03/10#1241">long wake</a>), but it does have some odd quirks.  </p>

<p>Check out this map of the <a href="http://google.com/maps?q=providence%2C%20ri&amp;spn=0.205078%2C0.430934&amp;hl=en">booming metropolis of Roger Williams National Park</a> between Pawtucket and Cranston.  (hint for those who haven&#8217;t lived in the Ocean State, Rhode Island seems to have misplaced it&#8217;s capitol.)</p>

<p><strong>update</strong>:  you now have to zoom out one notch to see Providence disappear.</p>
]]></content:encoded>
			<wfw:commentRss>http://laughingmeme.org/2005/03/11/google-map-anomalies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>frequent   crash on javascript window.open()</title>
		<link>http://laughingmeme.org/2004/10/06/frequent-crash-on-javascript-windowopen/</link>
		<comments>http://laughingmeme.org/2004/10/06/frequent-crash-on-javascript-windowopen/#comments</comments>
		<pubDate>Wed, 06 Oct 2004 21:16:24 +0000</pubDate>
		<dc:creator>Kellan</dc:creator>
				<category><![CDATA[Aside]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[firefox]]></category>

		<guid isPermaLink="false">http://lm.quxx.info/?p=2583</guid>
		<description><![CDATA[My vote for most annoying bug in 0.10.x, should be a showstopper for 1.0]]></description>
			<content:encoded><![CDATA[<p>My vote for most <em>annoying</em> bug in 0.10.x, should be a showstopper for 1.0</p>
<p><a href='https://bugzilla.mozilla.org/show_bug.cgi?id=255372'>https://bugzilla.mozilla.org/show_bug.cgi?id=255372</a></p>]]></content:encoded>
			<wfw:commentRss>http://laughingmeme.org/2004/10/06/frequent-crash-on-javascript-windowopen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP 4.3.2, fread(), network streams, and Magpie</title>
		<link>http://laughingmeme.org/2003/06/25/php-432-fread-network-streams-and-magpie/</link>
		<comments>http://laughingmeme.org/2003/06/25/php-432-fread-network-streams-and-magpie/#comments</comments>
		<pubDate>Thu, 26 Jun 2003 05:05:00 +0000</pubDate>
		<dc:creator>Kellan</dc:creator>
				<category><![CDATA[bug]]></category>
		<category><![CDATA[magpie]]></category>

		<guid isPermaLink="false">http://lm.quxx.info/?p=491</guid>
		<description><![CDATA[At long last we come to the end (hopefully) of the MagpieRSS and PHP 4.3.2 saga, the good guys win, the bad guys unforunatley got away and will live to program again, but for now all is peaceful. Look for MagpieRSS 0.5.2 later this evening. When using fread() on a network stream, it must be [...]]]></description>
			<content:encoded><![CDATA[<p>
At long last we come to the end (hopefully) of the MagpieRSS and PHP 4.3.2 saga, the good guys win, the bad guys unforunatley got away and will live to program again, but for now all is peaceful.  Look for MagpieRSS 0.5.2 later this evening.
</p>

<p><p>
<h3>When using fread() on a network stream, it must be called in a loop</h3></p>

<blockquote>
When reading from network streams or pipes reading will stop after a packet is available.  &#8211; <a href="http://www.php.net/fread/">PHP Manual: fread</a></blockquote>

<p></p>
<p>
The documentation goes on to say, &#8220;when reading from network streams or pipes, you should collect the data together in chunks&#8221;.  There, could it be any clearer!
</p>
<p>
<h3>Migration Headache</h3></p>

<p>Why yes, yes it could.  You see, it didn&#8217;t used to be like that.  I&#8217;m not sure how long the documentation has been changed, but until recently fread() was quite content to read past the end of a packet until you had <b>all</b> the information you <b>asked</b> for.  Migration is complicated by the fact that this new behaviour happens very very quietly, and seemingly sporadically.  You would never know anything had changed until your XML started showing up mangled causing 
<a href="http://laughingmeme.org/archives/000893.html#bug1">only the first item in an RSS feed to show up</a>, or your gzip encoded data was delivered improperly formatted causing 
<a href="http://laughingmeme.org/archives/000916.html#000916">gzinflate(): buffer errors</a> (to choose 2 hypothetical example).
</p>
<p>
And then of course there is the, ahem, questionable &#8220;example&#8221; of using fread() with a network socket one finds in the fread documentation.. (more on that later)
</p>
<p>
<h3>Steve Minutillo</h3></p>

<p>But first, I&#8217;d like to go on record and say 
<a href="http://minutillo.com/steve/weblog/">Steve</a> is the genius, and a very nice person who figured this all out.  I was still stuck swearing at expat, and then on a clue from Steve I was swearing at PHP&#8217;s bundled zlib.  Neither of whom were to blame.  It was <a href="http://snoopy.sf.net">Snoopy&#8217;s</a> old style fread() usage, compounded by my gzip encoding hack.  (Here is a 
<a href="http://laughingmeme.org/snoopy_php4_3_2.patch">patch</a> to make the upstream Snoopy work with 4.3.2)
</p>
<p></p>

<h3>Now Back to Trashing PHP</h3>

<p>Okay, what the hell is up with that example in the 
<a href="http://www.php.net/fread">manual</a>?  We&#8217;re going to play a game, called &#8220;how many really really egregious bugs can you spot in this code&#8221;.  No, poor style doesn&#8217;t count as a bug (but icky C inspired examples are a perfectly valid reason to stake someone over an anthill)</p>

<pre><code>
&lt;?php
$handle = fopen ("http://www.php.net/", "rb");
$contents = "";
do {
    $data = fread ($handle, filesize ($filename));
    if (strlen($data) == 0) {
        break;
    }
    $contents .= $data;
}
fclose ($handle);
?&gt;
</code></pre>

<p>I count 2, plus a minor one.  And while I&#8217;ll be the first to admit PHP is not my best language, can someone tell me what is wrong with the much simpler, or are they just trying to trip people?</p>

<pre><code>
while ( $data = fread($handle, 10240) ) {
    $results .= $data;

}
</code></pre>

<p>So yeah if you&#8217;ve upgraded to 4.3.2 and you&#8217;re seeing cropped data, make sure you (or the library you depend upon) has been updated for the new, stricter fread regime.</p>

<p></p></p>
]]></content:encoded>
			<wfw:commentRss>http://laughingmeme.org/2003/06/25/php-432-fread-network-streams-and-magpie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magpie, PHP 4.3.2 Memory Error, an Update</title>
		<link>http://laughingmeme.org/2003/06/25/magpie-php-432-memory-error-an-update/</link>
		<comments>http://laughingmeme.org/2003/06/25/magpie-php-432-memory-error-an-update/#comments</comments>
		<pubDate>Wed, 25 Jun 2003 20:49:00 +0000</pubDate>
		<dc:creator>Kellan</dc:creator>
				<category><![CDATA[bug]]></category>
		<category><![CDATA[fof]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[magpie]]></category>

		<guid isPermaLink="false">http://lm.quxx.info/?p=490</guid>
		<description><![CDATA[Steve tracked down the root of the problem that is causing MagpieRSS to run out of memory after upgrading to 4.3.2. It lies in my (apparently dodgy) patch to Snoopy to add gzip support. Temporary Solution To turn off gzip encoding (and thereby avoid this bug) add: define('MAGPIEUSEGZIP', false); to the top of your script. [...]]]></description>
			<content:encoded><![CDATA[<p>
<a href="http://minutillo.com/steve/weblog/">Steve</a> tracked down the root of the problem that is causing MagpieRSS to run out of memory after upgrading to 4.3.2.  It lies in my (apparently dodgy) patch to Snoopy to add gzip support.
</p>

<p><p>
<h3>Temporary Solution</h3>
To turn off gzip encoding (and thereby avoid this bug) add:
<p> 
<code>
define('MAGPIE<em>USE</em>GZIP', false);
</code>
</p>
to the top of your script.
</p></p>

<p>
<h3>Explanation</h3>
After much hair pulling trying to get gzip encoding working in PHP, I found this magic recipe in <a href=" http://www.php.net/manual/en/function.gzencode.php">comments attached to gzencode</a>:
<p>
<code>
 $results = substr($results, 10);
 $results = gzinflate($results);
</code>
</p>
Seems you had to strip off the gzip header to make it work.  This was confirmed when I found <a href="http://simon.incutio.com/">Simon&#8217;s</a> <a href="http://scripts.incutio.com/httpclient/">httpClient</a>.
</p>

<p><p>
Apparently this is changed in 4.3.2, and stripping the first 10 characters leads eventually (through a yet untraced path) to an out of memory error.
</p>
<p>
<h3>Next Steps</h3>
Does anyone have any info about this?  Any suggestions on a good way to support 4.3.2 and pre-4.3.2 PHPs?  Gzip encoding really isn&#8217;t an optional feature in a modern aggregator, so turning it off is a short term solution.
</p>
<p>
<h3>Update 6/25 2:16</h3>
Okay, so I&#8217;ve got PHP 4.2.3 locally now (via <a href="http://www.entropy.ch/software/macosx/php/">Marc Liyanage&#8217;s excellent package</a>), and I&#8217;m seeing similar behaviour.  I don&#8217;t actually get an out of memory error, but I can see memory usage spike (with iPulse) and I get a warning about a gzinflate buffer error.  Unforunately  removing &#8220;$results = substr($results, 10);&#8221; <b>does not</b> fix the problem for me.  So currently the only solution is to turn gzip encoding off <img src='http://laughingmeme.org/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> 
 </p>
<p>
<h3>Curiouser and Curiouser</h3>
So removing the substr() call changed the error message form &#8220;gzinflate(): buffer error&#8221;, to &#8220;gzinflate(): data error&#8221;.  However only for certain websites!  Files served with gzip encoding from some sites (<a href="http://dev.protest.net/~kellan/cvs-rss/">like mine</a>) work, but from others, it doesn&#8217;t.  Ack. 
</p></p>
]]></content:encoded>
			<wfw:commentRss>http://laughingmeme.org/2003/06/25/magpie-php-432-memory-error-an-update/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Magpie GZIP Bug</title>
		<link>http://laughingmeme.org/2003/05/30/magpie-gzip-bug/</link>
		<comments>http://laughingmeme.org/2003/05/30/magpie-gzip-bug/#comments</comments>
		<pubDate>Fri, 30 May 2003 20:27:00 +0000</pubDate>
		<dc:creator>Kellan</dc:creator>
				<category><![CDATA[bug]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[magpie]]></category>

		<guid isPermaLink="false">http://lm.quxx.info/?p=457</guid>
		<description><![CDATA[MagpieRSS 0.5 can fail without errors when fetching a RSS feed using GZIP encoding if your PHP doesn&#8217;t support gzinflate() (i.e. it hasn&#8217;t been built with --with-zlib) As of 0.5 sends an &#8220;Accept-encoding: gzip&#8221; header by default when fetching RSS files. You turn this feature off by adding define(MAGPIEUSEGZIP, 0) to the top of your [...]]]></description>
			<content:encoded><![CDATA[<p>
MagpieRSS 0.5 can fail without errors when fetching a RSS feed using GZIP encoding if your PHP doesn&#8217;t support <code>gzinflate()</code> (i.e. it hasn&#8217;t been built with <code>--with-zlib</code>)
</p>

<p><p>
As of 0.5 sends an &#8220;Accept-encoding: gzip&#8221; header by default when fetching RSS files.  You turn this feature off by adding <code>define(MAGPIE<em>USE</em>GZIP, 0)</code> to the top of your script.
</p>
<p>
A patched version of the locally maintained <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/magpierss/magpierss/extlib/Snoopy.class.inc">extlib/Snoopy.class.inc</a> 
that checks <code>function_exists(gzinflate)</code> is available in <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/magpierss/magpierss/extlib/Snoopy.class.inc">CVS</a>.
This fix seems to work, I haven&#8217;t had a chance to test it widely.  It is a busy week, but I&#8217;ll try to have a final fix, and new version out in the next couple of days.
<p>
(sidenote:  It seems silly to fork Snoopy, and give it a new name over one minor change like adding gzip support however development on Snoopy has stopped and its confusing this maintaing a local version because I don&#8217;t want to imply there is a bug with the real <a href="http://snoopy.sf.net">Snoopy</a>, just my version.  What do you think?)
</p></p>
]]></content:encoded>
			<wfw:commentRss>http://laughingmeme.org/2003/05/30/magpie-gzip-bug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

