<?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>Indistinguishable from Jesse &#187; Fuzzing</title>
	<atom:link href="http://www.squarefree.com/categories/fuzzing/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.squarefree.com</link>
	<description>Jesse Ruderman on Firefox, security, and more</description>
	<lastBuildDate>Sun, 05 Feb 2012 17:32:14 +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>Fuzzing in the pool</title>
		<link>http://www.squarefree.com/2010/11/23/fuzzing-in-the-pool/</link>
		<comments>http://www.squarefree.com/2010/11/23/fuzzing-in-the-pool/#comments</comments>
		<pubDate>Wed, 24 Nov 2010 04:25:51 +0000</pubDate>
		<dc:creator>Jesse Ruderman</dc:creator>
				<category><![CDATA[Fuzzing]]></category>
		<category><![CDATA[Mozilla]]></category>

		<guid isPermaLink="false">http://www.squarefree.com/?p=622</guid>
		<description><![CDATA[In mid-2009, John O'Duinn offered to let my DOM fuzzer run on the same pool of machines as Firefox regression tests. I'd have an average of 20 computers running my fuzzer across a range of operating systems, and I wouldn't have to maintain the computers. All I had to do was tweak my script to [...]]]></description>
			<content:encoded><![CDATA[<p>In mid-2009, <a href="http://oduinn.com/">John O'Duinn</a> offered to let my DOM fuzzer run on the same <a href="http://anamariamoz.wordpress.com/2010/11/08/mozillas-build-system/">pool of machines</a> as Firefox regression tests.  I'd have an average of 20 computers running my fuzzer across a range of operating systems, and I wouldn't have to maintain the computers.  All I had to do was tweak my script to play nicely with the scheduler, and not destroy the machines.</p>


<h3>Playing nicely with the scheduler</h3>

<p>Counter-intuitively, to maximize the amount of fuzzing, I had to minimize the duration of each fuzz job.  The scheduler tries to avoid delays in the regression test jobs so developers don't go insane <a href="https://developer.mozilla.org/En/Developer_Guide/Committing_Rules_and_Responsibilities#Watch_The_Tree">watching the tree</a>.  A low-priority job will be allowed to start much more often if it only takes 30 minutes.</p>

<p>Being limited to 30 minutes means the fuzz jobs don't have time to compile Firefox.  Instead, fuzz jobs have to download <a href="https://ftp.mozilla.org/pub/mozilla.org/firefox/tinderbox-builds/">Tinderbox builds</a> like the regression test jobs do.  I <a href="https://bugzilla.mozilla.org/buglist.cgi?quicksearch=561672,550388,570287,531479,532184">fixed several bugs in mozilla-central</a> to make Tinderbox builds work for fuzzing.</p>

<p>I also modified the <a href="http://www.squarefree.com/2007/09/15/introducing-lithium-a-testcase-reduction-tool/">testcase reducer</a> to split its work into 30-minute jobs.  If the fuzzer finds a bug and the reducer takes longer than 30 minutes, it uploads the partially-reduced testcase, along with the reduction algorithm's state, for a subsequent job to continue reducing.  To avoid race conditions between uploading and downloading, I use "ssh mv" synchronization.</p>


<h3>Not destroying the test slaves</h3>

<p>I wasn't trying to fill up the disks on the test slaves, really!</p>

<p>Early versions of my script <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=593561">filled up /tmp</a>. I had incorrectly assumed that /tmp would be cleared on each reboot.  Luckily, Nagios caught this before it caused serious damage.</p>

<p>Due to <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=600064">a security bug in some debug builds of Firefox</a>, the fuzzer created randomly-named files in the home directory.  This security bug has been fixed, but I'm afraid RelEng will be <a href="http://quotes.burntelectrons.org/5500">finding files</a> named "undefined" and "[Object HTMLBodyElement]" for a while.</p>

<p>By restarting Firefox frequently, fuzzing accelerated the creation of <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=603238">gigantic console.log files</a> on the slaves.  We're trying to figure out whether to make debug-Firefox not create these files or make BuildBot delete them.</p>


<h3>Results so far</h3>

<p>Running in the test pool gets me a variety of operating systems. The fuzzer currently runs on Mac32 (10.5), Mac64 (10.6), Linux32, Linux64, and Win32.  This allowed me to find <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=606639">a 64-bit-only bug</a> and <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=601427">a Linux-only bug</a> in October. Previously, I had mostly been testing on Mac.</p>

<p>The extra computational power also makes a difference.  I can find regressions more quickly (which developers appreciate) and find <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=614149">harder-to-trigger bugs</a> (which developers don't appreciate quite as much).  I also get faster results when I change the fuzzer, such as the <a href="https://bugzilla.mozilla.org/buglist.cgi?quicksearch=608573,608295">two convoluted testcases</a> I got shortly after I added document.write fuzzing.</p>

<p>Unexpectedly, getting quick results from fuzzer changes makes me more inclined to tweak and improve to the fuzzer. I know that the change will still be fresh in my mind when I learn about its effects. This may turn out to be the most important win.</p>

<p>With cross-platform testing and the boost to agility, I suddenly feel a lot closer to being able to share and release the fuzzer.</p>]]></content:encoded>
			<wfw:commentRss>http://www.squarefree.com/2010/11/23/fuzzing-in-the-pool/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How my DOM fuzzer ignores known bugs</title>
		<link>http://www.squarefree.com/2010/11/21/how-my-dom-fuzzer-ignores-known-bugs/</link>
		<comments>http://www.squarefree.com/2010/11/21/how-my-dom-fuzzer-ignores-known-bugs/#comments</comments>
		<pubDate>Mon, 22 Nov 2010 04:42:37 +0000</pubDate>
		<dc:creator>Jesse Ruderman</dc:creator>
				<category><![CDATA[Fuzzing]]></category>
		<category><![CDATA[Mozilla]]></category>

		<guid isPermaLink="false">http://www.squarefree.com/?p=616</guid>
		<description><![CDATA[When my DOM fuzzer finds a new bug, I want it to make a reduced testcase and notify me so I can file a bug report. To keep it from wasting time finding duplicates of known bugs, I maintain several ignore lists: 23 known crash signatures for 12 bugs 435 known assertions for 280 bugs [...]]]></description>
			<content:encoded><![CDATA[<p>When my DOM fuzzer finds a new bug, I want it to <a href="http://www.squarefree.com/2007/09/15/introducing-lithium-a-testcase-reduction-tool/">make a reduced testcase</a> and notify me so I can file a bug report.  To keep it from wasting time finding duplicates of known bugs, I maintain several <strong>ignore lists</strong>:</p>

<ul>
<li><a href="http://www.squarefree.com/fuzzing-ignores-2010-11/crashes.txt">23 known crash signatures</a> for <a href="https://bugzilla.mozilla.org/buglist.cgi?bug_id=571653,574904,585745,588237,588278,600100,601261,601411,604262,604807,605264,610477">12 bugs</a></li>
<li><a href="http://www.squarefree.com/fuzzing-ignores-2010-11/assertions.txt">435 known assertions</a> for <a href="https://bugzilla.mozilla.org/buglist.cgi?bug_id=136927,163838,180909,254181,255141,265084,266532,284594,303500,315549,322657,323498,324025,326625,327706,329891,345094,362649,367251,369179,370713,374680,382210,384504,385552,386010,387205,387754,391157,391879,393325,393501,393802,397568,398038,398043,398103,398121,399262,400789,402384,404115,407550,407649,408899,410166,410230,410267,410428,411319,414178,416639,417848,420776,421174,421829,422015,424225,424289,427322,427928,429454,429586,434559,434894,436006,436204,436470,437162,439204,439258,441680,443546,443655,444036,444702,444859,448083,451316,453871,454308,454746,456899,460209,461296,461907,462461,463356,463710,463711,464799,468202,468556,468557,468715,468967,469917,471064,472227,472256,473243,473481,473841,476021,477325,478135,479160,480686,481089,481097,481301,481557,482375,485893,493613,493641,493910,495546,495819,497734,499848,500532,500847,501870,505320,508394,508911,509562,512743,512749,513110,513397,516105,518739,521380,522174,522388,522515,526648,527825,527858,531550,531589,532145,536242,536654,536692,537027,537624,539348,540078,541620,542424,547003,550355,550364,560766,562510,563481,564047,564098,564099,564231,566159,569024,569193,570038,570082,570215,570386,570436,571020,571609,571610,571611,571612,571613,571959,572571,572617,572620,573321,573324,574889,575011,575464,576435,576719,576832,576931,580129,580481,580790,580796,581785,584208,587268,588237,588278,588627,589316,591075,591138,591480,591998,593302,593305,593550,593933,594634,595428,595613,595783,596876,596901,597240,597297,597317,597924,597935,600020,600100,600703,600783,601035,601046,601070,601076,601284,601289,601308,601392,601416,601434,601659,602661,603494,603524,603854,604262,604556,604841,605048,605979,606022,606432,606639,606642,606866,606914,606920,607001,608160,608191,608467,608573,608815,610331,610482,610483,610594,610952,611175,611532,611922,611927,612736,612994,613120,613122,613410,613421,613455,613629,613700,613793,613808,613816,613817,613889">280 bugs</a></li>
<li><a href="http://www.squarefree.com/fuzzing-ignores-2010-11/rleak.txt">12 known types of small memory leaks</a> for <a href="https://bugzilla.mozilla.org/buglist.cgi?bug_id=102229,397206,403199,417630,419562,463724,584590,601341,603844,610094">10 bugs</a></li>
<li><a href="http://www.squarefree.com/fuzzing-ignores-2010-11/valgrind.txt">Known valgrind warnings</a> for <a href="https://bugzilla.mozilla.org/buglist.cgi?bug_id=407860,499704,549224,566137,566168,571758,573190,573192,573688,580351,602447">11 bugs</a> and a bunch of library/compiler bugs.</li>
</ul>

<p>Some bugs are harder to distinguish based on output. In those cases, I use suppressions based on the fuzzer-generated input to Firefox:</p>

<ul>
<li><a href="http://www.squarefree.com/fuzzing-ignores-2010-11/input-hangs.txt">34 inputs allowed to cause hangs</a> for <a href="https://bugzilla.mozilla.org/buglist.cgi?bug_id=312680,331334,408147,458659,460705,493910,513106,543078,543645,543648,543651,544453,557348,564889,573426,592129,595042,600042,612213">19 bugs</a></li>
<li><a href="http://www.squarefree.com/fuzzing-ignores-2010-11/input-largeleaks.txt">6 inputs allowed cause large memory leaks</a> for <a href="https://bugzilla.mozilla.org/buglist.cgi?bug_id=605294,610571,613027">3 bugs</a></li>
</ul>

<p><strong>Fixing any bug on those lists improves the fuzzer's ability to find additional bugs.</strong>  But I'd like to point out a few that I'd especially like fixed:</p>

<ul>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=531550">Bug 531550</a> has me ignoring the "invalid array index" assertion for <a href="https://developer.mozilla.org/en/XPCOM_array_guide#nsTArray.3cT.3e">nsTArrays</a>.</li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=580790">Bug 580790</a> has me ignoring "recursion level" assertions for <a href="https://developer.mozilla.org/en/XPCOM_hashtable_guide#PLDHash_%28JSDHash%29">PLDHashes</a>.</li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=588237">Bug 588237</a> has me ignoring a large number of crashes and assertions in layout.</li>
</ul>

<p>In rare cases, I'll temporarily tell the fuzzer to skip a feature entirely:</p>

<ul>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=571613">Bug 571613</a> has me not testing with accessibility enabled.</li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=576927">Bug 576927</a> has me not testing text zoom.</li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=605271">Bug 605271</a> has me not testing QueryInterface.</li>
</ul>

<p>Several bugs interfere with my ability to distinguish bugs. Luckily, they're all platform-specific, so they don't prevent me from finding cross-platform bugs.</p>

<ul>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=610311">Bug 610311</a> makes it difficult to distinguish crashes on Linux, so I ignore crashes there.</li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=612093">Bug 612093</a> makes it difficult to distinguish PR_Asserts and abnormal exits on Windows. (It's fixed in NSPR and needs to be merged to mozilla-central.)</li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=507876">Bug 507876</a> makes it difficult to distinguish too-much-recursion crashes on Mac. (But I don't currently know of any, so I'm not ignoring them at the moment!)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.squarefree.com/2010/11/21/how-my-dom-fuzzer-ignores-known-bugs/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>GCC correctness fuzzing</title>
		<link>http://www.squarefree.com/2010/11/03/gcc-correctness-fuzzing/</link>
		<comments>http://www.squarefree.com/2010/11/03/gcc-correctness-fuzzing/#comments</comments>
		<pubDate>Wed, 03 Nov 2010 21:15:38 +0000</pubDate>
		<dc:creator>Jesse Ruderman</dc:creator>
				<category><![CDATA[Fuzzing]]></category>

		<guid isPermaLink="false">http://www.squarefree.com/?p=602</guid>
		<description><![CDATA[In 2008 I wrote about generating random JavaScript to find differences between optimization modes and differences between JavaScript engines (rough list of bugs). How do you do this kind of testing on a language like C where the behavior of many programs is undefined per spec? John Regehr explains how in his talk Exposing Difficult [...]]]></description>
			<content:encoded><![CDATA[<p>In 2008 I wrote about generating random JavaScript to find <a href="http://www.squarefree.com/2008/12/23/fuzzing-tracemonkey/">differences between optimization modes</a> and <a href="http://www.squarefree.com/2008/12/23/differences/">differences between JavaScript engines</a> (<a href="https://bugzilla.mozilla.org/buglist.cgi?quicksearch=465453,465460,465483,465567,465901,466781,466787,469927,469942,469943,470128,470129,470133,470139,470143,470144,470176,470735,470736,470737,470739,470779,470964,474769,489682,491989,495566,495773,495907,496532,496816,496922,497015,498236,498237,498549,501275,502768,503818,504520,505003,508187,566637,566639,584587,584603,584605,584647,593554,593556,601454">rough list of bugs</a>).</p>

<p>How do you do this kind of testing on a language like C where the behavior of many programs is <a href="http://en.wikipedia.org/wiki/Undefined_behavior">undefined per spec</a>?  <a href="http://blog.regehr.org/">John Regehr</a> explains how in his talk <strong>Exposing Difficult Compilers Bugs With Random Testing</strong> at <a href="http://gcc.gnu.org/wiki/summit2010">GCC Summit 2010</a>.</p>

<ul>
<li><a href="http://www.gccsummit.org/2010/view_abstract.php?content_key=1">Abstract</a></li>
<li><strong><a href="http://gcc.gnu.org/wiki/summit2010?action=AttachFile&amp;do=get&amp;target=regehr_gcc_summit_2010.pdf">Slides (PDF)</a></strong></li>
<li><a href="http://www.slideshare.net/regehr/gcc-summit-2010">Slides (Flash)</a></li>
<li><a href="http://blog.regehr.org/archives/289#comments">Comments on John Regehr's blog</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://www.squarefree.com/2010/11/03/gcc-correctness-fuzzing/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fuzzing talk at the Mozilla Summit</title>
		<link>http://www.squarefree.com/2010/07/14/fuzzing-talk-at-the-mozilla-summit/</link>
		<comments>http://www.squarefree.com/2010/07/14/fuzzing-talk-at-the-mozilla-summit/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 18:48:34 +0000</pubDate>
		<dc:creator>Jesse Ruderman</dc:creator>
				<category><![CDATA[Fuzzing]]></category>
		<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.squarefree.com/?p=594</guid>
		<description><![CDATA[At the 2010 Mozilla Summit, I talked about my JavaScript engine and DOM fuzzers, which have each found many hundreds of bugs. I also talked about the automations that keep me sane when I fuzz these complex components. My slides are in the S5 web-based presentation format. You can click the Ø button to view [...]]]></description>
			<content:encoded><![CDATA[<p>At the 2010 Mozilla Summit, I talked about my JavaScript engine and DOM fuzzers, which have each found many hundreds of bugs.  I also talked about the automations that keep me sane when I fuzz these complex components.</p>

<p><a href="http://www.squarefree.com/fuzzing2010/fuzzing2010.xhtml">My slides</a> are in the <a href="http://meyerweb.com/eric/tools/s5/">S5 web-based presentation format</a>.  You can click the Ø button to view the presentation in "handout mode" and see what I planned to <em>say</em> while each slide was up.</p>

<p>I shared a presentation slot with Mozilla contractor Paul Nickerson, who has a separate slide deck.  He wisely saved the best part of his talk for the end: a demo of his font fuzzer causing Windows 7 to <a href="http://en.wikipedia.org/wiki/Blue_Screen_of_Death">blue-screen</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.squarefree.com/2010/07/14/fuzzing-talk-at-the-mozilla-summit/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>CSS grammar fuzzer</title>
		<link>http://www.squarefree.com/2009/03/16/css-grammar-fuzzer/</link>
		<comments>http://www.squarefree.com/2009/03/16/css-grammar-fuzzer/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 02:28:54 +0000</pubDate>
		<dc:creator>Jesse Ruderman</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Fuzzing]]></category>
		<category><![CDATA[Mozilla]]></category>

		<guid isPermaLink="false">http://www.squarefree.com/?p=432</guid>
		<description><![CDATA[I wrote a CSS grammar fuzzer to test Gecko's CSS parser. This fuzzer's tricks: Declarative context-free grammar. This makes it easy to add new CSS features to the fuzzer, or even use it to test grammars other than CSS. Each symbol can be a star, concatenation, or list of alternatives. Unlike a parser, a fuzzer [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote a CSS grammar fuzzer to test Gecko's CSS parser.  This fuzzer's tricks:</p>

<p><strong>Declarative context-free grammar.</strong>  This makes it easy to add new CSS features to the fuzzer, or even use it to test grammars other than CSS.  Each symbol can be a <a href="http://en.wikipedia.org/wiki/Kleene_star">star</a>, concatenation, or list of alternatives.  Unlike a parser, a fuzzer has to make decisions about what to create, so alternatives can be given weights and stars have a suggested number of repetitions.  This alone was enough to find <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=473892">at least one bug in Gecko</a>.</p>

<p><strong>Breaking rules.</strong>  Like any good fuzzer, it doesn't always follow the given context-free grammar.  Sometimes it does weird stuff, such as inserting a random symbol, to throw the parser off.  I was surprised that this only found <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=473720">one additional bug in Gecko</a>.  Perhaps this reflects the comprehensive error handling requirements of the CSS specifications and the corresponding test suites.</p>

<p><strong>Grammatical recursion.</strong>  When the fuzzer notices that a symbol is the same as an ancestor, it can repeat the parts of the final string between the two symbols.  This is effective at finding bugs where large input can cause a recursive algorithm to run out of stack space and crash.  This found <a href="https://bugzilla.mozilla.org/buglist.cgi?bug_id=473908,473911,473914,475215">four grammar-recursion crashes in Gecko</a>.</p>

<p><strong>CSS serialization.</strong>  The fuzzer makes sure that any text that comes out of the browser's stylesheet serializer survives another trip through the parser and serializer.  This is the <a href="http://www.squarefree.com/2007/08/02/fuzzing-for-correctness/">same trick</a> jsfunfuzz uses to test the JavaScript engine decompiler.  This helped fine <a href="https://bugzilla.mozilla.org/buglist.cgi?bug_id=475214,475216,478160,478156">four incorrect-serialization bugs in Gecko</a>.</p>

<p>None of these Gecko bugs seem to be security holes.  I shared the fuzzer with other browser vendors privately for over a month, and nobody asked me to delay the release, so I believe it didn't find security holes in other browsers either.  But I think this has more to do with CSS parsing being fairly simple and self-contained than any weakness in the fuzzer.</p>

<p>After CanSecWest, I'm going to try using this fuzzer to generate JavaScript expressions that crash parsers that use recursion incautiously.  Unless someone beats me to it, of course ;)  (<a href="http://www.squarefree.com/2007/08/02/introducing-jsfunfuzz/">jsfunfuzz</a> already creates many types of weird JavaScript, but can't look for grammatical recursion opportunities easily because it is written in a functional style rather than a declarative style.)</p>

<p>This fuzzer is written in JavaScript and is MIT licensed.  I'd love to hear what other people manage to do with it.  <a href="http://www.squarefree.com/css-grammar-fuzzer/">Get it here</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.squarefree.com/2009/03/16/css-grammar-fuzzer/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Some differences between JavaScript engines</title>
		<link>http://www.squarefree.com/2008/12/23/differences/</link>
		<comments>http://www.squarefree.com/2008/12/23/differences/#comments</comments>
		<pubDate>Wed, 24 Dec 2008 03:57:36 +0000</pubDate>
		<dc:creator>Jesse Ruderman</dc:creator>
				<category><![CDATA[Fuzzing]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Mozilla]]></category>

		<guid isPermaLink="false">http://www.squarefree.com/?p=410</guid>
		<description><![CDATA[I gave my new fuzzer a break from testing TraceMonkey by asking it to look for differences between SpiderMonkey and JavaScriptCore. I have listed them below, with SpiderMonkey output above JavaScriptCore output. I have no idea how many of these are bugs (in SpiderMonkey or JavaScriptCore) and how many are ambiguous in the spec (intentionally [...]]]></description>
			<content:encoded><![CDATA[<p>I gave my new fuzzer a break from <a href="http://www.squarefree.com/2008/12/23/fuzzing-tracemonkey/">testing TraceMonkey</a> by asking it to look for differences between SpiderMonkey and JavaScriptCore.  I have listed them below, with SpiderMonkey output above JavaScriptCore output.</p>

<p>I have no idea how many of these are bugs (in SpiderMonkey or JavaScriptCore) and how many are ambiguous in the spec (intentionally or unintentionally).</p>



<h3>Early error reporting</h3>

<p>SpiderMonkey reports some errors at compile time that JavaScriptCore only reports at run time, if the code is actually hit.  The difference is most obvious (and most likely to cause compatibility problems) if the code is skipped.</p>

<pre>&gt; if (false) { --1; }
<span class="spidermonkey"  >S: SyntaxError: invalid decrement operand</span>
<span class="javascriptcore">J: (no error)</span></pre>


<pre>&gt; if (false) { return; }
<span class="spidermonkey"  >S: SyntaxError: return not in function</span>
<span class="javascriptcore">J: (no error)</span></pre>


<h3>instanceof</h3>

<p>The two engines disagree about what objects are reasonable operands for the 'instanceof' operator.</p>

<pre>&gt; ({} instanceof {a:2})
<span class="spidermonkey"  >S: typein:3: TypeError: invalid 'instanceof' operand ({a:2})</span>
<span class="javascriptcore">J: false</span></pre>


<pre>&gt; ({} instanceof eval)
<span class="spidermonkey"  >S: false</span>
<span class="javascriptcore">J: Exception: TypeError: instanceof called on an object with an invalid prototype property.</span></pre>




<h3>new with native functions</h3>

<p>SpiderMonkey allows the "new" operator to be used with some native functions that JavaScriptCore considers non-constructors.</p>


<pre>&gt; new Math.sqrt(16)
<span class="spidermonkey"  >S: 4</span>
<span class="javascriptcore">J: Exception: TypeError: Result of expression 'Math.sqrt' ... is not a constructor.</span></pre>


<pre>&gt; new ({}.toString)
<span class="spidermonkey"  >S: [object Object]</span>
<span class="javascriptcore">J: Exception: TypeError: Result of expression '({}.toString)' ... is not a constructor.</span></pre>


<pre>&gt; new eval
<span class="spidermonkey"  >S: typein:9: EvalError: function eval must be called directly, and not by way of a function of another name</span>
<span class="javascriptcore">J: Exception: TypeError: Result of expression 'eval' ... is not a constructor.</span></pre>




<h3>Converting between numbers and strings</h3>

<pre>&gt; print(+'\00000027')
<span class="spidermonkey"  >S: NaN</span>
<span class="javascriptcore">J: 0</span></pre>


<pre>&gt; (1e-10).toString(16)
<span class="spidermonkey"  >S: 0.000000006df37f675ef6ec</span>
<span class="javascriptcore">J: 0</span></pre>




<h3>const</h3>

<p>There are subtle differences in handling of this new keyword.</p>


<pre>&gt; const d; const d;
<span class="spidermonkey"  >S: TypeError: redeclaration of const d</span>
<span class="javascriptcore">J: (no error)</span></pre>


<pre>&gt; const c = 0; print(++c);
<span class="spidermonkey"  >S: 0</span>
<span class="javascriptcore">J: 1</span></pre>



<h3>Other differences</h3>


<pre>&gt; print((function(){return arguments;})());
<span class="spidermonkey"  >S: [object Object]</span>
<span class="javascriptcore">J: [object Arguments]</span></pre>


<pre>&gt; typeof /x/
<span class="spidermonkey"  >S: object</span>
<span class="javascriptcore">J: function</span></pre>

<p>See <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=61911">Mozilla bug 61911</a>, which changed this in SpiderMonkey in 2007.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.squarefree.com/2008/12/23/differences/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

