Debian Codegraph @

rhino/testsrc/tests/js1_5/extensions/regress-341956-03.js

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