js/src/tests/js1_5/extensions/regress-345967.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_5/extensions/regress-345967.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,68 @@
     1.4 +// |reftest| skip -- slow
     1.5 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +//-----------------------------------------------------------------------------
    1.11 +var BUGNUMBER = 345967;
    1.12 +var summary = 'Yet another unrooted atom in jsarray.c';
    1.13 +var actual = '';
    1.14 +var expect = '';
    1.15 +
    1.16 +
    1.17 +//-----------------------------------------------------------------------------
    1.18 +test();
    1.19 +//-----------------------------------------------------------------------------
    1.20 +
    1.21 +function test()
    1.22 +{
    1.23 +  enterFunc ('test');
    1.24 +  printBugNumber(BUGNUMBER);
    1.25 +  printStatus (summary);
    1.26 +
    1.27 +  expectExitCode(0);
    1.28 +  expectExitCode(3);
    1.29 +
    1.30 +  print('This test will probably run out of memory');
    1.31 +  print('This test really should only fail on 64 bit machines');
    1.32 + 
    1.33 +  var JSVAL_INT_MAX = (1 << 30) - 1;
    1.34 +
    1.35 +  var a = new Array(JSVAL_INT_MAX + 2);
    1.36 +  a[JSVAL_INT_MAX] = 0;
    1.37 +  a[JSVAL_INT_MAX + 1] = 1;
    1.38 +
    1.39 +  a.__defineGetter__(JSVAL_INT_MAX, function() { return 0; });
    1.40 +
    1.41 +  a.__defineSetter__(JSVAL_INT_MAX, function(value) {
    1.42 +		       delete a[JSVAL_INT_MAX + 1];
    1.43 +		       var tmp = [];
    1.44 +		       tmp[JSVAL_INT_MAX + 2] = 2;
    1.45 +
    1.46 +		       if (typeof gc == 'function')
    1.47 +			 gc();
    1.48 +		       for (var i = 0; i != 50000; ++i) {
    1.49 +			 var tmp = 1 / 3;
    1.50 +			 tmp /= 10;
    1.51 +		       }
    1.52 +		       for (var i = 0; i != 1000; ++i) {
    1.53 +			 // Make string with 11 characters that would take
    1.54 +			 // (11 + 1) * 2 bytes or sizeof(JSAtom) so eventually
    1.55 +			 // malloc will ovewrite just freed atoms.
    1.56 +			 var tmp2 = Array(12).join(' ');
    1.57 +		       }
    1.58 +		     });
    1.59 +
    1.60 +
    1.61 +  a.shift();
    1.62 +
    1.63 +  expect = 0;
    1.64 +  actual = a[JSVAL_INT_MAX];
    1.65 +  if (expect !== actual)
    1.66 +    print("BAD");
    1.67 +
    1.68 +  reportCompare(expect, actual, summary);
    1.69 +
    1.70 +  exitFunc ('test');
    1.71 +}

mercurial