js/src/tests/js1_5/extensions/regress-341956-01.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 //-----------------------------------------------------------------------------
     7 var BUGNUMBER = 341956;
     8 var summary = 'GC Hazards in jsarray.c - unshift';
     9 var actual = 'No Crash';
    10 var expect = 'No Crash';
    12 //-----------------------------------------------------------------------------
    13 test();
    14 //-----------------------------------------------------------------------------
    16 function test()
    17 {
    18   enterFunc ('test');
    19   printBugNumber(BUGNUMBER);
    20   printStatus (summary);
    22   var N = 0xFFFFFFFF;
    24   var a = [];
    25   a[N - 1] = 1;
    26   a.__defineGetter__(N - 1, function() {
    27 		       var tmp = [];
    28 		       tmp[N - 2] = 0;
    29 		       if (typeof gc == 'function')
    30 			 gc();
    31 		       for (var i = 0; i != 50000; ++i) {
    32 			 var tmp = 1 / 3;
    33 			 tmp /= 10;
    34 		       }
    35 		       for (var i = 0; i != 1000; ++i) {
    36 			 // Make string with 11 characters that would take
    37 			 // (11 + 1) * 2 bytes or sizeof(JSAtom) so eventually
    38 			 // malloc will ovewrite just freed atoms.
    39 			 var tmp2 = Array(12).join(' ');
    40 		       }
    41 		       return 10;
    42 		     });
    45 // The following always-throw getter is to stop unshift from doing
    46 // 2^32 iterations.
    47   var toStop = "stringToStop";
    48   a[N - 3] = 0;
    49   a.__defineGetter__(N - 3, function() { throw toStop; });
    51   var good = false;
    53   try {
    54     a.unshift(1);
    55   } catch (e) {
    56     if (e === toStop)
    57       good = true;
    58   }
    60   expect = true;
    61   actual = good;
    63   reportCompare(expect, actual, summary);
    65   print('Done');
    67   exitFunc ('test');
    68 }

mercurial