error with mongo on ruby

I am trying to run a map-reduce and it is failing with the following error :

/usr/lib/ruby/gems/1.8/gems/mongo-1.4.0/lib/../lib/mongo/db.rb:520:in `command': Database command 'mapreduce' failed: (errmsg: 'assertion: assertion scripting/engine_spidermonkey.cpp:433'; ok: '0.0'). (Mongo::OperationFailure)   from /usr/lib/ruby/gems/1.8/gems/mongo-1.4.0/lib/../lib/mongo/ collection.rb:618:in `map_reduce'   from unique-sites.rb:164

The map reduce works okay if a smaller dataset is provided. Can someone please help ?

Thanks Pankaj

HEre are the map and reduce functions:

map = "function() { if ( this.sites ) " +                  "{ " +                    " var parent_deviceid=this.deviceid; "+                    " var unique_total_dur = new Object(); " +                    " this.sites.forEach(function(site_entry) { " +                    " var validDur = 0; "+                    " if ( site_entry.duration ) "+                    " validDur = site_entry.duration; "+                    " if ( site_entry.url in unique_total_dur ) " +                         " unique_total_dur[site_entry.url] += validDur; "+                    " else { " +                           " unique_total_dur[site_entry.url] = 0; "+                           " unique_total_dur[site_entry.url] += validDur; "+                       "}}); " +                      " for( var visited_site in unique_total_dur ) { "