|
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/. */ |
|
5 |
|
6 //----------------------------------------------------------------------------- |
|
7 var BUGNUMBER = 341956; |
|
8 var summary = 'GC Hazards in jsarray.c - reverse'; |
|
9 var actual = 'No Crash'; |
|
10 var expect = 'No Crash'; |
|
11 |
|
12 //----------------------------------------------------------------------------- |
|
13 test(); |
|
14 //----------------------------------------------------------------------------- |
|
15 |
|
16 function test() |
|
17 { |
|
18 enterFunc ('test'); |
|
19 printBugNumber(BUGNUMBER); |
|
20 printStatus (summary); |
|
21 |
|
22 var N = 0xFFFFFFFF; |
|
23 var a = []; |
|
24 a[N - 1] = 0; |
|
25 |
|
26 var expected = "GETTER RESULT"; |
|
27 |
|
28 a.__defineGetter__(N - 1, function() { |
|
29 delete a[N - 1]; |
|
30 var tmp = []; |
|
31 tmp[N - 2] = 1; |
|
32 |
|
33 if (typeof gc == 'function') |
|
34 gc(); |
|
35 for (var i = 0; i != 50000; ++i) { |
|
36 var tmp = 1 / 3; |
|
37 tmp /= 10; |
|
38 } |
|
39 for (var i = 0; i != 1000; ++i) { |
|
40 // Make string with 11 characters that would take |
|
41 // (11 + 1) * 2 bytes or sizeof(JSAtom) so eventually |
|
42 // malloc will ovewrite just freed atoms. |
|
43 var tmp2 = Array(12).join(' '); |
|
44 } |
|
45 return expected; |
|
46 }); |
|
47 |
|
48 // The following always-throw getter is to stop unshift from doing |
|
49 // 2^32 iterations. |
|
50 var toStop = "stringToStop"; |
|
51 a[N - 3] = 0; |
|
52 a.__defineGetter__(N - 3, function() { throw toStop; }); |
|
53 |
|
54 |
|
55 var good = false; |
|
56 |
|
57 try { |
|
58 a.reverse(); |
|
59 } catch (e) { |
|
60 if (e === toStop) |
|
61 good = true; |
|
62 } |
|
63 |
|
64 expect = true; |
|
65 actual = good; |
|
66 |
|
67 reportCompare(expect, actual, summary); |
|
68 |
|
69 print('Done'); |
|
70 |
|
71 exitFunc ('test'); |
|
72 } |