|
1 // |reftest| skip -- slow |
|
2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
3 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 //----------------------------------------------------------------------------- |
|
8 var BUGNUMBER = 345967; |
|
9 var summary = 'Yet another unrooted atom in jsarray.c'; |
|
10 var actual = ''; |
|
11 var expect = ''; |
|
12 |
|
13 |
|
14 //----------------------------------------------------------------------------- |
|
15 test(); |
|
16 //----------------------------------------------------------------------------- |
|
17 |
|
18 function test() |
|
19 { |
|
20 enterFunc ('test'); |
|
21 printBugNumber(BUGNUMBER); |
|
22 printStatus (summary); |
|
23 |
|
24 expectExitCode(0); |
|
25 expectExitCode(3); |
|
26 |
|
27 print('This test will probably run out of memory'); |
|
28 print('This test really should only fail on 64 bit machines'); |
|
29 |
|
30 var JSVAL_INT_MAX = (1 << 30) - 1; |
|
31 |
|
32 var a = new Array(JSVAL_INT_MAX + 2); |
|
33 a[JSVAL_INT_MAX] = 0; |
|
34 a[JSVAL_INT_MAX + 1] = 1; |
|
35 |
|
36 a.__defineGetter__(JSVAL_INT_MAX, function() { return 0; }); |
|
37 |
|
38 a.__defineSetter__(JSVAL_INT_MAX, function(value) { |
|
39 delete a[JSVAL_INT_MAX + 1]; |
|
40 var tmp = []; |
|
41 tmp[JSVAL_INT_MAX + 2] = 2; |
|
42 |
|
43 if (typeof gc == 'function') |
|
44 gc(); |
|
45 for (var i = 0; i != 50000; ++i) { |
|
46 var tmp = 1 / 3; |
|
47 tmp /= 10; |
|
48 } |
|
49 for (var i = 0; i != 1000; ++i) { |
|
50 // Make string with 11 characters that would take |
|
51 // (11 + 1) * 2 bytes or sizeof(JSAtom) so eventually |
|
52 // malloc will ovewrite just freed atoms. |
|
53 var tmp2 = Array(12).join(' '); |
|
54 } |
|
55 }); |
|
56 |
|
57 |
|
58 a.shift(); |
|
59 |
|
60 expect = 0; |
|
61 actual = a[JSVAL_INT_MAX]; |
|
62 if (expect !== actual) |
|
63 print("BAD"); |
|
64 |
|
65 reportCompare(expect, actual, summary); |
|
66 |
|
67 exitFunc ('test'); |
|
68 } |